README.md in fitting-2.6.0 vs README.md in fitting-2.7.0

- old
+ new

@@ -37,35 +37,57 @@ In your `spec_helper.rb`: ```ruby require 'fitting' -Fitting.statistics +Fitting.save_test_data ``` -or +The tests.json file will be created -```ruby -require 'fitting' +Example: -responses = Fitting::Storage::Responses.new +``` +[ + { + "method": "GET", + "path": "/api/v1/book", + "body": {}, + "response": { + "status": 200, + "body": { + "title": "The Martian Chronicles" + } + }, + "title": "/spec/controllers/api/v1/books_controller_spec.rb:11", + "group": "/spec/controllers/api/v1/books_controller_spec.rb" + }, + { + "method": "POST", + "path": "/api/v1/book", + "body": {}, + "response": { + "status": 200, + "body": { + "title": "The Old Man and the Sea" + } + }, + "title": "/spec/controllers/api/v1/books_controller_spec.rb:22", + "group": "/spec/controllers/api/v1/books_controller_spec.rb" + }, + ... +``` -RSpec.configure do |config| - config.after(:each, type: :controller) do - responses.add(response) - end - config.after(:suite) do - responses.statistics.save - end -end -``` +## Check documentation cover -## Example output +### xs size -After running tests you will get statistics in the file `fitting/stats`: +For match routes and valid json-schemas run `rake fitting:documentation_responses[xs]` +You will get statistics: + ``` 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 @@ -86,36 +108,55 @@ API responses conforming to the blueprint: 16 (64.00% of 25). API responses with validation errors or untested: 9 (36.00% of 25). ``` -Also you will get not covered responses in the file `fitting/not_covered`. +### s size -## Matchers +In addition to the previous comand, you will learn the coverage json-schemas with task `rake fitting:documentation_responses[s]` -If you want to know why you get crosses instead of checkmarks you can use matchers for RSpec. - -```ruby -config.include Fitting::Matchers, type: :controller ``` +Fully conforming requests: +DELETE /api/v1/book 100% 200 100% 201 100% 404 +DELETE /api/v1/book/{id} 100% 200 100% 201 100% 404 +GET /api/v1/book/{id}/seller 100% 200 100% 201 100% 404 -### match_schema +Partially conforming requests: +GET /api/v1/book 0% 200 66% 404 +POST /api/v1/book 0% 200 90% 201 100% 404 +GET /api/v1/book/{id} 0% 200 88% 404 10% 200 +PATCH /api/v1/book/{id} 0% 200 100% 201 10% 404 -Makes a simple validation against JSON Schema. +Non-conforming requests: +GET /api/v1/seller 0% 200 0% 201 0 404 +GET /api/v1/buyer 0% 200 0% 404 -```ruby -expect(response).to match_schema +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). ``` -### strictly_match_schema +For details `rake fitting:documentation_responses_error[s]` -Makes a strict validation against JSON Schema. All properties are considered to have `"required": true` and all objects `"additionalProperties": false`. - -```ruby -expect(response).to strictly_match_schema ``` +request metohd: GET +request path: /api/v1/book +response staus: 200 +source json-schema: {"$schema"=>"http://json-schema.org/draft-04/schema#", "type"=>"object", ...} +combination: ["required", "pages"] +new json-schema: {"$schema"=>"http://json-schema.org/draft-04/schema#", "type"=>"object", ...} +``` +## Check tests cover + +### xs size + +`rake fitting:tests_responses[xs]` + ## Config You can specify the settings either in a yaml file `.fitting.yml` or in config. If your project uses several prefixes, for each one you need to create a separate yaml file in the folder `fitting` (`fitting/*.yml`). @@ -173,9 +214,14 @@ - GET /users/{id}/employees /sessions: [] ``` Empty array `[]` means all methods. + +### json_schema_cover + +Default: false. Json-schema covering becomes mandatory. +Or you can call `responses.statistics.cover_save` if you don't use call `Fitting.statistics`. ### include_resources Default: all resources if `include_resources` and `include_actions` is not used. This is an array of resources that are mandatory for implementation.