Skip to content

Commit

Permalink
fix(api): add integration tests
Browse files Browse the repository at this point in the history
BREAKING CHANGE: two method signatures and one property name have changed.

**Objects & Properties**

1. readmeInspector.ReadmeScore - refactor:rename ReadmeScore ➡️ ReadmeAppraisal
2. module:readme-inspector/readme-score - refactor:rename 'ReadmeScore'
   module:readme-inspector/readme-appraisal 'ReadmeAppraisal', which is now
   a class.

**Functions**

1. getReadmeInfo
1.1. Function name - refactor:rename ➡️ getInfo
1.2. Function signature - now expects a params object literal

2. getReadmeScore
2.1. Function name - refactor:rename ➡️ getAppraisal
2.2. Function signature remains the same as in 1.x.x.

3. check's signature now expects a params object literal,
   which it passes to getInfo.

**API tests**

Add API (integration) tests to verify appraisal initialization.

1. Create the lib/__apis__/ directory
2. Add Jest/Jasmine specs without mocks
3. Invoke real APIs for results

**CI**

1. Create four ENV variables on Appveyor.
2. Customize greenkeeper commit messages

**Documentation**

- Use commonality branding colors for 'Request a Feature' and
  'Report a Defect' badges
- Move DEVELOPERS.md user the /docs/project/ directory
- Add secure variables to  for API testing
- Iterate through filepaths with markdown files that require
  automated content generation

GH-18,GH-21
  • Loading branch information
