module RSpec::Rails::Matchers
def be_a_new(model_class)
- Api: - public
def be_a_new(model_class) BeANew.new(model_class) end
def be_new_record
- Api: - public
def be_new_record BeANewRecord.new end
def be_valid(*args)
- Api: - public
def be_valid(*args) BeValid.new(*args) end
def check_active_job_adapter
- Private: -
def check_active_job_adapter return if ::ActiveJob::QueueAdapters::TestAdapter === ::ActiveJob::Base.queue_adapter raise StandardError, "To use ActiveJob matchers set `ActiveJob::Base.queue_adapter = :test`" end
def have_been_enqueued
- Api: - public
def have_been_enqueued check_active_job_adapter ActiveJob::HaveBeenEnqueued.new end
def have_enqueued_job(job = nil)
- Api: - public
def have_enqueued_job(job = nil) check_active_job_adapter ActiveJob::HaveEnqueuedJob.new(job) end
def have_http_status(target)
- See: https://github.com/rack/rack/blob/master/lib/rack/utils.rb - `Rack::Utils::SYMBOL_TO_STATUS_CODE`
See: https://github.com/rails/rails/blob/master/actionpack/lib/action_dispatch/testing/test_response.rb - `ActionDispatch::TestResponse`
Other tags:
- Example: Works with standard `response` objects and Capybara's `page` -
Example: Accepts numeric and symbol statuses -
Other tags:
- Api: - public
def have_http_status(target) raise ArgumentError, "Invalid HTTP status: nil" unless target HaveHttpStatus.matcher_for_status(target) end