fitting 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/fitting.rb +14 -2
- data/lib/fitting/documentation/response/route.rb +1 -1
- data/lib/fitting/matchers/response_matcher.rb +4 -4
- data/lib/fitting/request.rb +2 -2
- data/lib/fitting/response.rb +4 -4
- data/lib/fitting/storage/skip.rb +15 -0
- data/lib/fitting/version.rb +1 -1
- metadata +2 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 06220f80408936409260ab3c2ae9ec2ca4150688
         | 
| 4 | 
            +
              data.tar.gz: b47cb00f2e71872775753041f1008d4c26484e35
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 4750c9efa6c63c0bda3895adccc1da21561905d261af985a0e4dc7fc735d1af8eb7fc76367776285b21ec2faf879a159aa4a9fe81d81bfb46d35a2a87538987b
         | 
| 7 | 
            +
              data.tar.gz: 97f88a0b890bcc70bf6ed41f2f2044007dea8b75680aaaf1fe4b883cc2d3d5b0d9e11584456179c1ef6371e66f88d7facf6ad84e37c5313783ecd0760d0cd450
         | 
    
        data/lib/fitting.rb
    CHANGED
    
    | @@ -4,6 +4,7 @@ require 'fitting/documentation/response/route' | |
| 4 4 | 
             
            require 'fitting/documentation/request/route'
         | 
| 5 5 | 
             
            require 'fitting/storage/responses'
         | 
| 6 6 | 
             
            require 'fitting/storage/documentation'
         | 
| 7 | 
            +
            require 'fitting/storage/skip'
         | 
| 7 8 | 
             
            require 'fitting/report/response'
         | 
| 8 9 | 
             
            require 'fitting/matchers/response_matcher'
         | 
| 9 10 |  | 
| @@ -27,14 +28,25 @@ module RSpec | |
| 27 28 |  | 
| 28 29 | 
             
                  def run_specs(example_groups)
         | 
| 29 30 | 
             
                    origin_run_specs(example_groups)
         | 
| 30 | 
            -
             | 
| 31 | 
            +
             | 
| 32 | 
            +
                    return if Fitting::Storage::Skip.get
         | 
| 31 33 |  | 
| 32 34 | 
             
                    response_routes = Fitting::Documentation::Response::Route.new(
         | 
| 33 35 | 
             
                      Fitting::Storage::Documentation.hash,
         | 
| 34 36 | 
             
                      Fitting::Storage::Responses.all
         | 
| 35 37 | 
             
                    )
         | 
| 36 38 | 
             
                    request_routes = Fitting::Documentation::Request::Route.new(response_routes)
         | 
| 37 | 
            -
             | 
| 39 | 
            +
             | 
| 40 | 
            +
                    valid_count = response_routes.coverage.size
         | 
| 41 | 
            +
                    valid_percentage = response_routes.cover_ratio
         | 
| 42 | 
            +
                    total_count = response_routes.all.size
         | 
| 43 | 
            +
                    invalid_count = response_routes.not_coverage.size
         | 
| 44 | 
            +
                    invalid_percentage = 100.0 - response_routes.cover_ratio
         | 
| 45 | 
            +
                    puts "API responses conforming to the blueprint: #{valid_count} (#{valid_percentage}% of #{total_count})."
         | 
| 46 | 
            +
                    puts "API responses with validation errors or untested: #{invalid_count} (#{invalid_percentage}% of #{total_count})."
         | 
| 47 | 
            +
                    puts
         | 
| 48 | 
            +
                    puts "Conforming responses: \n#{response_routes.coverage.join("\n")} \n\n"
         | 
| 49 | 
            +
                    puts "Non-conforming responses: \n#{response_routes.not_coverage.join("\n")}\n\n"
         | 
| 38 50 | 
             
                    Fitting::Report::Response.new('report_response.yaml', response_routes).save
         | 
| 39 51 | 
             
                    Fitting::Report::Response.new('report_request_by_response.yaml', request_routes).save
         | 
| 40 52 | 
             
                  end
         | 
| @@ -27,7 +27,7 @@ module Fitting | |
| 27 27 | 
             
                          responses
         | 
