Skip to content

Commit

Permalink
update README
Browse files Browse the repository at this point in the history
  • Loading branch information
Francesco Rodriguez committed Feb 27, 2013
1 parent f434810 commit 7f300e5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 38 deletions.
45 changes: 9 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ Usage
Require `mongoid-minitest` in your `test_helper.rb` or
`spec_helper.rb` file:

gem 'minitest'
require 'minitest/autorun'
require 'mongoid'
require 'mongoid-minitest'
Expand Down Expand Up @@ -91,11 +90,14 @@ Matchers
Module Mongoid
Module Matchers
include Document
include Validations
include Associations
include MiniTest::Matchers::ActiveModel
end
end

*NOTE:* [minitest-activemodel](https://github.com/frodsan/minitest-activemodel)
gem is a dependency of this gem.

### Document Matchers

describe Mongoid::Matchers::Document do
Expand All @@ -122,40 +124,6 @@ Matchers
it { must have_index_for(:account_id, :email) }
end

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

it { must validate_confirmation_of(:password) }
it { must validate_acceptance_of(:terms_of_use).accept_with("1") }

it { must validate_associated(:pets) }

# 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
Expand Down Expand Up @@ -183,6 +151,11 @@ Matchers
end
end

### Validation Matchers

Check [minitest-activemodel](https://github.com/frodsan/minitest-activemodel)
gem for more information.

Contributing
------------

Expand Down
2 changes: 0 additions & 2 deletions test/matchers/associations_test.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
require 'test_helper'

describe "Associations" do

describe Person do
subject { Person }

Expand Down Expand Up @@ -30,5 +29,4 @@

it { must embedded_in(:person) }
end

end

0 comments on commit 7f300e5

Please sign in to comment.