Skip to content
Newer
Older
100644 159 lines (111 sloc) 4.63 KB
1e71df3 update readme
Francesco Rodriguez authored Apr 4, 2012
1 # mongoid-minitest
e1cae91 creating gem
Francesco Rodriguez authored Apr 4, 2012
2
5b9ee94 updating readme - require ruby 1.9
Francesco Rodriguez authored Apr 11, 2012
3 MiniTest matchers for Mongoid. Requires Ruby 1.9.
1e71df3 update readme
Francesco Rodriguez authored Apr 5, 2012
4
6b20f24 adding first release date
Francesco Rodriguez authored Apr 5, 2012
5 **First release: 10/04/2012** - 1 week! :grin:
e1cae91 creating gem
Francesco Rodriguez authored Apr 4, 2012
6
7 ## Installation
8
9 Add this line to your application's Gemfile:
10
11 gem 'mongoid-minitest'
12
13 And then execute:
14
15 $ bundle
16
17 Or install it yourself as:
18
19 $ gem install mongoid-minitest
20
21 ## Usage
22
4efb365 udpate readme - usage examples
Francesco Rodriguez authored Apr 10, 2012
23 Matchers are available at `Mongoid::Matchers` module.
24 Setup matchers according to your testing preferences:
25
26 ### minitest/unit
110909c deleting assert_failure and fix docs
Francesco Rodriguez authored Apr 6, 2012
27
28 class MiniTest::Unit::TestCase
bb8a290 udpate readme - usage
Francesco Rodriguez authored Apr 10, 2012
29 include Mongoid::Matchers
110909c deleting assert_failure and fix docs
Francesco Rodriguez authored Apr 6, 2012
30 end
31
4efb365 udpate readme - usage examples
Francesco Rodriguez authored Apr 10, 2012
32 ### minitest/spec
110909c deleting assert_failure and fix docs
Francesco Rodriguez authored Apr 6, 2012
33
34 class MiniTest::Spec
bb8a290 udpate readme - usage
Francesco Rodriguez authored Apr 10, 2012
35 include Mongoid::Matchers
110909c deleting assert_failure and fix docs
Francesco Rodriguez authored Apr 6, 2012
36 end
37
4efb365 udpate readme - usage examples
Francesco Rodriguez authored Apr 10, 2012
38 See the following examples:
39
40 # minitest/unit
41 class DummyTest < MiniTest::Unit::TestCase
42 def test_matchers
43 assert_must Dummy, have_field(:name)
44 assert_wont Dummy, have_field(:none)
45 end
46 end
47
48 # minitest/spec
49 describe Dummy
50 it "sould test matchers" do
51 Dummy.must have_field(:name)
52 Dummy.wont have_field(:none)
53 end
54 end
55
56 # minitest/spec with subject
57 describe Dummy
58 it { must have_field(:name) }
59 it { wont have_field(:none) }
60 end
61
62 ## Matchers
61d9462 Adding must and wont using subject specs
Francesco Rodriguez authored Apr 5, 2012
63
8e07c70 Explaning mongoid::matchers module
Francesco Rodriguez authored Apr 10, 2012
64 `Mongoid::Matchers` include the following modules:
65
68577da module matchers structure
Francesco Rodriguez authored Apr 10, 2012
66 Module Mongoid
67 Module Matchers
68 include Mongoid::Matchers::Document
69 include Mongoid::Matchers::Validations
70 end
71 end
8e07c70 Explaning mongoid::matchers module
Francesco Rodriguez authored Apr 10, 2012
72
571f134 update readme
Francesco Rodriguez authored Apr 10, 2012
73 ### Document Matchers
61d9462 Adding must and wont using subject specs
Francesco Rodriguez authored Apr 5, 2012
74
555f7ac added validate_presence_of(field) matcher
Francesco Rodriguez authored Apr 10, 2012
75 describe Mongoid::Matchers::Document do
76 subject { Person }
77
78 it { must be_document }
79 it { must be_paranoid }
80 it { must be_versioned }
81 it { must be_timestamped }
f5886eb added be_document matcher
Francesco Rodriguez authored Apr 6, 2012
82
61d9462 Adding must and wont using subject specs
Francesco Rodriguez authored Apr 5, 2012
83 it { must have_field(:name) }
555f7ac added validate_presence_of(field) matcher
Francesco Rodriguez authored Apr 10, 2012
84 it { must have_field(:name).of_type(String) }
a602229 adding with_default_value validation to HaveFieldMatcher
Francesco Rodriguez authored Apr 6, 2012
85 it { must have_field(:name).with_default_value("me") }
555f7ac added validate_presence_of(field) matcher
Francesco Rodriguez authored Apr 10, 2012
86 it { must have_field(:name).of_type(String).with_default_value("me") }
4f1cb7e added have_fields matcher
Francesco Rodriguez authored Apr 6, 2012
87
42617fd refactoring tests and examples
Francesco Rodriguez authored Apr 11, 2012
88 it { must have_fields(:name, :login) }
89 it { must have_fields(:name, :login).of_type(String) }
90 it { must have_fields(:name, :login).with_default_value("me") }
91 it { must have_fields(:name, :login).of_type(String).with_default_value("me") }
4f1cb7e added have_fields matcher
Francesco Rodriguez authored Apr 7, 2012
92 end
93
555f7ac added validate_presence_of(field) matcher
Francesco Rodriguez authored Apr 10, 2012
94 ### Validations Matchers
95
96 describe Mongoid::Matchers::Validations do
97 subject { Person }
98
99 it { must validate_presence_of(:name) }
b7c2add added validate_uniqueness_of matcher
Francesco Rodriguez authored Apr 10, 2012
100
42617fd refactoring tests and examples
Francesco Rodriguez authored Apr 11, 2012
101 it { must validate_uniqueness_of(:login).case_insensitive }
722db28 added validate_presence_of matcher
Francesco Rodriguez authored Apr 11, 2012
102
45f9296 fixing with_min examples
Francesco Rodriguez authored Apr 11, 2012
103 it { must validate_length_of(:password).with_min(8) }
23909a5 added with_minimum chained matcher to validate_length_of matcher
Francesco Rodriguez authored Apr 11, 2012
104 it { must validate_length_of(:password).with_minimum(8) }
a9fce71 added with_max alias to with_maximum matcher
Francesco Rodriguez authored Apr 11, 2012
105 it { must validate_length_of(:password).with_max(16) }
a604c91 added with_maximum matcher to ValidateLengthMatcher
Francesco Rodriguez authored Apr 11, 2012
106 it { must validate_length_of(:password).with_maximum(16) }
a6552f5 added validate_format_of matcher
Francesco Rodriguez authored Apr 11, 2012
107
ea6fb4f updating examples
Francesco Rodriguez authored Apr 11, 2012
108 it { must validate_format_of(:email).to_allow("foo@bar.com") }
109 it { must validate_format_of(:email).to_not_allow("foo_bar_com") }
b98a9b5 added to_not_allow matcher to ValidateExclusionMatcher
Francesco Rodriguez authored Apr 11, 2012
110
111 it { must validate_exclusion_of(:email).to_not_allow("foo@bar.com", "fizz@buzz.com") }
555f7ac added validate_presence_of(field) matcher
Francesco Rodriguez authored Apr 10, 2012
112 end
113
e1cae91 creating gem
Francesco Rodriguez authored Apr 4, 2012
114 ## Contributing
115
116 1. Fork it
117 2. Create your feature branch (`git checkout -b my-new-feature`)
118 3. Commit your changes (`git commit -am 'Added some feature'`)
119 4. Push to the branch (`git push origin my-new-feature`)
120 5. Create new Pull Request
88f6b78 Use bundle exec rake to run minitest gem version
Francesco Rodriguez authored Apr 5, 2012
121
122 ## Unit Tests
123
bec6dc3 adding guard step to readme
Francesco Rodriguez authored Apr 6, 2012
124 To run unit tests, run `bundle exec rake` or `bundle exec guard` to run in auto mode.
998d089 updating readme
Francesco Rodriguez authored Apr 10, 2012
125
126 ## License
127
128 Copyright (c) 2012 Francesco Rodriguez
129
130 MIT License
131
132 Permission is hereby granted, free of charge, to any person obtaining
133 a copy of this software and associated documentation files (the
134 "Software"), to deal in the Software without restriction, including
135 without limitation the rights to use, copy, modify, merge, publish,
136 distribute, sublicense, and/or sell copies of the Software, and to
137 permit persons to whom the Software is furnished to do so, subject to
138 the following conditions:
139
140 The above copyright notice and this permission notice shall be
141 included in all copies or substantial portions of the Software.
142
143 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
144 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
145 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
146 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
147 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
148 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
149 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
f857d58 last means last
Francesco Rodriguez authored Apr 10, 2012
150
151 ## Last words
152
355902e we are Epic
Francesco Rodriguez authored Apr 10, 2012
153 At [EpicLabs](https://github.com/epiclabs/), We're migrating all the tests from `rspec` to `minitest`. I've been using
f857d58 last means last
Francesco Rodriguez authored Apr 10, 2012
154 [mongoid-rspec gem](https://github.com/evansagge/mongoid-rspec) by [evanssage](https://github.com/evansagge).
36e519f readme typo
Francesco Rodriguez authored Apr 11, 2012
155 So, this gem is heavily inspired in Evan's gem and [minitest-matchers](https://github.com/zenspider/minitest-matchers) gem
f857d58 last means last
Francesco Rodriguez authored Apr 10, 2012
156 by [zenspider](https://github.com/zenspider). We love [minitest](https://github.com/seattlerb/minitest) and
157 we hope that this will be helpful for you. Thanks!
158
Something went wrong with that request. Please try again.