Module: RSpec::Rails::Matchers Private
- Included in:
- RailsExampleGroup
- Defined in:
- lib/rspec/rails/matchers.rb,
lib/rspec/rails/matchers/be_valid.rb,
lib/rspec/rails/matchers/be_a_new.rb,
lib/rspec/rails/matchers/redirect_to.rb,
lib/rspec/rails/matchers/be_new_record.rb,
lib/rspec/rails/matchers/have_rendered.rb,
lib/rspec/rails/matchers/routing_matchers.rb,
lib/rspec/rails/matchers/have_http_status.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Container module for Rails specific matchers.
Defined Under Namespace
Modules: HaveHttpStatus, RedirectTo, RenderTemplate, RoutingMatchers Classes: BeANew
Instance Method Summary (collapse)
-
- (Object) be_a_new(model_class)
private
Passes if actual is an instance of
model_classand returnsfalseforpersisted?. -
- (Object) be_new_record
private
Passes if actual returns
falseforpersisted?. -
- (Object) be_valid(*args)
private
Passes if the given model instance's
valid?method is true, meaning all of theActiveModel::Validationspassed and no errors exist. -
- (Object) have_http_status(target)
Passes if
responsehas a matching HTTP status code.
Instance Method Details
- (Object) be_a_new(model_class)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Passes if actual is an instance of model_class and returns false for
persisted?. Typically used to specify instance variables assigned to
views by controller actions
Use the with method to specify the specific attributes to match on the
new record.
76 77 78 |
# File 'lib/rspec/rails/matchers/be_a_new.rb', line 76 def be_a_new(model_class) BeANew.new(model_class) end |
- (Object) be_new_record
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Passes if actual returns false for persisted?.
24 25 26 |
# File 'lib/rspec/rails/matchers/be_new_record.rb', line 24 def be_new_record BeANewRecord.new end |
- (Object) be_valid(*args)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Passes if the given model instance's valid? method is true, meaning
all of the ActiveModel::Validations passed and no errors exist. If a
message is not given, a default message is shown listing each error.
43 44 45 |
# File 'lib/rspec/rails/matchers/be_valid.rb', line 43 def be_valid(*args) BeValid.new(*args) end |
- (Object) have_http_status(target)
Passes if response has a matching HTTP status code.
The following symbolic status codes are allowed:
Rack::Utils::SYMBOL_TO_STATUS_CODE- One of the defined
ActionDispatch::TestResponsealiases::error:missing:redirect:success
355 356 357 358 |
# File 'lib/rspec/rails/matchers/have_http_status.rb', line 355 def have_http_status(target) raise ArgumentError, "Invalid HTTP status: nil" unless target HaveHttpStatus.matcher_for_status(target) end |