module RSpecApi::Expectations::Response::Body::Collection

Public Instance Methods

expect_a_collection(response, expectations = {}) click to toggle source
# File lib/rspec-api/expectations/body/collection.rb, line 8
def expect_a_collection(response, expectations = {})
  include RSpecApi::Matchers

  if should_check_collection(response, expectations)
    if expectations[:collection]
      it { expect(response).to be_a_collection }
    else
      it { expect(response).not_to be_a_collection }
    end
  end
end

Private Instance Methods

should_check_collection(response, expectations) click to toggle source
# File lib/rspec-api/expectations/body/collection.rb, line 22
def should_check_collection(response, expectations)
  expectations.key?(:collection) && success?(response) && has_entity_body?(response)
end