module RSpec::Rails::Matchers

def be_a_new(model_class)

Other tags:
    Api: - public
def be_a_new(model_class)
  BeANew.new(model_class)
end

def be_new_record

Other tags:
    Api: - public
def be_new_record
  BeANewRecord.new
end

def be_valid(*args)

Other tags:
    Api: - public
def be_valid(*args)
  BeValid.new(*args)
end

def check_action_cable_adapter

Other tags:
    Private: -
def check_action_cable_adapter
  return if ::ActionCable::SubscriptionAdapter::Test === ::ActionCable.server.pubsub
  raise StandardError, "To use ActionCable matchers set `adapter: test` in your cable.yml"
end

def check_active_job_adapter

Other tags:
    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

Other tags:
    Api: - public
def have_been_enqueued
  check_active_job_adapter
  ActiveJob::HaveBeenEnqueued.new
end

def have_been_performed

Other tags:
    Api: - public
def have_been_performed
  check_active_job_adapter
  ActiveJob::HaveBeenPerformed.new
end

def have_broadcasted_to(target = nil)

Other tags:
    Api: - public
def have_broadcasted_to(target = nil)
  check_action_cable_adapter
  ActionCable::HaveBroadcastedTo.new(target, channel: described_class)
end

def have_enqueued_job(job = nil)

Other tags:
    Api: - public
def have_enqueued_job(job = nil)
  check_active_job_adapter
  ActiveJob::HaveEnqueuedJob.new(job)
end

def have_enqueued_mail(mailer_class = nil, mail_method_name = nil)

Other tags:
    Api: - public
def have_enqueued_mail(mailer_class = nil, mail_method_name = nil)
  HaveEnqueuedMail.new(mailer_class, mail_method_name)
end

def have_http_status(target)

Other tags:
    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

def have_performed_job(job = nil)

Other tags:
    Api: - public
def have_performed_job(job = nil)
  check_active_job_adapter
  ActiveJob::HavePerformedJob.new(job)
end

def receive_inbound_email(message)

Parameters:
  • message (Hash, Mail::Message) -- a mail message or hash of

Other tags:
    Api: - public
def receive_inbound_email(message)
  ActionMailbox::ReceiveInboundEmail.new(message)
end