rspec-httpd 0.0.12 → 0.0.14
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/VERSION +1 -1
- data/lib/rspec/httpd.rb +7 -9
- data/lib/rspec/httpd/client.rb +7 -0
- metadata +1 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: c71c6a8e039811020f1c135751a4068adafb8f9e6992833fe2449661060146ce
         | 
| 4 | 
            +
              data.tar.gz: 2875628708bf20325ce4323dde9d253f9955493f2e8af2c65828a2054481d421
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: b262a9cbcb738a6956c32bafee8b2ab234cee9d8cf1fe218c2006b6d8e19b8b22311f2201253d49b875a9ade93b6da1a529e456db522039c4441e93e583bf9d9
         | 
| 7 | 
            +
              data.tar.gz: b834501793639f9c49ff836d7eb1d25f0b170743bfe3c98186f7219fcd0f30705e97e2ffd331aad25fac55dccee6abdd66384a1598479e5d504fa90f85e187b5
         | 
    
        data/VERSION
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            0.0. | 
| 1 | 
            +
            0.0.14
         | 
    
        data/lib/rspec/httpd.rb
    CHANGED
    
    | @@ -71,22 +71,20 @@ module RSpec::Httpd | |
| 71 71 | 
             
                #
         | 
| 72 72 | 
             
                #    expect_response 201
         | 
| 73 73 | 
             
                #
         | 
| 74 | 
            -
                 | 
| 75 | 
            -
             | 
| 76 | 
            -
             | 
| 77 | 
            -
                end
         | 
| 74 | 
            +
                expected_status = expected.is_a?(Integer) && status.nil? ? expected : status || 200
         | 
| 75 | 
            +
             | 
| 76 | 
            +
                request, response = client.request, client.response
         | 
| 78 77 |  | 
| 79 | 
            -
                 | 
| 80 | 
            -
             | 
| 78 | 
            +
                expect(client.status).to eq(expected_status), 
         | 
| 79 | 
            +
                  "status should be #{expected_status}, but is #{client.status}, on '#{request.method} #{request.path}'"
         | 
| 81 80 |  | 
| 82 | 
            -
                 | 
| 83 | 
            -
                return if expected.nil?
         | 
| 81 | 
            +
                return if expected.nil? || expected.is_a?(Integer)
         | 
| 84 82 |  | 
| 85 83 | 
             
                begin
         | 
| 86 84 | 
             
                  # expect! comes from the expectation gem
         | 
| 87 85 | 
             
                  expect! client.result => expected
         | 
| 88 86 | 
             
                rescue ::Expectation::Matcher::Mismatch => e
         | 
| 89 | 
            -
                  raise ExpectationFailed.new(e, request:  | 
| 87 | 
            +
                  raise ExpectationFailed.new(e, request: request, response: response), cause: nil
         | 
| 90 88 | 
             
                end
         | 
| 91 89 | 
             
              end
         | 
| 92 90 |  | 
    
        data/lib/rspec/httpd/client.rb
    CHANGED
    
    | @@ -34,6 +34,11 @@ module RSpec::Httpd | |
| 34 34 | 
             
                  run_request(::Net::HTTP::Get, url, body: nil, headers: headers)
         | 
| 35 35 | 
             
                end
         | 
| 36 36 |  | 
| 37 | 
            +
                # A HEAD request
         | 
| 38 | 
            +
                def head(url, headers: {})
         | 
| 39 | 
            +
                  run_request(::Net::HTTP::Head, url, body: nil, headers: headers)
         | 
| 40 | 
            +
                end
         | 
| 41 | 
            +
             | 
| 37 42 | 
             
                # A POST request
         | 
| 38 43 | 
             
                def post(url, body, headers: {})
         | 
| 39 44 | 
             
                  run_request(::Net::HTTP::Post, url, body: body, headers: headers)
         | 
| @@ -104,6 +109,8 @@ module RSpec::Httpd | |
| 104 109 |  | 
| 105 110 | 
             
                module ResponseParser
         | 
| 106 111 | 
             
                  def self.parse(response)
         | 
| 112 | 
            +
                    return nil if response.body.nil?
         | 
| 113 | 
            +
             | 
| 107 114 | 
             
                    content_type = response["content-type"]
         | 
| 108 115 |  | 
| 109 116 | 
             
                    result = if content_type&.include?("application/json")
         |