webspicy 0.26.0 → 0.27.1
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/webspicy/configuration.rb +1 -1
 - data/lib/webspicy/specification/post/missing_condition_impl.rb +1 -0
 - data/lib/webspicy/specification/post/unexpected_condition_impl.rb +1 -0
 - data/lib/webspicy/specification/service.rb +1 -1
 - data/lib/webspicy/support/deep_merge.rb +53 -33
 - data/lib/webspicy/tester/result/error_schema_met.rb +5 -2
 - data/lib/webspicy/tester/result/output_schema_met.rb +5 -2
 - data/lib/webspicy/tester.rb +5 -1
 - data/lib/webspicy/version.rb +2 -2
 - data/lib/webspicy/web/formaldoc.fio +32 -2
 - data/lib/webspicy/web/openapi/data_struct.rb +40 -0
 - data/lib/webspicy/web/openapi/reporter.rb +36 -0
 - data/lib/webspicy/web/openapi/utils.rb +210 -0
 - data/lib/webspicy/web/openapi.rb +3 -0
 - data/lib/webspicy/web/specification/pre/global_request_headers.rb +0 -1
 - data/lib/webspicy/web/specification/test_case.rb +32 -0
 - data/lib/webspicy/web/specification.rb +4 -0
 - data/spec/unit/configuration/scope/test_expand_example.rb +1 -1
 - data/spec/unit/web/specification/test_case/test_v2_ic.rb +50 -0
 - metadata +9 -5
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 80a8b39983717af6c599f4ef9fbd88bacfa408dbd16089f7b559ca8de2b46e39
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: c899bfe6f59ef4aec92e897bff3cff3899103feb0ca1640132a0a79c3968b50b
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: ba81af580827248b93f6ca3720ed845bc8010071a5311c134b8c4090b0bda65a8927298124c4cd18e8d2af9612cca55c9f1ebc25e219fac145d4c196ed8c771f
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 1b7fa160cda6a2b8cb412b46e928104e33c14b9fba3bebdbffd47aa68b72237b02622c3656277f19441f55f2951f140732c67568499686d60bbc038440a3a529
         
     | 
| 
         @@ -299,7 +299,7 @@ module Webspicy 
     | 
|
| 
       299 
299 
     | 
    
         
             
                # truthy value is returned will be considered by the scope.
         
     | 
| 
       300 
300 
     | 
    
         
             
                # - ===: any instance responding to `===` can be used as a matcher, following
         
     | 
| 
       301 
301 
     | 
    
         
             
                #   Ruby conventions. The match is done on a Service instance.
         
     | 
