collectiveidea / json_spec

Easily handle JSON in RSpec and Cucumber
rubygems.org/gems/json_spec
MIT License
919 stars 114 forks source link

ArgumentError: bad value for range #86

Closed xurde closed 7 years ago

xurde commented 9 years ago

I'm trying to use the have_json_size matcher but no luck. When I used as shown below, I get an error like ArgumentError: bad value for range.

    context "listing cases" do
      specify do
        get "#{API_BASE_PATH}/cases/"
        expect(last_response).to be_ok
        expect { JSON.parse(last_response.body) }.not_to raise_exception
        expect (last_response.body).to    have_json_size(1)
      end
    end

Attending to the examples it seems this syntax is ok. Any clue if I'm doing something wrong? Thanks a lot in advance.

xurde commented 9 years ago

As additional info, I think that this can be related to the fact that I'm using rack/test to test a Grape based API. So I'm including this helper Rack::Test::Methods in the Rspec config and I think this is generating a different result class in the response.boby: Rack::MockResponse.

Any clue on how to make the matcher rack/test compliant?

Regards.

shekibobo commented 7 years ago

Hi there! We’re doing some open source maintenance work and closing old issues. If you would still like this issue to be addressed, please re-open it by May 17, 2017. Thanks!