README.md in mongoid-rspec-1.13.0 vs README.md in mongoid-rspec-2.0.0.rc1

- old
+ new

@@ -1,31 +1,51 @@ mongoid-rspec -= +============= -[![Build Status][travis_badge]][travis] +[![Build Status](https://secure.travis-ci.org/mongoid-rspec/mongoid-rspec.png?branch=master)](https://travis-ci.org/mongoid-rspec/mongoid-rspec) -RSpec matchers for Mongoid 3.x. +[![Gem Version](https://badge.fury.io/rb/mongoid-rspec.svg)](http://badge.fury.io/rb/mongoid-rspec) -For Mongoid 2.x, use [mongoid-rspec 1.4.5](http://rubygems.org/gems/mongoid-rspec/versions/1.4.5) +[![Code Climate](https://codeclimate.com/github/mongoid-rspec/mongoid-rspec/badges/gpa.svg)](https://codeclimate.com/github/mongoid-rspec/mongoid-rspec) -Installation -- -Add to your Gemfile +mongoid-rspec provides a collection of RSpec-compatible matchers that help to test mongoid documents. - gem 'mongoid-rspec' +## Installation -Drop in existing or dedicated support file in spec/support (spec/support/mongoid.rb) +### With Mongoid 4.x +Use mongoid-rspec [2.0.0.rc1][mongo4] + + gem 'mongoid-rspec', '~> 2.0.0.rc1' + +### With Mongoid 3.x + +Use mongoid-rspec [1.11.0][mongo3]. + + gem 'mongoid-rspec', '~> 1.11.0' + +### With Mongoid 2.x + +Use mongoid-rspec [1.4.5][mongo2] + + gem 'mongoid-rspec', '1.4.5' + +### Configuring + +Drop in existing or dedicated support file in spec/support. +i.e: `spec/support/mongoid.rb` + ```ruby RSpec.configure do |config| config.include Mongoid::Matchers, type: :model end ``` -Association Matchers -- +## Matchers +### Association Matchers + ```ruby describe User do it { should have_many(:articles).with_foreign_key(:author_id).ordered_by(:title) } it { should have_one(:record) } @@ -67,12 +87,11 @@ describe Site do it { should have_many(:users).as_inverse_of(:site).ordered_by(:email.asc) } end ``` -Mass Assignment Matcher -- +### Mass Assignment Matcher ```ruby describe User do it { should allow_mass_assignment_of(:login) } it { should allow_mass_assignment_of(:email) } @@ -83,12 +102,11 @@ it { should_not allow_mass_assignment_of(:role) } end ``` -Validation Matchers -- +### Validation Matchers ```ruby describe Site do it { should validate_presence_of(:name) } it { should validate_uniqueness_of(:name) } @@ -129,12 +147,11 @@ # 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 -- +### Accepts Nested Attributes Matcher ```ruby describe User do it { should accept_nested_attributes_for(:articles) } it { should accept_nested_attributes_for(:comments) } @@ -143,12 +160,11 @@ describe Article do it { should accept_nested_attributes_for(:permalink) } end ``` -Index Matcher -- +### Index Matcher ```ruby describe Article do it { should have_index_for(published: 1) } it { should have_index_for(title: 1).with_options(unique: true, background: true) } @@ -157,12 +173,11 @@ describe Profile do it { should have_index_for(first_name: 1, last_name: 1) } end ``` -Others -- +### Others ```ruby describe User do it { should have_fields(:email, :login) } it { should have_field(:s).with_alias(:status) } @@ -189,19 +204,19 @@ 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 ``` -Known issues -- +## Known issues -accept_nested_attributes_for matcher must test options [issue 91](https://github.com/evansagge/mongoid-rspec/issues/91). +accept_nested_attributes_for matcher must test options [issue 91](https://github.com/mongoid-rspec/mongoid-rspec/issues/91). -Acknowledgement -- -Thanks to [Durran Jordan](https://github.com/durran) for providing the changes necessary to make -this compatible with mongoid 2.0.0.rc, and for other [contributors](https://github.com/evansagge/mongoid-rspec/contributors) +## Acknowledgement + +Thanks to [Durran Jordan][durran] for providing the changes necessary to make +this compatible with mongoid 2.0.0.rc, and for other [contributors](https://github.com/mongoid-rspec/mongoid-rspec/contributors) to this project. - -[travis_badge]: https://travis-ci.org/mongoid-rspec/mongoid-rspec.svg?branch=mongoid-3-1 -[travis]: https://travis-ci.org/mongoid-rspec/mongoid-rspec +[durran]: https://github.com/durran +[mongo2]: http://rubygems.org/gems/mongoid-rspec/versions/1.4.5 +[mongo3]: http://rubygems.org/gems/mongoid-rspec/versions/1.11.0 +[mongo4]: http://rubygems.org/gems/mongoid-rspec/versions/2.0.0.rc1