Sha256: c0d3b0858f32aca869881da11f701da47e238a4c39871340e86426680b97d914
Contents?: true
Size: 1004 Bytes
Versions: 1
Compression:
Stored size: 1004 Bytes
Contents
# frozen_string_literal: true 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-1.0.0 | lib/rack-rest-rspec/matchers/respond_with_collection_size.rb |