gregswindle authored Apr 21, 2018
1 parent ad96ea5 commit 96546fe
Show file tree
Hide file tree
Showing 128 changed files with 46,438 additions and 428 deletions.
8 changes: 4 additions & 4 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -598,8 +598,8 @@
| [got@8.3.0](https://github.com/sindresorhus/got#readme) | Simplified HTTP requests | 8.3.0 | MIT | production |
| [insight@0.10.1](https://github.com/yeoman/insight#readme) | Understand how your tool is being used by anonymously reporting usage metrics to Google Analytics or Yandex.Metrica | 0.10.1 | BSD-2-Clause | production |
| [lodash.camelcase@4.3.0](https://lodash.com/) | The lodash method `_.camelCase` exported as a module. | 4.3.0 | MIT | production |
| [lodash.isstring@4.0.1](https://lodash.com/) | The lodash method `_.isString` exported as a module. | 4.0.1 | MIT | production |
| [lodash.transform@4.6.0](https://lodash.com/) | The lodash method `_.transform` exported as a module. | 4.6.0 | MIT | production |
| [lodash.mapkeys@4.6.0](https://lodash.com/) | The lodash method `_.mapKeys` exported as a module. | 4.6.0 | MIT | production |
| [lodash.noop@3.0.1](https://lodash.com/) | The lodash method `_.noop` exported as a module. | 3.0.1 | MIT | production |
| [meow@4.0.0](https://github.com/sindresorhus/meow#readme) | CLI app helper | 4.0.0 | MIT | production |
<!-- AUTO-GENERATED-CONTENT:END -->
Expand All @@ -611,7 +611,7 @@
| **Dependency** | **Description** | **Version** | **License** | **Type** |
| -------------- | --------------- | ----------- | ----------- | -------- |
| [@semantic-release/changelog@2.0.1](https://github.com/semantic-release/changelog#readme) | Set of semantic-release plugins for creating or updating a changelog file | 2.0.1 | MIT | dev |
| [@semantic-release/git@4.0.1](https://github.com/semantic-release/git#readme) | Set of semantic-release plugins to publish to a git repository | 4.0.1 | MIT | dev |
| [@semantic-release/git@4.0.2](https://github.com/semantic-release/git#readme) | Set of semantic-release plugins to publish to a git repository | 4.0.2 | MIT | dev |
| [@semantic-release/npm@3.2.4](https://github.com/semantic-release/npm#readme) | Set of semantic-release plugins to publish to a npm registry | 3.2.4 | MIT | dev |
| [ajv@6.4.0](https://github.com/epoberezkin/ajv) | Another JSON Schema Validator | 6.4.0 | MIT | dev |
| [ajv-keywords@3.1.0](https://github.com/epoberezkin/ajv-keywords#readme) | Custom JSON-Schema keywords for Ajv validator | 3.1.0 | MIT | dev |
Expand Down Expand Up @@ -649,7 +649,7 @@
| [markdown-magic-package-scripts@1.2.1](https://github.com/camacho/markdown-magic-package-scripts#readme) | Print list of scripts in package.json with descriptions | 1.2.1 | MIT | dev |
| [minami@1.2.3](https://github.com/Nijikokun/minami) | Clean and minimal JSDoc 3 Template / Theme | 1.2.3 | UNLICENSED | dev |
| [nsp@^3.2.1](https://github.com/nodesecurity/nsp#readme) | The Node Security (nodesecurity.io) command line interface | 3.2.1 | Apache-2.0 | dev |
| [prettier@1.12.1](https://prettier.io) | Prettier is an opinionated code formatter | 1.12.0 | MIT | dev |
| [prettier@1.12.1](https://prettier.io) | Prettier is an opinionated code formatter | 1.12.1 | MIT | dev |
| [semantic-release@15.1.7](https://github.com/semantic-release/semantic-release#readme) | Automated semver compliant package publishing | 15.1.7 | MIT | dev |
| [standard-markdown@4.0.2](https://github.com/zeke/standard-markdown#readme) | Test your Markdown files for Standard JavaScript Style™ | 4.0.2 | MIT | dev |
| [standard-version@4.3.0](https://github.com/conventional-changelog/standard-version#readme) | replacement for `npm version` with automatic CHANGELOG generation | 4.3.0 | ISC | dev |
Expand Down
70 changes: 70 additions & 0 deletions .github/assets/examples/usage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// Load all .env variables before anything else.

const dotenvExtended = require('dotenv-extended')
const envConfig = dotenvExtended.config()

// Import readme-inspector.

const readmeInspector = require('readme-inspector')

// Recommended: authenticate to avoid rate limts.

readmeInspector.authenticate({
token: envConfig.GH_TOKEN,
type: 'oauth'
})

// Verify that the repository with the slug
// gregswindle/github-resource-converter
// 1. Has a README, and
// 2. Score the README for quality.

const info = await readmeInspector.check(
'gregswindle',
'github-resource-converter'
)

// Display the resulting readmeInfo as a
// JSON string.

const WHITESPACE = 2
console.log(JSON.stringify(results, null, WHITESPACE))
// =>
/*
{
"appraisal": {
"breakdown": {
"cumulativeCodeBlockLength": 0,
"hasLists": 0,
"lowCodeBlockPenalty": 0,
"numberOfCodeBlocks": 0,
"numberOfGifs": 0,
"numberOfImages": 0,
"numberOfNonCodeSections": 0
},
"error": null,
"score": 0,
"url": null
},
"error": null,
"isPresent": true,
"value": {
"name": "README.md",
"path": "README.md",
"sha": "4769744aad57ff3e9aac2df603795c4d10fcdc31",
"size": 36877,
"url": "https://api.github.com/repos/commonality/readme-inspector/contents/README.md?ref=master",
"html_url": "https://github.com/commonality/readme-inspector/blob/master/README.md",
"git_url": "https://api.github.com/repos/commonality/readme-inspector/git/blobs/4769744aad57ff3e9aac2df603795c4d10fcdc31",
"download_url": "https://raw.githubusercontent.com/commonality/readme-inspector/master/README.md",
"type": "file",
"content": "{base64-encoding-of-readme-markdown}",
"encoding": "base64",
"_links": {
"self": "https://api.github.com/repos/commonality/readme-inspector/contents/README.md?ref=master",
"git": "https://api.github.com/repos/commonality/readme-inspector/git/blobs/4769744aad57ff3e9aac2df603795c4d10fcdc31",
"html": "https://github.com/commonality/readme-inspector/blob/master/README.md"
}
}
}
*/
2 changes: 1 addition & 1 deletion .github/config/.jsdoc.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"showInheritedInNav": true
},
"opts": {
"destination": "./docs/",
"destination": "./docs/api/",
"encoding": "utf8",
"private": true,
"recurse": true,
Expand Down
10 changes: 6 additions & 4 deletions .github/config/markdown.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ const config = {

const main = () => {
let markdownPath = path.join(__dirname, '**/*.md')
markdownMagic(markdownPath, config)
let index = 0
let paths = ['**/*.md', '../CONTRIBUTING.md', '../../docs/**/*.md']

markdownPath = path.join(__dirname, '..', 'CONTRIBUTING.md')
console.log(markdownPath)
markdownMagic(markdownPath, config)
paths.forEach(filePath => {
markdownPath = path.join(__dirname, filePath)
markdownMagic(markdownPath, config)
})
}

main()
2 changes: 1 addition & 1 deletion .github/config/sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ sonar.sourceEncoding=UTF-8
sonar.organization=commonality
sonar.projectKey=readme-inspector
sonar.projectName=readme-inspector
sonar.projectVersion=1.0.2
# sonar.projectVersion=1.0.2

# =====================================================
# Meta-data for the project
Expand Down
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ script:
after_script:
- npm run posttest:ci:coverage:codacy
- npm run posttest:ci:coverage:coveralls
- sonar-scanner -Dproject.settings=./.github/config/sonar-project.properties -Dsonar.organization=$SONAR_ORGANIZATION
-Dsonar.login=$SONAR_COMMONALITY_TOKEN -X
- npm run code-quality:sonar
jobs:
include:
- stage: release
Expand Down
71 changes: 59 additions & 12 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,47 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

---

<a name="2.0.0"></a>

## [2.0.0](https://github.com/commonality/readme-inspector/compare/v1.0.2...v2.0.0) (2018-04-21)

### Bug Fixes

* **@semantic-release/git:** update to version 4.0.2 ([ad96ea5](https://github.com/commonality/readme-inspector/commit/ad96ea5))
* **score:** verify appraisal initialization ([fd87a8b](https://github.com/commonality/readme-inspector/commit/fd87a8b)), closes [#18](https://github.com/commonality/readme-inspector/issues/18) [#21](https://github.com/commonality/readme-inspector/issues/21)

### BREAKING CHANGES

**readme-score:** `ReadmeScore` is now `ReadmeAppraisal`, with two method signatures changes and one property name change.

#### Objects & Properties

`readmeInspector.ReadmeScore` - refactor:rename `ReadmeScore``ReadmeAppraisal`, which is now a class.

#### Functions

1. `readmeInspector.getReadmeInfo``readmeInspector.getInfo`

> * Refactor:rename function
>
> * Refactor function signature: now expects a `params` object literal
2. `readmeInspector.getReadmeScore``readmeInspector.getAppraisal`

> Refactor:rename function; signature remains the same as in 1.x.x,
> however.
3. `readmeInspector.check`'s signature now expects a `params` object literal,
which it passes to `getInfo`.

#### API tests

Add API (integration) tests.

---

<a name="1.0.2"></a>

## [1.0.2](https://github.com/commonality/readme-inspector/compare/v1.0.1...v1.0.2) (2018-04-17)
Expand All @@ -14,6 +55,8 @@ All notable changes to this project will be documented in this file. See [standa
>
> Refactor `readmeScoreApiClientOptions` with a single property called `apiEndpoint: URL` in order to set the `url` query parameter explicitly, and call `apiEndpoint.toString()` for a serialized URL string.
---

<a name="1.0.1"></a>

## [1.0.1](https://github.com/commonality/readme-inspector/compare/v1.0.0...v1.0.1) (2018-04-16)
Expand All @@ -24,13 +67,17 @@ All notable changes to this project will be documented in this file. See [standa

Replaced [`dotenv`][dotenv-url] with [`dotenv-extended`][dotenv-extended-url] in order to load default values.

---

<a name="1.0.0"></a>

## 1.0.0 (2018-04-12)

### Features

* **module:readme-inspector:** Verify the existence—and assess the quality—of README files
* #### module:readme-inspector

Verify the existence—and assess the quality—of README files

> ![quote][octicon-quote] READMEs do more than explain how to use your project. They also
> explain why your project matters, and what your users can do with it.
Expand All @@ -47,29 +94,29 @@ All notable changes to this project will be documented in this file. See [standa
> licenses and attribution. If you don’t want to accept contributions, or
> your project is not yet ready for production, write this information down. <sup><a href="#ref-1" title="View reference.">[1]</a></sup>
**Public API**
* #### Public API

_Methods_

* `authenticate` - Sets GitHub credentials for all subsequent requests.
* `check` - Attempts to GET and assess a README at a repo-root directory.
* `getReadmeInfo` - Attempt to GET a README without assessing it.
* `getReadmeScore` - Assess the quality of a README.
> * `authenticate` - Sets GitHub credentials for all subsequent requests.
> * `check` - Attempts to GET and assess a README at a repo-root directory.
> * `getReadmeInfo` - Attempt to GET a README without assessing it.
> * `getReadmeScore` - Assess the quality of a README.
_Properties_

* `ReadmeScore` - An API proxy wrapper for the readme-score-api.
* `api` - A configurable Octokit instance.
> * `ReadmeScore` - An API proxy wrapper for the readme-score-api.
> * `api` - A configurable Octokit instance.
_Documentation_

Visit <https://github.com/commonality/readme-inspector/#readme> for
more information about installation, usage, API, version,
contributing guidelines, and licenses.
> Visit <https://github.com/commonality/readme-inspector/#readme> for
> more information about installation, usage, API, version,
> contributing guidelines, and licenses.
_Commit_

([e04a07a](https://github.com/commonality/readme-inspector/commit/e04a07a)), closes [#1](https://github.com/commonality/readme-inspector/issues/1)
> ([e04a07a](https://github.com/commonality/readme-inspector/commit/e04a07a)), closes [#1](https://github.com/commonality/readme-inspector/issues/1)
## References

Expand Down
Loading

0 comments on commit 96546fe

Please sign in to comment.