module RSpec::Rails::Matchers
Public Instance Methods
be_a_new(model_class)
click to toggle source
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
@example
get :new assigns(:thing).should be_a_new(Thing) post :create, :thing => { :name => "Illegal Value" } assigns(:thing).should be_a_new(Thing).with(:name => nil)
# File lib/rspec/rails/matchers/be_a_new.rb, line 73 def be_a_new(model_class) BeANew.new(model_class) end
be_new_record()
click to toggle source
Passes if actual returns `false` for `persisted?`.
@example
get :new assigns(:thing).should be_new_record
# File lib/rspec/rails/matchers/be_new_record.rb, line 24 def be_new_record BeANewRecord.new end
be_valid(*args)
click to toggle source
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.
@example
thing = Thing.new thing.should be_valid
# File lib/rspec/rails/matchers/be_valid.rb, line 37 def be_valid(*args) BeValid.new(*args) end