Sha256: 0eaad6e0b951bfa424ac9d065ca929e14c04feef935d6c114c8cb8d770c90067
Contents?: true
Size: 978 Bytes
Versions: 1
Compression:
Stored size: 978 Bytes
Contents
RSpec::Matchers.define :respond_with_collection do |options={}| expected = options[:size] match do |actual| result = JSON::parse(actual.browser.last_response.body, symbolize_names: true) result = result[options[:root]] unless options[:root].nil? result.size == expected end description do "respond with a collection of records size of #{expected}" end failure_message do |actual| result = JSON::parse(actual.browser.last_response.body, symbolize_names: true) result = result[options[:root]] unless options[:root].nil? "expected #{actual} response body collection would have a size of #{expected}, \ngot #{result.size}" end failure_message_when_negated do |actual| result = JSON::parse(actual.browser.last_response.body, symbolize_names: true) result = result[options[:root]] unless options[:root].nil? "expected #{actual} response body collection would not have a size of #{expected}, \ngot #{result.size}" end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rack-rest-rspec-0.0.5 | lib/rack-rest-rspec/matchers/respond_with_collection_size.rb |