Module: Mongoid::Matchers

Includes:
Associations, Validations
Defined in:
lib/matchers/accept_nested_attributes.rb,
lib/mongoid/rspec.rb,
lib/matchers/have_field.rb,
lib/matchers/validations.rb,
lib/matchers/associations.rb,
lib/matchers/be_stored_in.rb,
lib/matchers/have_timestamps.rb,
lib/matchers/be_dynamic_document.rb,
lib/matchers/be_mongoid_document.rb,
lib/matchers/allow_mass_assignment.rb,
lib/matchers/validations/format_of.rb,
lib/matchers/validations/length_of.rb,
lib/matchers/indexes/have_index_for.rb,
lib/matchers/validations/absence_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/indexes/v3/have_index_for.rb,
lib/matchers/indexes/v4/have_index_for.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, BeDynamicDocument, BeMongoidDocument, BeStoredIn, HaveField, HaveIndexFor, HaveIndexForBase, HaveTimestamps

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_absence_of, #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) }


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

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) }


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

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

#be_dynamic_documentObject



3
4
5
# File 'lib/matchers/be_dynamic_document.rb', line 3

def be_dynamic_document
  BeDynamicDocument.new
end

#be_mongoid_documentObject



3
4
5
# File 'lib/matchers/be_mongoid_document.rb', line 3

def be_mongoid_document
  BeMongoidDocument.new
end

#be_stored_in(options) ⇒ Object



3
4
5
# File 'lib/matchers/be_stored_in.rb', line 3

def be_stored_in(options)
  BeStoredIn.new(options)
end

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



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

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

#have_index_for(index_key) ⇒ Object



3
4
5
# File 'lib/matchers/indexes/v3/have_index_for.rb', line 3

def have_index_for(index_key)
  HaveIndexFor.new(index_key)
end

#have_timestampsObject



3
4
5
# File 'lib/matchers/have_timestamps.rb', line 3

def have_timestamps
  HaveTimestamps.new
end