| 28 28 | 
             
                        end.map do |status, indexes|
         | 
| 29 29 | 
             
                          indexes.times do |index|
         | 
| 30 | 
            -
                            route = "#{request['method']} | 
| 30 | 
            +
                            route = "#{request['method']}\t#{request['path']} #{status} #{index}"
         | 
| 31 31 | 
             
                            routes.push(route)
         | 
| 32 32 | 
             
                          end
         | 
| 33 33 | 
             
                        end
         | 
| @@ -25,10 +25,10 @@ module Fitting | |
| 25 25 | 
             
                    end
         | 
| 26 26 |  | 
| 27 27 | 
             
                    unless @response.valid?
         | 
| 28 | 
            -
                      "response not  | 
| 29 | 
            -
                      " | 
| 30 | 
            -
                      " | 
| 31 | 
            -
                      " | 
| 28 | 
            +
                      "response does not conform to json-schema\n"\
         | 
| 29 | 
            +
                      "schemas: \n#{@response.expected}\n\n"\
         | 
| 30 | 
            +
                      "got: #{@response.got}\n\n"\
         | 
| 31 | 
            +
                      "errors: \n#{@response.diff}\n"
         | 
| 32 32 | 
             
                    end
         | 
| 33 33 | 
             
                  end
         | 
| 34 34 | 
             
                end
         | 
    
        data/lib/fitting/request.rb
    CHANGED
    
    | @@ -14,11 +14,11 @@ module Fitting | |
| 14 14 | 
             
                end
         | 
| 15 15 |  | 
| 16 16 | 
             
                def route
         | 
| 17 | 
            -
                  "#{@schema['method']} | 
| 17 | 
            +
                  "#{@schema['method']}\t#{@schema['path']}"
         | 
| 18 18 | 
             
                end
         | 
| 19 19 |  | 
| 20 20 | 
             
                def real_method_with_path
         | 
| 21 | 
            -
                  "#{@method} | 
| 21 | 
            +
                  "#{@method}\t#{@path}"
         | 
| 22 22 | 
             
                end
         | 
| 23 23 |  | 
| 24 24 | 
             
                def schemas_of_possible_responses(status:)
         | 
    
        data/lib/fitting/response.rb
    CHANGED
    
    | @@ -44,14 +44,14 @@ module Fitting | |
| 44 44 |  | 
| 45 45 | 
             
                def diff
         | 
| 46 46 | 
             
                  @fully_validates.inject("") do |res, fully_validate|
         | 
| 47 | 
            -
                    res + "#{fully_validate}\n"
         | 
| 47 | 
            +
                    res + "#{fully_validate.join("\n")}\n\n"
         | 
| 48 48 | 
             
                  end
         | 
| 49 49 | 
             
                end
         | 
| 50 50 |  | 
| 51 51 | 
             
                def expected
         | 
| 52 | 
            -
                  @schemas.inject( | 
| 53 | 
            -
                    res | 
| 54 | 
            -
                  end
         | 
| 52 | 
            +
                  @schemas.inject([]) do |res, schema|
         | 
| 53 | 
            +
                    res.push("#{schema}")
         | 
| 54 | 
            +
                  end.join("\n\n")
         | 
| 55 55 | 
             
                end
         | 
| 56 56 |  | 
| 57 57 | 
             
                private
         | 
    
        data/lib/fitting/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: fitting
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1. | 
| 4 | 
            +
              version: 1.1.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - d.efimov
         | 
| @@ -200,6 +200,7 @@ files: | |
| 200 200 | 
             
            - lib/fitting/response.rb
         | 
| 201 201 | 
             
            - lib/fitting/storage/documentation.rb
         | 
| 202 202 | 
             
            - lib/fitting/storage/responses.rb
         | 
| 203 | 
            +
            - lib/fitting/storage/skip.rb
         | 
| 203 204 | 
             
            - lib/fitting/version.rb
         | 
| 204 205 | 
             
            homepage: https://github.com/funbox/fitting
         | 
| 205 206 | 
             
            licenses:
         |