Module: RSpecApi::Matchers::Filter

Included in:
RSpecApi::Matchers
Defined in:
lib/rspec-api/matchers/filter/matcher.rb,
lib/rspec-api/matchers/filter/be_filtered.rb

Defined Under Namespace

Classes: Matcher

Instance Method Summary collapse

Instance Method Details

#be_filtered(options = {}) ⇒ Object

Passes if the response body is a non-empty filtered JSON collection

For more examples check be_filtered_spec.rb.

Examples:


# Passes if the body only contains objects with ID = 1
body = '[{"id": 1}, {"id": 1}, {"id": 1}]'
expect(OpenStruct.new body: body).to be_filtered by: :id, value: 1


15
16
17
# File 'lib/rspec-api/matchers/filter/be_filtered.rb', line 15

def be_filtered(options = {})
  RSpecApi::Matchers::Filter::Matcher.new options
end