Module: RSpecApi::Matchers::Collection

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

Defined Under Namespace

Classes: Matcher

Instance Method Summary collapse

Instance Method Details

#be_a_collectionObject

Passes if the response body is a collection of JSON objects

For more examples check be_a_collection_spec.rb.

Examples:


# Passes if the body is a JSON array
body = '[{"id": 1}]'
expect(OpenStruct.new body: body).to be_a_collection


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

def be_a_collection
  RSpecApi::Matchers::Collection::Matcher.new
end