README.md in fitting-1.5.0 vs README.md in fitting-1.6.0
- old
+ new
@@ -1,13 +1,12 @@
# Fitting
[](https://travis-ci.org/funbox/fitting)
-This gem will help to make your tests according to the documentation for the API.
+This gem will help to realize your API in strict accordance with the documentation in the format API Bluprint.
+To do this, when you run your RSpes tests on the controller, in the documentation automatically searches for the json-schema and then validate it with a response in the test.
-When writing tests, you can be sure that the implement API in accordance with documentation on API Blueprint.
-
## Installation
Add this line to your application's Gemfile:
```ruby
@@ -25,44 +24,85 @@
## Usage
In your `spec_helper.rb`:
```ruby
-config.include JSON::SchemaMatchers
+ Fitting.configure do |config|
+ config.apib_path = `doc.apib`
+ end
```
-This gem takes a simplified format json convert from API Blueprint which we have called API Tomogram.
+## Example output
-Use gem [tomograph](https://github.com/funbox/tomograph)
+After running tests you will get statistics in the console.
-```ruby
- Fitting.configure do |config|
- config.tomogram = 'tomogram.json'
- end
-
```
+Fully conforming requests:
+DELETE /api/v1/book ✔ 200 ✔ 201 ✔ 404
+DELETE /api/v1/book/{id} ✔ 200 ✔ 201 ✔ 404
+GET /api/v1/book/{id}/seller ✔ 200 ✔ 201 ✔ 404
+
+Partially conforming requests:
+GET /api/v1/book ✖ 200 ✔ 404
+POST /api/v1/book ✖ 200 ✔ 201 ✔ 404
+GET /api/v1/book/{id} ✖ 200 ✔ 404 ✔ 200
+PATCH /api/v1/book/{id} ✖ 200 ✔ 201 ✔ 404
+
+Non-conforming requests:
+GET /api/v1/seller ✖ 200 ✖ 201 ✖ 404
+GET /api/v1/buyer ✖ 200 ✖ 404
+
+API requests with fully implemented responses: 3 (33.33% of 9).
+API requests with partially implemented responses: 4 (44.44% of 9).
+API requests with no implemented responses: 2 (22.22% of 9).
+
+API responses conforming to the blueprint: 16 (64.00% of 25).
+API responses with validation errors or untested: 9 (36.00% of 25).
+```
-You can then write tests such as:
+## Matchers
-```ruby
- expect(response).to match_response
+If you want know describe why you get crosses instead of checkmarks you can use matchers for RSpec.
+
+### match_response
+
+Makes a simple validation JSON Schema.
+
```
+expect(response).to match_response
+```
-If you want check all tests:
+### strict_match_response
-```ruby
-config.after(:each, :type => :controller) do
- expect(response).to match_response
-end
+Makes a strict validation JSON Schema. All properties are condisidered to have `"required": true` and all objects `"additionalProperties": false`.
+
```
+expect(response).to strict_match_response
+```
## Config
+### apib_path
+
+Path for API Blueprint documentation. There must be an installed library [drafter](https://github.com/apiaryio/drafter).
+
+### drafter_yaml_path
+
+Path for API Blueprint documentation after use drafter and transformation in yaml.
+
### necessary_fully_implementation_of_responses
Default `true`. It returns `exit 1` if not implemented all(with tests expect match response) the responses.
+### strict
+
+Default `false`. If `true` than all properties are condisidered to have `"required": true` and all objects `"additionalProperties": false`.
+
+### prefix
+
+Prefix for request.
+
### white_list
Default all resources. This is an array of resources that are mandatory for implementation.
This list does not affect the work of the match expert.
This list is only for the report in the console and verify implementation.
@@ -76,12 +116,18 @@
}
```
Empty array `[]` means all methods.
+Result be two statistic for two list.
+
### create_report_with_name
Create report with name.
+
+### show_statistics_in_console
+
+Default `true`.
## Report
Autogenerate `report_request_by_response.yaml` and `report_response.yaml reports`.