Module: Mongoid::Matchers

Includes:
Associations, Validations
Defined in:
lib/matchers/accept_nested_attributes.rb,
lib/mongoid-rspec.rb,
lib/matchers/indexes.rb,
lib/matchers/document.rb,
lib/matchers/validations.rb,
lib/matchers/associations.rb,
lib/matchers/allow_mass_assignment.rb,
lib/matchers/validations/format_of.rb,
lib/matchers/validations/length_of.rb,
lib/matchers/validations/associated.rb,
lib/matchers/validations/presence_of.rb,
lib/matchers/validations/exclusion_of.rb,
lib/matchers/validations/inclusion_of.rb,
lib/matchers/validations/with_message.rb,
lib/matchers/validations/acceptance_of.rb,
lib/matchers/validations/uniqueness_of.rb,
lib/matchers/validations/confirmation_of.rb,
lib/matchers/validations/numericality_of.rb,
lib/matchers/validations/custom_validation_of.rb

Overview

:nodoc:

Defined Under Namespace

Modules: Associations, Validations Classes: AcceptNestedAttributesForMatcher, AllowMassAssignmentOfMatcher, HaveFieldMatcher, HaveIndexForMatcher

Constant Summary

Constants included from Associations

Associations::BELONGS_TO, Associations::EMBEDDED_IN, Associations::EMBEDS_MANY, Associations::EMBEDS_ONE, Associations::HAS_AND_BELONGS_TO_MANY, Associations::HAS_MANY, Associations::HAS_ONE

Instance Method Summary collapse

Methods included from Validations

#custom_validate, #validate_acceptance_of, #validate_associated, #validate_confirmation_of, #validate_exclusion_of, #validate_format_of, #validate_inclusion_of, #validate_length_of, #validate_numericality_of, #validate_presence_of, #validate_uniqueness_of

Methods included from Associations

#be_embedded_in, #belong_to_related, #embed_many, #embed_one, #have_and_belong_to_many, #have_many_related, #have_one_related

Instance Method Details

#accept_nested_attributes_for(attribute) ⇒ Object

Ensures that the model can accept nested attributes for the specified association.

Example:

it { should accept_nested_attributes_for(:articles) }


10
11
12
# File 'lib/matchers/accept_nested_attributes.rb', line 10

def accept_nested_attributes_for(attribute)
  AcceptNestedAttributesForMatcher.new(attribute)
end

#allow_mass_assignment_of(value) ⇒ Object

Ensures that the attribute can be set on mass update.

it { should_not allow_mass_assignment_of(:password) }
it { should allow_mass_assignment_of(:first_name) }

In Rails 3.1 you can check role as well:

it { should allow_mass_assignment_of(:first_name).as(:admin) }


97
98
99
# File 'lib/matchers/allow_mass_assignment.rb', line 97

def allow_mass_assignment_of(value)
  AllowMassAssignmentOfMatcher.new(value)
end

#have_field(*args) ⇒ Object Also known as: have_fields



85
86
87
# File 'lib/matchers/document.rb', line 85

def have_field(*args)
  HaveFieldMatcher.new(*args)
end

#have_index_for(index_fields) ⇒ Object



80
81
82
# File 'lib/matchers/indexes.rb', line 80

def have_index_for(index_fields)
  HaveIndexForMatcher.new(index_fields)
end