-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: Add API for testing Array size #17
Comments
Hey @PikachuEXE, I appreciate your feedback, but I'm afraid of feature creep. This is already possible with airborne using a block like so: it 'should validate array size' do
get '/array_api' #api that returns {data: [1,2,3,4]}
expect_json_types({data: -> (data){expect(data.length).to eq(4)}}
end I'll admit it's not as nice as having a specialized function for array size, but I don't think we should add a function for every variation that people come across. This was the intent of the blocks, where you can just use RSpec's robust expectation library. I'm open to feedback though, and if you/others disagree, I'll reconsider. |
I have added one to a wiki page. |
OK, I've changed my mind 😄 I took a look at your code, and I like it, I was thinking about going with a different approach that would have been slightly more invasive. Go ahead and submit a pull request (please add tests and documentation as well) and I'll merge it. Thanks for the effort! |
I tried adding internal methods but didn't work for unknown reason. PR will be created later. |
Thanks for your pull request. I'm closing this issue since I've merged your pull request: #18 |
I am using
json_spec
currently and just started using this gem.I like how I can validate the types easily with
expect_json_types
.But I found no API for Array size, which is very common when writing spec for collection endpoints.
(Like
expect_json_size
)I am staying with
have_json_size
fromjson_spec
at the moment.The text was updated successfully, but these errors were encountered: