README.md in mongoid-minitest-0.0.1 vs README.md in mongoid-minitest-0.0.2

- old
+ new

@@ -1,10 +1,11 @@ -# mongoid-minitest +# mongoid-minitest [![Build Status](https://secure.travis-ci.org/frodsan/mongoid-minitest.png?branch=master&.png)](http://travis-ci.org/frodsan/mongoid-minitest) [![Dependency Status](https://gemnasium.com/frodsan/mongoid-minitest.png)](https://gemnasium.com/frodsan/mongoid-minitest) MiniTest matchers for Mongoid. -Requires Ruby 1.9. +* Compatible with Ruby >=1.9.2. +* Tested on MiniTest 2.x ## Installation Add this line to your application's Gemfile: @@ -74,15 +75,17 @@ ### Document Matchers describe Mongoid::Matchers::Document do subject { Person } - it { must be_document } - it { must be_paranoid } - it { must be_versioned } - it { must be_timestamped } + it { must be_document } # if model includes Mongoid::Document + it { must be_paranoid } # if model includes Mongoid::Paranoia + it { must be_versioned } # if model includes Mongoid::Versioning + it { must be_timestamped } # if model includes Mongoid::Timestamps + it { must be_stored_in(:people) } # checks the collection for model's document + it { must have_field(:name) } it { must have_field(:name).of_type(String) } it { must have_field(:name).with_default_value("me") } it { must have_field(:name).of_type(String).with_default_value("me") } @@ -90,35 +93,59 @@ it { must have_fields(:name, :login).of_type(String) } it { must have_fields(:name, :login).with_default_value("me") } it { must have_fields(:name, :login).of_type(String).with_default_value("me") } end -### Validations Matchers +### Validation Matchers describe Mongoid::Matchers::Validations do subject { Person } it { must validate_presence_of(:name) } it { must validate_uniqueness_of(:login).case_insensitive } + it { must validate_uniqueness_of(:login).scoped_to(:site) } + it { must validate_length_of(:login).in(5..12) } + it { must validate_length_of(:login).within(5..12) } + it { must validate_length_of(:password).with_min(8) } it { must validate_length_of(:password).with_minimum(8) } it { must validate_length_of(:password).with_max(16) } it { must validate_length_of(:password).with_maximum(16) } it { must validate_format_of(:email).to_allow("foo@bar.com") } it { must validate_format_of(:email).to_not_allow("foo_bar_com") } + it { must validate_inclusion_of(:role).to_allow("user", "admin") } it { must validate_exclusion_of(:email).to_not_allow("foo@bar.com", "fizz@buzz.com") } + + # Testing validators custom messages + it { must validate_presence_of(:role).with_message("no role") } + it { must validate_length_of(:password).with_min(8).with_message("len >= 8") } end ### Association Matchers describe Mongoid::Matchers::Associations do - subject { Person } + describe Person do + subject { Person } - it { must have_many(:pets).of_type(Pet) } + it { must have_one(:account).of_type(Account) } + it { must have_many(:pets).of_type(Pet) } + end + + describe Pet do + subject { Pet } + + it { must belong_to(:person).of_type(Person) } + end + + describe Account do + subject { Account } + + it { must belong_to(:person).of_type(Person) } + end end ## Contributing 1. Fork it