README.md in mongoid-rspec-1.5.6 vs README.md in mongoid-rspec-1.6.0

- old
+ new

@@ -7,10 +7,22 @@ RSpec matchers for Mongoid 3.x. For Mongoid 2.x, use [mongoid-rspec 1.4.5](http://rubygems.org/gems/mongoid-rspec/versions/1.4.5) +Installation +- +Add to your Gemfile + + gem 'mongoid-rspec' + +Drop in existing or dedicated support file in spec/support (spec/support/mongoid.rb) + + RSpec.configure do |configuration| + configuration.include Mongoid::Matchers + end + Association Matchers - describe User do it { should have_many(:articles).with_foreign_key(:author_id) } @@ -102,10 +114,21 @@ # in order to be able to use the custom_validate matcher, the custom validator class (in this case SsnValidator) # should redefine the kind method to return :custom, i.e. "def self.kind() :custom end" it { should custom_validate(:ssn).with_validator(SsnValidator) } end +Accepts Nested Attributes Matcher +- + describe User do + it { should accept_nested_attributes_for(:articles) } + it { should accept_nested_attributes_for(:comments) } + end + + describe Article do + it { should accept_nested_attributes_for(:permalink) } + end + Index Matcher - describe Article do it { should have_index_for(published: 1) } it { should have_index_for(title: 1).with_options(unique: true, background: true) } @@ -139,21 +162,9 @@ describe Article do it { should have_field(:published).of_type(Boolean).with_default_value_of(false) } it { should have_field(:allow_comments).of_type(Boolean).with_default_value_of(true) } it { should_not have_field(:allow_comments).of_type(Boolean).with_default_value_of(false) } it { should_not have_field(:number_of_comments).of_type(Integer).with_default_value_of(1) } - end - -Use -- -add in Gemfile - - gem 'mongoid-rspec' - -drop in existing or dedicated support file in spec/support (spec/support/mongoid.rb) - - RSpec.configure do |configuration| - configuration.include Mongoid::Matchers end Acknowledgement - Thanks to [Durran Jordan](https://github.com/durran) for providing the changes necessary to make