| 
       302 
     | 
    
         
            -
                def test_case_filter=( 
     | 
| 
      
 302 
     | 
    
         
            +
                def test_case_filter=(test_case_filter)
         
     | 
| 
       303 
303 
     | 
    
         
             
                  @test_case_filter = test_case_filter
         
     | 
| 
       304 
304 
     | 
    
         
             
                end
         
     | 
| 
       305 
305 
     | 
    
         
             
                attr_reader :test_case_filter
         
     | 
| 
         @@ -1,49 +1,69 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module Webspicy
         
     | 
| 
       2 
2 
     | 
    
         
             
              module Support
         
     | 
| 
       3 
3 
     | 
    
         
             
                class DeepMerge
         
     | 
| 
       4 
     | 
    
         
            -
                  class << self
         
     | 
| 
       5 
4 
     | 
    
         | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
      
 5 
     | 
    
         
            +
                  DEFAULT_OPTIONS = {
         
     | 
| 
      
 6 
     | 
    
         
            +
                    uniq_on_arrays: false
         
     | 
| 
      
 7 
     | 
    
         
            +
                  }
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                  def initialize(options = {})
         
     | 
| 
      
 10 
     | 
    
         
            +
                    @options = DEFAULT_OPTIONS.merge(options)
         
     | 
| 
      
 11 
     | 
    
         
            +
                  end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                  def self.deep_merge(*args, &bl)
         
     | 
| 
      
 14 
     | 
    
         
            +
                    new.deep_merge(*args, &bl)
         
     | 
| 
      
 15 
     | 
    
         
            +
                  end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                  def self.deep_dup(*args, &bl)
         
     | 
| 
      
 18 
     | 
    
         
            +
                    new.deep_dup(*args, &bl)
         
     | 
| 
      
 19 
     | 
    
         
            +
                  end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                  def self.symbolize_keys(*args, &bl)
         
     | 
| 
      
 22 
     | 
    
         
            +
                    new.symbolize_keys(*args, &bl)
         
     | 
| 
      
 23 
     | 
    
         
            +
                  end
         
     | 
| 
       18 
24 
     | 
    
         | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
      
 25 
     | 
    
         
            +
                  def symbolize_keys(arg)
         
     | 
| 
      
 26 
     | 
    
         
            +
                    case arg
         
     | 
| 
      
 27 
     | 
    
         
            +
                    when Hash
         
     | 
| 
      
 28 
     | 
    
         
            +
                      arg.each_pair.each_with_object({}){|(k,v),memo|
         
     | 
| 
      
 29 
     | 
    
         
            +
                        memo[k.to_sym] = symbolize_keys(v)
         
     | 
| 
      
 30 
     | 
    
         
            +
                      }
         
     | 
| 
      
 31 
     | 
    
         
            +
                    when Array
         
     | 
| 
      
 32 
     | 
    
         
            +
                      arg.map{|item| symbolize_keys(item) }
         
     | 
| 
      
 33 
     | 
    
         
            +
                    else
         
     | 
| 
      
 34 
     | 
    
         
            +
                      arg
         
     | 
| 
       21 
35 
     | 
    
         
             
                    end
         
     | 
| 
      
 36 
     | 
    
         
            +
                  end
         
     | 
| 
       22 
37 
     | 
    
         | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
      
 38 
     | 
    
         
            +
                  def deep_merge(h1, h2)
         
     | 
| 
      
 39 
     | 
    
         
            +
                    merge_maps(deep_dup(h1), deep_dup(h2))
         
     | 
| 
      
 40 
     | 
    
         
            +
                  end
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
                  def deep_dup(x)
         
     | 
| 
      
 43 
     | 
    
         
            +
                    case x
         
     | 
| 
      
 44 
     | 
    
         
            +
                    when Array
         
     | 
| 
      
 45 
     | 
    
         
            +
                      x.map{|y| deep_dup(y) }
         
     | 
| 
      
 46 
     | 
    
         
            +
                    when Hash
         
     | 
| 
      
 47 
     | 
    
         
            +
                      x.each_with_object({}){|(k,v),memo| memo[k] = deep_dup(v) }
         
     | 
| 
      
 48 
     | 
    
         
            +
                    else
         
     | 
| 
      
 49 
     | 
    
         
            +
                      x
         
     | 
| 
       32 
50 
     | 
    
         
             
                    end
         
     | 
| 
      
 51 
     | 
    
         
            +
                  end
         
     | 
| 
       33 
52 
     | 
    
         | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
      
 53 
     | 
    
         
            +
                private
         
     | 
| 
       35 
54 
     | 
    
         | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
     | 
    
         
            -
                         
     | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
       42 
     | 
    
         
            -
                         
     | 
| 
      
 55 
     | 
    
         
            +
                  def merge_maps(h1, h2)
         
     | 
| 
      
 56 
     | 
    
         
            +
                    h1.merge(h2) do |k,v1,v2|
         
     | 
| 
      
 57 
     | 
    
         
            +
                      case v1
         
     | 
| 
      
 58 
     | 
    
         
            +
                      when Hash
         
     | 
| 
      
 59 
     | 
    
         
            +
                        merge_maps(v1, v2)
         
     | 
| 
      
 60 
     | 
    
         
            +
                      when Array
         
     | 
| 
      
 61 
     | 
    
         
            +
                        @options[:uniq_on_arrays] ? (v1 + v2).uniq : v1 + v2
         
     | 
| 
      
 62 
     | 
    
         
            +
                      else v2
         
     | 
| 
       43 
63 
     | 
    
         
             
                      end
         
     | 
| 
       44 
64 
     | 
    
         
             
                    end
         
     | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
       46 
65 
     | 
    
         
             
                  end
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
       47 
67 
     | 
    
         
             
                end
         
     | 
| 
       48 
68 
     | 
    
         
             
              end
         
     | 
| 
       49 
69 
     | 
    
         
             
            end
         
     | 
| 
         @@ -12,8 +12,11 @@ module Webspicy 
     | 
|
| 
       12 
12 
     | 
    
         
             
                    end
         
     | 
| 
       13 
13 
     | 
    
         | 
| 
       14 
14 
     | 
    
         
             
                    def call
         
     | 
| 
       15 
     | 
    
         
            -
                       
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
      
 15 
     | 
    
         
            +
                      output = if invocation.is_structured_output?
         
     | 
| 
      
 16 
     | 
    
         
            +
                        invocation.loaded_body
         
     | 
| 
      
 17 
     | 
    
         
            +
                      else
         
     | 
| 
      
 18 
     | 
    
         
            +
                        invocation.raw_output
         
     | 
| 
      
 19 
     | 
    
         
            +
                      end
         
     | 
| 
       17 
20 
     | 
    
         
             
                      service.error_schema.dress(output)
         
     | 
| 
       18 
21 
     | 
    
         
             
                    rescue Finitio::TypeError => ex
         
     | 
| 
       19 
22 
     | 
    
         
             
                      _! "Invalid error: #{ex.message}"
         
     | 
| 
         @@ -12,8 +12,11 @@ module Webspicy 
     | 
|
| 
       12 
12 
     | 
    
         
             
                    end
         
     | 
| 
       13 
13 
     | 
    
         | 
| 
       14 
14 
     | 
    
         
             
                    def call
         
     | 
| 
       15 
     | 
    
         
            -
                       
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
      
 15 
     | 
    
         
            +
                      output = if invocation.is_structured_output?
         
     | 
| 
      
 16 
     | 
    
         
            +
                        invocation.loaded_body
         
     | 
| 
      
 17 
     | 
    
         
            +
                      else
         
     | 
| 
      
 18 
     | 
    
         
            +
                        invocation.raw_output
         
     | 
| 
      
 19 
     | 
    
         
            +
                      end
         
     | 
| 
       17 
20 
     | 
    
         
             
                      service.output_schema.dress(output)
         
     | 
| 
       18 
21 
     | 
    
         
             
                    rescue Finitio::TypeError => ex
         
     | 
| 
       19 
22 
     | 
    
         
             
                      _! "Invalid output: #{ex.message}"
         
     | 
    
        data/lib/webspicy/tester.rb
    CHANGED
    
    | 
         @@ -65,7 +65,11 @@ module Webspicy 
     | 
|
| 
       65 
65 
     | 
    
         
             
                    raise Error, "No such service `#{method} #{url}`"
         
     | 
| 
       66 
66 
     | 
    
         
             
                  end
         
     | 
| 
       67 
67 
     | 
    
         
             
                  mutated = tc.mutate(mutation)
         
     | 
| 
       68 
     | 
    
         
            -
                   
     | 
| 
      
 68 
     | 
    
         
            +
                  call_one(mutated)
         
     | 
| 
      
 69 
     | 
    
         
            +
                end
         
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
      
 71 
     | 
    
         
            +
                def call_one(test_case)
         
     | 
| 
      
 72 
     | 
    
         
            +
                  fork_tester(test_case: test_case) do |t|
         
     | 
| 
       69 
73 
     | 
    
         
             
                    instrumented = t.instrument_test_case
         
     | 
| 
       70 
74 
     | 
    
         
             
                    t.client.call(instrumented)
         
     | 
| 
       71 
75 
     | 
    
         
             
                  end
         
     | 
    
        data/lib/webspicy/version.rb
    CHANGED
    
    
| 
         @@ -11,10 +11,16 @@ FileUpload = 
     | 
|
| 
       11 
11 
     | 
    
         
             
                    param_name   :? String
         
     | 
| 
       12 
12 
     | 
    
         
             
                }
         
     | 
| 
       13 
13 
     | 
    
         | 
| 
      
 14 
     | 
    
         
            +
            OpenApi = {
         
     | 
| 
      
 15 
     | 
    
         
            +
                tag     :? String
         
     | 
| 
      
 16 
     | 
    
         
            +
                summary :? String
         
     | 
| 
      
 17 
     | 
    
         
            +
            }
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
       14 
19 
     | 
    
         
             
            Specification = .Webspicy::Web::Specification
         
     | 
| 
       15 
20 
     | 
    
         
             
              <info> {
         
     | 
| 
       16 
21 
     | 
    
         
             
                name: String
         
     | 
| 
       17 
22 
     | 
    
         
             
                url: String
         
     | 
| 
      
 23 
     | 
    
         
            +
                openapi :? OpenApi
         
     | 
| 
       18 
24 
     | 
    
         
             
                services: [Service]
         
     | 
| 
       19 
25 
     | 
    
         
             
              }
         
     | 
