Module: RSpecApi::Matchers::Status

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

Defined Under Namespace

Classes: Matcher

Instance Method Summary collapse

Instance Method Details

#have_status(status) ⇒ Object

Passes if the object has a status that matches status.

Examples:

Passes if the response status matches :ok

require 'rspec-api-matchers'

obj = OpenStruct.new status: 200

describe 'have_status' do
  include RSpecApi::Matchers::Status
  it { expect(obj).to have_status :ok }
end

# => (rspec) 1 example, 0 failures

Parameters:

  • status (Symbol or Integer)

    The expected status code

See Also:


25
26
27
# File 'lib/rspec-api/matchers/status/have_status.rb', line 25

def have_status(status)
  RSpecApi::Matchers::Status::Matcher.new status
end