| 
       20 
26 
     | 
    
         
             
              <singleservice> {
         
     | 
| 
         @@ -22,6 +28,7 @@ Specification = .Webspicy::Web::Specification 
     | 
|
| 
       22 
28 
     | 
    
         
             
                url             :  String
         
     | 
| 
       23 
29 
     | 
    
         
             
                method          :  Method
         
     | 
| 
       24 
30 
     | 
    
         
             
                description     :  String
         
     | 
| 
      
 31 
     | 
    
         
            +
                openapi         :? OpenApi
         
     | 
| 
       25 
32 
     | 
    
         
             
                preconditions   :? [String]|String
         
     | 
| 
       26 
33 
     | 
    
         
             
                postconditions  :? [String]|String
         
     | 
| 
       27 
34 
     | 
    
         
             
                errconditions   :? [String]|String
         
     | 
| 
         @@ -39,6 +46,7 @@ Service = 
     | 
|
| 
       39 
46 
     | 
    
         
             
                    name            :? String
         
     | 
| 
       40 
47 
     | 
    
         
             
                    method          :  Method
         
     | 
| 
       41 
48 
     | 
    
         
             
                    description     :  String
         
     | 
| 
      
 49 
     | 
    
         
            +
                    openapi         :? OpenApi
         
     | 
| 
       42 
50 
     | 
    
         
             
                    preconditions   :? [String]|String
         
     | 
| 
       43 
51 
     | 
    
         
             
                    postconditions  :? [String]|String
         
     | 
| 
       44 
52 
     | 
    
         
             
                    errconditions   :? [String]|String
         
     | 
| 
         @@ -51,8 +59,30 @@ Service = 
     | 
|
| 
       51 
59 
     | 
    
         
             
                    counterexamples :? [TestCase]
         
     | 
| 
       52 
60 
     | 
    
         
             
                }
         
     | 
| 
       53 
61 
     | 
    
         | 
| 
       54 
     | 
    
         
            -
            TestCase =
         
     | 
| 
       55 
     | 
    
         
            -
                 
     | 
| 
      
 62 
     | 
    
         
            +
            TestCase = .Webspicy::Web::Specification::TestCase
         
     | 
| 
      
 63 
     | 
    
         
            +
                <v2> {
         
     | 
| 
      
 64 
     | 
    
         
            +
                    for              :? String
         
     | 
| 
      
 65 
     | 
    
         
            +
                    when             :? String
         
     | 
| 
      
 66 
     | 
    
         
            +
                    it               :? String
         
     | 
| 
      
 67 
     | 
    
         
            +
                    description      :? String
         
     | 
| 
      
 68 
     | 
    
         
            +
                    validate_input   :? Boolean
         
     | 
| 
      
 69 
     | 
    
         
            +
                    input            :? Params
         
     | 
| 
      
 70 
     | 
    
         
            +
                    headers          :? .Hash
         
     | 
| 
      
 71 
     | 
    
         
            +
                    body             :? String
         
     | 
| 
      
 72 
     | 
    
         
            +
                    file_upload      :? FileUpload
         
     | 
| 
      
 73 
     | 
    
         
            +
                    seeds            :? String
         
     | 
| 
      
 74 
     | 
    
         
            +
                    requester        :? String
         
     | 
| 
      
 75 
     | 
    
         
            +
                    metadata         :? { ...: .Object }
         
     | 
| 
      
 76 
     | 
    
         
            +
                    expected         :? {
         
     | 
| 
      
 77 
     | 
    
         
            +
                        status       :? StatusRange
         
     | 
| 
      
 78 
     | 
    
         
            +
                        content_type :? String|Nil
         
     | 
| 
      
 79 
     | 
    
         
            +
                        error        :? String
         
     | 
| 
      
 80 
     | 
    
         
            +
                        headers      :? .Hash
         
     | 
| 
      
 81 
     | 
    
         
            +
                    }
         
     | 
| 
      
 82 
     | 
    
         
            +
                    assert           :? [String]
         
     | 
| 
      
 83 
     | 
    
         
            +
                    tags             :? [Tag]
         
     | 
| 
      
 84 
     | 
    
         
            +
                }
         
     | 
| 
      
 85 
     | 
    
         
            +
                <info> {
         
     | 
| 
       56 
86 
     | 
    
         
             
                    description      :? String
         
     | 
| 
       57 
87 
     | 
    
         
             
                    dress_params     :? Boolean
         
     | 
| 
       58 
88 
     | 
    
         
             
                    params           :? Params
         
     | 
| 
         @@ -0,0 +1,40 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Webspicy
         
     | 
| 
      
 2 
     | 
    
         
            +
              module Web
         
     | 
| 
      
 3 
     | 
    
         
            +
                module Openapi
         
     | 
| 
      
 4 
     | 
    
         
            +
                  class DataStruct
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
                    MERGER = Support::DeepMerge.new({
         
     | 
| 
      
 7 
     | 
    
         
            +
                      uniq_on_arrays: true
         
     | 
| 
      
 8 
     | 
    
         
            +
                    })
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                    def initialize
         
     | 
| 
      
 11 
     | 
    
         
            +
                      @info = {}
         
     | 
| 
      
 12 
     | 
    
         
            +
                      @tags = []
         
     | 
| 
      
 13 
     | 
    
         
            +
                      @paths = {}
         
     | 
| 
      
 14 
     | 
    
         
            +
                    end
         
     | 
| 
      
 15 
     | 
    
         
            +
                    attr_reader :info, :tags, :paths
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                    def ensure_tags(tags)
         
     | 
| 
      
 18 
     | 
    
         
            +
                      @tags = (@tags + tags).uniq.sort_by{|t| t[:name] }
         
     | 
| 
      
 19 
     | 
    
         
            +
                    end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                    def ensure_path(path)
         
     | 
| 
      
 22 
     | 
    
         
            +
                      @paths = MERGER.deep_merge(
         
     | 
| 
      
 23 
     | 
    
         
            +
                        @paths,
         
     | 
| 
      
 24 
     | 
    
         
            +
                        path,
         
     | 
| 
      
 25 
     | 
    
         
            +
                      )
         
     | 
| 
      
 26 
     | 
    
         
            +
                    end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                    def to_openapi_data
         
     | 
| 
      
 29 
     | 
    
         
            +
                      {
         
     | 
| 
      
 30 
     | 
    
         
            +
                        "openapi" => '3.0.2',
         
     | 
| 
      
 31 
     | 
    
         
            +
                        "info" => info,
         
     | 
| 
      
 32 
     | 
    
         
            +
                        "tags" => tags,
         
     | 
| 
      
 33 
     | 
    
         
            +
                        "paths" => paths,
         
     | 
| 
      
 34 
     | 
    
         
            +
                      }
         
     | 
| 
      
 35 
     | 
    
         
            +
                    end
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                  end # class DataStruct
         
     | 
| 
      
 38 
     | 
    
         
            +
                end # module Openapi
         
     | 
| 
      
 39 
     | 
    
         
            +
              end # module Web
         
     | 
| 
      
 40 
     | 
    
         
            +
            end # module Webspicy
         
     | 
| 
         @@ -0,0 +1,36 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Webspicy
         
     | 
| 
      
 2 
     | 
    
         
            +
              module Web
         
     | 
| 
      
 3 
     | 
    
         
            +
                module Openapi
         
     | 
| 
      
 4 
     | 
    
         
            +
                  class Reporter < Webspicy::Tester::Reporter
         
     | 
| 
      
 5 
     | 
    
         
            +
                    include Utils
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
                    def initialize(base, output_file)
         
     | 
| 
      
 8 
     | 
    
         
            +
                      @base = base
         
     | 
| 
      
 9 
     | 
    
         
            +
                      @output_file = output_file
         
     | 
| 
      
 10 
     | 
    
         
            +
                    end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                    def before_all
         
     | 
| 
      
 13 
     | 
    
         
            +
                      @datastruct = DataStruct.new
         
     | 
| 
      
 14 
     | 
    
         
            +
                    end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                    def after_each
         
     | 
| 
      
 17 
     | 
    
         
            +
                      @datastruct.ensure_tags(tags_for(specification))
         
     | 
| 
      
 18 
     | 
    
         
            +
                      @datastruct.ensure_path(base_path_for(specification))
         
     | 
| 
      
 19 
     | 
    
         
            +
                      @datastruct.ensure_path(base_verb_for(service))
         
     | 
| 
      
 20 
     | 
    
         
            +
                      @datastruct.ensure_path(base_request_body_for(service))
         
     | 
| 
      
 21 
     | 
    
         
            +
                      @datastruct.ensure_path(base_request_example_for(test_case))
         
     | 
| 
      
 22 
     | 
    
         
            +
                      @datastruct.ensure_path(base_request_response_for(invocation))
         
     | 
| 
      
 23 
     | 
    
         
            +
                    end
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                    def report
         
     | 
| 
      
 26 
     | 
    
         
            +
                      json = Support::DeepMerge.deep_merge(
         
     | 
| 
      
 27 
     | 
    
         
            +
                        @base,
         
     | 
| 
      
 28 
     | 
    
         
            +
                        @datastruct.to_openapi_data,
         
     | 
| 
      
 29 
     | 
    
         
            +
                      )
         
     | 
| 
      
 30 
     | 
    
         
            +
                      @output_file.write(JSON.pretty_generate(json))
         
     | 
| 
      
 31 
     | 
    
         
            +
                    end
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                  end # class Reporter
         
     | 
| 
      
 34 
     | 
    
         
            +
                end # class OpenApi
         
     | 
| 
      
 35 
     | 
    
         
            +
              end # class Web
         
     | 
| 
      
 36 
     | 
    
         
            +
            end # module Webspicy
         
     | 
| 
         @@ -0,0 +1,210 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Webspicy
         
     | 
| 
      
 2 
     | 
    
         
            +
              module Web
         
     | 
| 
      
 3 
     | 
    
         
            +
                module Openapi
         
     | 
| 
      
 4 
     | 
    
         
            +
                  module Utils
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
                    def into_specification_path(specification, x)
         
     | 
| 
      
 7 
     | 
    
         
            +
                      {
         
     | 
| 
      
 8 
     | 
    
         
            +
                        standardize(specification.url) => x.compact,
         
     | 
| 
      
 9 
     | 
    
         
            +
                      }
         
     | 
| 
      
 10 
     | 
    
         
            +
                    end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                    def into_service_verb(service, x)
         
     | 
| 
      
 13 
     | 
    
         
            +
                      verb = downcase_verb(service)
         
     | 
| 
      
 14 
     | 
    
         
            +
                      into_specification_path(service.specification, {
         
     | 
| 
      
 15 
     | 
    
         
            +
                        verb => x.compact,
         
     | 
| 
      
 16 
     | 
    
         
            +
                      })
         
     | 
| 
      
 17 
     | 
    
         
            +
                    end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                    def into_service_request_body(service, x)
         
     | 
| 
      
 20 
     | 
    
         
            +
                      into_service_verb(service, {
         
     | 
| 
      
 21 
     | 
    
         
            +
                        requestBody: x.compact,
         
     | 
| 
      
 22 
     | 
    
         
            +
                      })
         
     | 
| 
      
 23 
     | 
    
         
            +
                    end
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                    def into_service_responses(service, x)
         
     | 
| 
      
 26 
     | 
    
         
            +
                      into_service_verb(service, {
         
     | 
| 
      
 27 
     | 
    
         
            +
                        responses: x.compact,
         
     | 
| 
      
 28 
     | 
    
         
            +
                      })
         
     | 
| 
      
 29 
     | 
    
         
            +
                    end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                    ###
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                    def base_path_for(specification)
         
     | 
| 
      
 34 
     | 
    
         
            +
                      into_specification_path(specification, {
         
     | 
| 
      
 35 
     | 
    
         
            +
                        summary: specification.name.to_s || 'API Specification'
         
     | 
| 
      
 36 
     | 
    
         
            +
                      })
         
     | 
| 
      
 37 
     | 
    
         
            +
                    end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                    def base_verb_for(service)
         
     | 
| 
      
 40 
     | 
    
         
            +
                      verb_defn = {
         
     | 
| 
      
 41 
     | 
    
         
            +
                        summary: service.name,
         
     | 
| 
      
 42 
     | 
    
         
            +
                        description: service.description,
         
     | 
| 
      
 43 
     | 
    
         
            +
                        tags: tags_for(service.specification).map{|s| s[:name] },
         
     | 
| 
      
 44 
     | 
    
         
            +
                        parameters: parameters_for(service),
         
     | 
| 
      
 45 
     | 
    
         
            +
                      }
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
                      verb_defn = service.conditions.inject(verb_defn) do |memo, p|
         
     | 
| 
      
 48 
     | 
    
         
            +
                        if p.respond_to?(:contribute_to_openapi_verb)
         
     | 
| 
      
 49 
     | 
    
         
            +
                          p.contribute_to_openapi_verb(memo)
         
     | 
| 
      
 50 
     | 
    
         
            +
                        else
         
     | 
| 
      
 51 
     | 
    
         
            +
                          memo
         
     | 
| 
      
 52 
     | 
    
         
            +
                        end
         
     | 
| 
      
 53 
     | 
    
         
            +
                      end
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
                      into_service_verb(service, verb_defn)
         
     | 
| 
      
 56 
     | 
    
         
            +
                    end
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
                    def extract_request_body_info_for(service)
         
     | 
| 
      
 59 
     | 
    
         
            +
                      verb = downcase_verb(service)
         
     | 
| 
      
 60 
     | 
    
         
            +
                      return nil if ['get', 'options', 'head'].include?(verb)
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
                      schema = actual_body_schema(service)
         
     | 
| 
      
 63 
     | 
    
         
            +
                      return nil if empty_schema?(schema)
         
     | 
| 
      
 64 
     | 
    
         
            +
                      puts schema.inspect
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
                      content_type = content_type_for(service)
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
                      [schema, content_type]
         
     | 
| 
      
 69 
     | 
    
         
            +
                    end
         
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
      
 71 
     | 
    
         
            +
                    def base_request_body_for(service)
         
     | 
| 
      
 72 
     | 
    
         
            +
                      schema, content_type = extract_request_body_info_for(service)
         
     | 
| 
      
 73 
     | 
    
         
            +
                      return {} unless schema
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
                      into_service_request_body(service, {
         
     | 
| 
      
 76 
     | 
    
         
            +
                        required: true,
         
     | 
| 
      
 77 
     | 
    
         
            +
                        content: {
         
     | 
| 
      
 78 
     | 
    
         
            +
                          content_type => {
         
     | 
| 
      
 79 
     | 
    
         
            +
                            schema: schema.to_json_schema,
         
     | 
| 
      
 80 
     | 
    
         
            +
                          }.compact,
         
     | 
| 
      
 81 
     | 
    
         
            +
                        },
         
     | 
| 
      
 82 
     | 
    
         
            +
                      })
         
     | 
| 
      
 83 
     | 
    
         
            +
                    end
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
      
 85 
     | 
    
         
            +
                    def base_request_example_for(test_case)
         
     | 
| 
      
 86 
     | 
    
         
            +
                      schema, content_type = extract_request_body_info_for(service)
         
     | 
| 
      
 87 
     | 
    
         
            +
                      return {} unless schema
         
     | 
| 
      
 88 
     | 
    
         
            +
             
     | 
| 
      
 89 
     | 
    
         
            +
                      value = test_case.params
         
     | 
| 
      
 90 
     | 
    
         
            +
                      in_url = service.specification.url_placeholders
         
     | 
| 
      
 91 
     | 
    
         
            +
                      value = value.reject{|k,v| in_url.include?(k) } if value.is_a?(Hash)
         
     | 
| 
      
 92 
     | 
    
         
            +
             
     | 
| 
      
 93 
     | 
    
         
            +
                      example = {
         
     | 
| 
      
 94 
     | 
    
         
            +
                        description: test_case.description,
         
     | 
| 
      
 95 
     | 
    
         
            +
                        value: value,
         
     | 
| 
      
 96 
     | 
    
         
            +
                      }
         
     | 
| 
      
 97 
     | 
    
         
            +
             
     | 
| 
      
 98 
     | 
    
         
            +
                      into_service_request_body(service, {
         
     | 
| 
      
 99 
     | 
    
         
            +
                        required: true,
         
     | 
| 
      
 100 
     | 
    
         
            +
                        content: {
         
     | 
| 
      
 101 
     | 
    
         
            +
                          content_type => {
         
     | 
| 
      
 102 
     | 
    
         
            +
                            examples: {
         
     | 
| 
      
 103 
     | 
    
         
            +
                              test_case.description => example
         
     | 
| 
      
 104 
     | 
    
         
            +
                            }
         
     | 
| 
      
 105 
     | 
    
         
            +
                          }.compact,
         
     | 
| 
      
 106 
     | 
    
         
            +
                        },
         
     | 
| 
      
 107 
     | 
    
         
            +
                      })
         
     | 
| 
      
 108 
     | 
    
         
            +
                    end
         
     | 
| 
      
 109 
     | 
    
         
            +
             
     | 
| 
      
 110 
     | 
    
         
            +
                    def base_request_response_for(invocation)
         
     | 
| 
      
 111 
     | 
    
         
            +
                      test_case = invocation.test_case
         
     | 
| 
      
 112 
     | 
    
         
            +
                      service = invocation.service
         
     | 
| 
      
 113 
     | 
    
         
            +
                      content_type = content_type_for(service)
         
     | 
| 
      
 114 
     | 
    
         
            +
                      verb = downcase_verb(service)
         
     | 
| 
      
 115 
     | 
    
         
            +
             
     | 
| 
      
 116 
     | 
    
         
            +
                      content = nil
         
     | 
| 
      
 117 
     | 
    
         
            +
                      unless invocation.is_empty_response?
         
     | 
| 
      
 118 
     | 
    
         
            +
                        schema = actual_output_schema(test_case, false)
         
     | 
| 
      
 119 
     | 
    
         
            +
                        example = invocation.loaded_output
         
     | 
| 
      
 120 
     | 
    
         
            +
                        content = {
         
     | 
| 
      
 121 
     | 
    
         
            +
                          content_type => {
         
     | 
| 
      
 122 
     | 
    
         
            +
                            schema: schema&.to_json_schema,
         
     | 
| 
      
 123 
     | 
    
         
            +
                            example: example,
         
     | 
| 
      
 124 
     | 
    
         
            +
                          }.compact
         
     | 
| 
      
 125 
     | 
    
         
            +
                        }
         
     | 
| 
      
 126 
     | 
    
         
            +
                      end
         
     | 
| 
      
 127 
     | 
    
         
            +
             
     | 
| 
      
 128 
     | 
    
         
            +
                      into_service_responses(service, {
         
     | 
| 
      
 129 
     | 
    
         
            +
                        invocation.response_code.to_s => {
         
     | 
| 
      
 130 
     | 
    
         
            +
                          description: '',
         
     | 
| 
      
 131 
     | 
    
         
            +
                          content: content,
         
     | 
| 
      
 132 
     | 
    
         
            +
                        }.compact
         
     | 
| 
      
 133 
     | 
    
         
            +
                      })
         
     | 
| 
      
 134 
     | 
    
         
            +
                    end
         
     | 
| 
      
 135 
     | 
    
         
            +
             
     | 
| 
      
 136 
     | 
    
         
            +
                    def tags_for(specification)
         
     | 
| 
      
 137 
     | 
    
         
            +
                      tag = specification&.openapi&.[](:tag) || specification.name
         
     | 
| 
      
 138 
     | 
    
         
            +
             
     | 
| 
      
 139 
     | 
    
         
            +
                      return [] unless tag.is_a?(String)
         
     | 
| 
      
 140 
     | 
    
         
            +
                      return [] if tag.empty?
         
     | 
| 
      
 141 
     | 
    
         
            +
             
     | 
| 
      
 142 
     | 
    
         
            +
                      [{
         
     | 
| 
      
 143 
     | 
    
         
            +
                        name: tag.gsub(/\n/, ' ').strip
         
     | 
| 
      
 144 
     | 
    
         
            +
                      }]
         
     | 
| 
      
 145 
     | 
    
         
            +
                    end
         
     | 
| 
      
 146 
     | 
    
         
            +
             
     | 
| 
      
 147 
     | 
    
         
            +
                    def parameters_for(service)
         
     | 
| 
      
 148 
     | 
    
         
            +
                      schema = actual_input_schema(service)
         
     | 
| 
      
 149 
     | 
    
         
            +
                      params = service.specification.url_placeholders.map{|p|
         
     | 
| 
      
 150 
     | 
    
         
            +
                        {
         
     | 
| 
      
 151 
     | 
    
         
            +
                          in: 'path',
         
     | 
| 
      
 152 
     | 
    
         
            +
                          name: p,
         
     | 
| 
      
 153 
     | 
    
         
            +
                          schema: { type: 'string' },
         
     | 
| 
      
 154 
     | 
    
         
            +
                          required: true
         
     | 
| 
      
 155 
     | 
    
         
            +
                        }
         
     | 
| 
      
 156 
     | 
    
         
            +
                      }
         
     | 
| 
      
 157 
     | 
    
         
            +
                      params.empty? ? nil : params
         
     | 
| 
      
 158 
     | 
    
         
            +
                    end
         
     | 
| 
      
 159 
     | 
    
         
            +
             
     | 
| 
      
 160 
     | 
    
         
            +
                    def actual_output_schema(test_case, counterexample)
         
     | 
| 
      
 161 
     | 
    
         
            +
                      if counterexample
         
     | 
| 
      
 162 
     | 
    
         
            +
                        test_case.service.error_schema['Main']
         
     | 
| 
      
 163 
     | 
    
         
            +
                      else
         
     | 
| 
      
 164 
     | 
    
         
            +
                        test_case.service.output_schema['Main']
         
     | 
| 
      
 165 
     | 
    
         
            +
                      end
         
     | 
| 
      
 166 
     | 
    
         
            +
                    end
         
     | 
| 
      
 167 
     | 
    
         
            +
             
     | 
| 
      
 168 
     | 
    
         
            +
                    def actual_input_schema(service)
         
     | 
| 
      
 169 
     | 
    
         
            +
                      service.input_schema['Main']
         
     | 
| 
      
 170 
     | 
    
         
            +
                    end
         
     | 
| 
      
 171 
     | 
    
         
            +
             
     | 
| 
      
 172 
     | 
    
         
            +
                    def actual_body_schema(service)
         
     | 
| 
      
 173 
     | 
    
         
            +
                      schema = actual_input_schema(service)
         
     | 
| 
      
 174 
     | 
    
         
            +
             
     | 
| 
      
 175 
     | 
    
         
            +
                      a_schema = schema
         
     | 
| 
      
 176 
     | 
    
         
            +
                      a_schema = schema.target if schema.is_a?(Finitio::AliasType)
         
     | 
| 
      
 177 
     | 
    
         
            +
                      return schema unless a_schema.is_a?(Finitio::HashBasedType)
         
     | 
| 
      
 178 
     | 
    
         
            +
             
     | 
| 
      
 179 
     | 
    
         
            +
                      in_url = service.specification.url_placeholders.map(&:to_sym)
         
     | 
| 
      
 180 
     | 
    
         
            +
                      return schema if in_url.empty?
         
     | 
| 
      
 181 
     | 
    
         
            +
             
     | 
| 
      
 182 
     | 
    
         
            +
                      a_schema.allbut(in_url)
         
     | 
| 
      
 183 
     | 
    
         
            +
                    end
         
     | 
| 
      
 184 
     | 
    
         
            +
             
     | 
| 
      
 185 
     | 
    
         
            +
                    def standardize(url)
         
     | 
| 
      
 186 
     | 
    
         
            +
                      url = url.gsub(/\/$/, '') if url =~ /\/$/
         
     | 
| 
      
 187 
     | 
    
         
            +
                      url
         
     | 
| 
      
 188 
     | 
    
         
            +
                    end
         
     | 
| 
      
 189 
     | 
    
         
            +
             
     | 
| 
      
 190 
     | 
    
         
            +
                    def downcase_verb(service)
         
     | 
| 
      
 191 
     | 
    
         
            +
                      service.method.downcase.gsub(/_form$/, '')
         
     | 
| 
      
 192 
     | 
    
         
            +
                    end
         
     | 
| 
      
 193 
     | 
    
         
            +
             
     | 
| 
      
 194 
     | 
    
         
            +
                    def content_type_for(service)
         
     | 
| 
      
 195 
     | 
    
         
            +
                      if service.method.downcase == 'post_form'
         
     | 
| 
      
 196 
     | 
    
         
            +
                        'application/x-www-form-urlencoded'
         
     | 
| 
      
 197 
     | 
    
         
            +
                      else
         
     | 
| 
      
 198 
     | 
    
         
            +
                        'application/json'
         
     | 
| 
      
 199 
     | 
    
         
            +
                      end
         
     | 
| 
      
 200 
     | 
    
         
            +
                    end
         
     | 
| 
      
 201 
     | 
    
         
            +
             
     | 
| 
      
 202 
     | 
    
         
            +
                    def empty_schema?(schema)
         
     | 
| 
      
 203 
     | 
    
         
            +
                      schema = schema.target if schema.is_a?(Finitio::AliasType)
         
     | 
| 
      
 204 
     | 
    
         
            +
                      schema.is_a?(Finitio::HashBasedType) && schema.heading.empty?
         
     | 
| 
      
 205 
     | 
    
         
            +
                    end
         
     | 
| 
      
 206 
     | 
    
         
            +
             
     | 
| 
      
 207 
     | 
    
         
            +
                  end # module Utils
         
     | 
| 
      
 208 
     | 
    
         
            +
                end # module Openapi
         
     | 
| 
      
 209 
     | 
    
         
            +
              end # module Web
         
     | 
| 
      
 210 
     | 
    
         
            +
            end # module Webspicy
         
     | 
    
        data/lib/webspicy/web/openapi.rb
    CHANGED
    
    
| 
         @@ -3,6 +3,24 @@ module Webspicy 
     | 
|
| 
       3 
3 
     | 
    
         
             
                class Specification
         
     | 
| 
       4 
4 
     | 
    
         
             
                  class TestCase < Webspicy::Specification::TestCase
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
      
 6 
     | 
    
         
            +
                    def self.v2(info)
         
     | 
| 
      
 7 
     | 
    
         
            +
                      info = info.dup
         
     | 
| 
      
 8 
     | 
    
         
            +
                      if !info.has_key?(:description) && (info.has_key?(:when) || info.has_key?(:it))
         
     | 
| 
      
 9 
     | 
    
         
            +
                        info[:description] = "when #{info[:when]}" if info.has_key?(:when)
         
     | 
| 
      
 10 
     | 
    
         
            +
                        info[:description] << ", it #{info[:it]}" if info.has_key?(:it)
         
     | 
| 
      
 11 
     | 
    
         
            +
                        info.delete_if{|k,v| k == :when || k == :it }
         
     | 
| 
      
 12 
     | 
    
         
            +
                      end
         
     | 
| 
      
 13 
     | 
    
         
            +
                      if !info.has_key?(:dress_params) && info.has_key?(:validate_input)
         
     | 
| 
      
 14 
     | 
    
         
            +
                        info[:dress_params] = info[:validate_input]
         
     | 
| 
      
 15 
     | 
    
         
            +
                        info.delete(:validate_input)
         
     | 
| 
      
 16 
     | 
    
         
            +
                      end
         
     | 
| 
      
 17 
     | 
    
         
            +
                      if !info.has_key?(:params) && info.has_key?(:input)
         
     | 
| 
      
 18 
     | 
    
         
            +
                        info[:params] = info[:input]
         
     | 
| 
      
 19 
     | 
    
         
            +
                        info.delete(:input)
         
     | 
| 
      
 20 
     | 
    
         
            +
                      end
         
     | 
| 
      
 21 
     | 
    
         
            +
                      new(info)
         
     | 
| 
      
 22 
     | 
    
         
            +
                    end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
       6 
24 
     | 
    
         
             
                    def headers
         
     | 
| 
       7 
25 
     | 
    
         
             
                      @raw[:headers] ||= {}
         
     | 
| 
       8 
26 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -52,6 +70,20 @@ module Webspicy 
     | 
|
| 
       52 
70 
     | 
    
         
             
                      !expected_headers.empty?
         
     | 
| 
       53 
71 
     | 
    
         
             
                    end
         
     | 
| 
       54 
72 
     | 
    
         | 
| 
      
 73 
     | 
    
         
            +
                    def to_v2
         
     | 
| 
      
 74 
     | 
    
         
            +
                      info = to_info
         
     | 
| 
      
 75 
     | 
    
         
            +
                      info = info.merge({
         
     | 
| 
      
 76 
     | 
    
         
            +
                        validate_input: !!info[:dress_params],
         
     | 
| 
      
 77 
     | 
    
         
            +
                        input: info[:params] || {},
         
     | 
| 
      
 78 
     | 
    
         
            +
                      }).delete_if{|k,v| k == :dress_params || k == :params }
         
     | 
| 
      
 79 
     | 
    
         
            +
                      if info[:description] =~ /^when (.*?), it (.*)$/
         
     | 
| 
      
 80 
     | 
    
         
            +
                        info[:when] = $1
         
     | 
| 
      
 81 
     | 
    
         
            +
                        info[:it] = $2
         
     | 
| 
      
 82 
     | 
    
         
            +
                        info.delete(:description)
         
     | 
| 
      
 83 
     | 
    
         
            +
                      end
         
     | 
| 
      
 84 
     | 
    
         
            +
                      info
         
     | 
| 
      
 85 
     | 
    
         
            +
                    end
         
     | 
| 
      
 86 
     | 
    
         
            +
             
     | 
| 
       55 
87 
     | 
    
         
             
                  end # class TestCase
         
     | 
| 
       56 
88 
     | 
    
         
             
                end # class Specification
         
     | 
| 
       57 
89 
     | 
    
         
             
              end # module Web
         
     | 
| 
         @@ -0,0 +1,50 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'spec_helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
            module Webspicy
         
     | 
| 
      
 3 
     | 
    
         
            +
              module Web
         
     | 
| 
      
 4 
     | 
    
         
            +
                class Specification
         
     | 
| 
      
 5 
     | 
    
         
            +
                  describe TestCase, "v2 information contract" do
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
                    it 'dresses fine' do
         
     | 
| 
      
 8 
     | 
    
         
            +
                      tc = Webspicy::Web.test_case({
         
     | 
| 
      
 9 
     | 
    
         
            +
                        when: "a condition",
         
     | 
| 
      
 10 
     | 
    
         
            +
                        it: "does something",
         
     | 
| 
      
 11 
     | 
    
         
            +
                        input: { foo: "bar" },
         
     | 
| 
      
 12 
     | 
    
         
            +
                        validate_input: false,
         
     | 
| 
      
 13 
     | 
    
         
            +
                      })
         
     | 
| 
      
 14 
     | 
    
         
            +
                      expect(tc.description).to eql("when a condition, it does something")
         
     | 
| 
      
 15 
     | 
    
         
            +
                      expect(tc.params).to eql({ foo: "bar" })
         
     | 
| 
      
 16 
     | 
    
         
            +
                      expect(tc.dress_params).to eql(false)
         
     | 
| 
      
 17 
     | 
    
         
            +
                    end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                    it 'undresses fine' do
         
     | 
| 
      
 20 
     | 
    
         
            +
                      tc = Webspicy::Web.test_case({
         
     | 
| 
      
 21 
     | 
    
         
            +
                        when: "a condition",
         
     | 
| 
      
 22 
     | 
    
         
            +
                        it: "does something",
         
     | 
| 
      
 23 
     | 
    
         
            +
                        input: { foo: "bar" },
         
     | 
| 
      
 24 
     | 
    
         
            +
                        validate_input: false,
         
     | 
| 
      
 25 
     | 
    
         
            +
                      })
         
     | 
| 
      
 26 
     | 
    
         
            +
                      expect(tc.to_v2).to eql({
         
     | 
| 
      
 27 
     | 
    
         
            +
                        when: "a condition",
         
     | 
| 
      
 28 
     | 
    
         
            +
                        it: "does something",
         
     | 
| 
      
 29 
     | 
    
         
            +
                        input: { foo: "bar" },
         
     | 
| 
      
 30 
     | 
    
         
            +
                        validate_input: false,
         
     | 
| 
      
 31 
     | 
    
         
            +
                      })
         
     | 
| 
      
 32 
     | 
    
         
            +
                    end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                    it 'keeps to_info clean' do
         
     | 
| 
      
 35 
     | 
    
         
            +
                      tc = Webspicy::Web.test_case({
         
     | 
| 
      
 36 
     | 
    
         
            +
                        when: "a condition",
         
     | 
| 
      
 37 
     | 
    
         
            +
                        it: "does something",
         
     | 
| 
      
 38 
     | 
    
         
            +
                        input: { foo: "bar" },
         
     | 
| 
      
 39 
     | 
    
         
            +
                        validate_input: false,
         
     | 
| 
      
 40 
     | 
    
         
            +
                      })
         
     | 
| 
      
 41 
     | 
    
         
            +
                      expect(tc.to_info).to eql({
         
     | 
| 
      
 42 
     | 
    
         
            +
                        description: "when a condition, it does something",
         
     | 
| 
      
 43 
     | 
    
         
            +
                        params: { foo: "bar" },
         
     | 
| 
      
 44 
     | 
    
         
            +
                        dress_params: false,
         
     | 
| 
      
 45 
     | 
    
         
            +
                      })
         
     | 
| 
      
 46 
     | 
    
         
            +
                    end
         
     | 
| 
      
 47 
     | 
    
         
            +
                  end
         
     | 
| 
      
 48 
     | 
    
         
            +
                end
         
     | 
| 
      
 49 
     | 
    
         
            +
              end
         
     | 
| 
      
 50 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: webspicy
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.27.1
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Bernard Lambeau
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire:
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date:  
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2025-03-22 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: rake
         
     | 
| 
         @@ -104,7 +104,7 @@ dependencies: 
     | 
|
| 
       104 
104 
     | 
    
         
             
                requirements:
         
     | 
| 
       105 
105 
     | 
    
         
             
                - - ">="
         
     | 
| 
       106 
106 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       107 
     | 
    
         
            -
                    version: 0.12. 
     | 
| 
      
 107 
     | 
    
         
            +
                    version: 0.12.2
         
     | 
| 
       108 
108 
     | 
    
         
             
                - - "<"
         
     | 
| 
       109 
109 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       110 
110 
     | 
    
         
             
                    version: 0.13.0
         
     | 
| 
         @@ -114,7 +114,7 @@ dependencies: 
     | 
|
| 
       114 
114 
     | 
    
         
             
                requirements:
         
     | 
| 
       115 
115 
     | 
    
         
             
                - - ">="
         
     | 
| 
       116 
116 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       117 
     | 
    
         
            -
                    version: 0.12. 
     | 
| 
      
 117 
     | 
    
         
            +
                    version: 0.12.2
         
     | 
| 
       118 
118 
     | 
    
         
             
                - - "<"
         
     | 
| 
       119 
119 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       120 
120 
     | 
    
         
             
                    version: 0.13.0
         
     | 
| 
         @@ -399,8 +399,11 @@ files: 
     | 
|
| 
       399 
399 
     | 
    
         
             
            - lib/webspicy/web/mocker.rb
         
     | 
| 
       400 
400 
     | 
    
         
             
            - lib/webspicy/web/mocker/config.ru
         
     | 
| 
       401 
401 
     | 
    
         
             
            - lib/webspicy/web/openapi.rb
         
     | 
| 
      
 402 
     | 
    
         
            +
            - lib/webspicy/web/openapi/data_struct.rb
         
     | 
| 
       402 
403 
     | 
    
         
             
            - lib/webspicy/web/openapi/ext.rb
         
     | 
| 
       403 
404 
     | 
    
         
             
            - lib/webspicy/web/openapi/generator.rb
         
     | 
| 
      
 405 
     | 
    
         
            +
            - lib/webspicy/web/openapi/reporter.rb
         
     | 
| 
      
 406 
     | 
    
         
            +
            - lib/webspicy/web/openapi/utils.rb
         
     | 
| 
       404 
407 
     | 
    
         
             
            - lib/webspicy/web/specification.rb
         
     | 
| 
       405 
408 
     | 
    
         
             
            - lib/webspicy/web/specification/file_upload.rb
         
     | 
| 
       406 
409 
     | 
    
         
             
            - lib/webspicy/web/specification/post.rb
         
     | 
| 
         @@ -441,6 +444,7 @@ files: 
     | 
|
| 
       441 
444 
     | 
    
         
             
            - spec/unit/web/mocker/test_mocker.rb
         
     | 
| 
       442 
445 
     | 
    
         
             
            - spec/unit/web/openapi/test_generator.rb
         
     | 
| 
       443 
446 
     | 
    
         
             
            - spec/unit/web/specification/pre/test_global_request_headers.rb
         
     | 
| 
      
 447 
     | 
    
         
            +
            - spec/unit/web/specification/test_case/test_v2_ic.rb
         
     | 
| 
       444 
448 
     | 
    
         
             
            - spec/unit/web/specification/test_instantiate_url.rb
         
     | 
| 
       445 
449 
     | 
    
         
             
            - spec/unit/web/specification/test_url_placeholders.rb
         
     | 
| 
       446 
450 
     | 
    
         
             
            - tasks/gem.rake
         
     | 
| 
         @@ -464,7 +468,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       464 
468 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       465 
469 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       466 
470 
     | 
    
         
             
            requirements: []
         
     | 
| 
       467 
     | 
    
         
            -
            rubygems_version: 3.3. 
     | 
| 
      
 471 
     | 
    
         
            +
            rubygems_version: 3.3.27
         
     | 
| 
       468 
472 
     | 
    
         
             
            signing_key:
         
     | 
| 
       469 
473 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       470 
474 
     | 
    
         
             
            summary: Webspicy helps testing web services as software operation black boxes!
         
     |