mongoid-minitest 0.0.3.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +68 -56
- data/README.md +19 -19
- data/lib/matchers/associations/associations.rb +8 -8
- data/lib/matchers/document/be_stored_in.rb +1 -1
- data/lib/matchers/document/document.rb +5 -5
- data/lib/matchers/document/have_field.rb +2 -2
- data/lib/matchers/document/have_index.rb +5 -3
- data/lib/matchers/validations/exclusion.rb +2 -2
- data/lib/matchers/validations/inclusion.rb +4 -4
- data/lib/matchers/validations/uniqueness.rb +3 -3
- data/lib/mongoid-minitest.rb +20 -20
- data/lib/mongoid-minitest/version.rb +1 -1
- metadata +28 -51
- data/.gitignore +0 -18
- data/.rbenv-version +0 -1
- data/.travis.yml +0 -5
- data/Gemfile +0 -4
- data/Guardfile +0 -12
- data/Rakefile +0 -11
- data/mongoid-minitest.gemspec +0 -23
- data/test/matchers/associations_test.rb +0 -34
- data/test/matchers/document_test.rb +0 -25
- data/test/matchers/validations_test.rb +0 -33
- data/test/models/models.rb +0 -62
- data/test/test_helper.rb +0 -12
data/CHANGELOG.md
CHANGED
@@ -1,56 +1,68 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
+
|
4
|
-
+
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
+
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
+
|
17
|
-
+
|
18
|
-
+
|
19
|
-
+
|
20
|
-
+
|
21
|
-
+
|
22
|
-
+
|
23
|
-
+
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
+
|
30
|
-
+
|
31
|
-
+
|
32
|
-
|
33
|
-
+
|
34
|
-
+
|
35
|
-
+
|
36
|
-
+
|
37
|
-
+
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
+
|
42
|
-
+
|
43
|
-
+
|
44
|
-
+
|
45
|
-
+
|
46
|
-
+
|
47
|
-
+
|
48
|
-
+
|
49
|
-
+
|
50
|
-
+
|
51
|
-
+
|
52
|
-
+
|
53
|
-
+
|
54
|
-
+
|
55
|
-
+
|
56
|
-
+
|
1
|
+
## 0.1.0 - unreleased
|
2
|
+
|
3
|
+
+ Change support to only Ruby 1.9.3.
|
4
|
+
+ Bump mongoid version to 3.0.2 and minitest version to 3.3.0 and minitest version
|
5
|
+
to 3.3.0 - *Sascha Wessel*.
|
6
|
+
|
7
|
+
## 0.0.3.1 - 31/05/2012
|
8
|
+
|
9
|
+
+ Change `have_index_for(indexed_field)` to work with `belongs_to :association, index: true`.
|
10
|
+
Fixes [#7](https://github.com/frodsan/mongoid-minitest/issues/7).
|
11
|
+
|
12
|
+
## 0.0.3 - 04/15/2012
|
13
|
+
|
14
|
+
+ Add `have_index_for(indexed_field)` document matcher.
|
15
|
+
+ Add `embedded_in(association_name)` association matcher.
|
16
|
+
+ Add `embed_many(association_name)` association matcher.
|
17
|
+
+ Fix issue check `association_type` if metadata is not nil.
|
18
|
+
+ Add `embed_one(association_name)` association matcher.
|
19
|
+
+ Add `have_and_belong_to_many(association_name)` association matcher.
|
20
|
+
+ Add `validate_associated(association_name)` validation matcher.
|
21
|
+
+ Add `accept_with(value)` chain matcher to `validate_acceptance_of`.
|
22
|
+
+ Add `validate_acceptance_of(field)` validation matcher.
|
23
|
+
+ Add `validate_confirmation_of(field)` validation matcher.
|
24
|
+
|
25
|
+
## 0.0.2 - 04/13/2012
|
26
|
+
|
27
|
+
+ Add `have_one(association_name)` association matcher.
|
28
|
+
+ Add `in(range)` alias to `within` matcher.
|
29
|
+
+ Add `within(range)` chain matcher to `validate_length_of`.
|
30
|
+
+ Add `scoped_to(*scope)` chain matcher to `validate_uniqueness_of`
|
31
|
+
+ Add `with_message(custom_message)` chain matcher for validation matchers to test
|
32
|
+
custom messages.
|
33
|
+
+ Add `DocumentModuleMatcher` class to simplify document matchers.
|
34
|
+
+ Add `be_stored_in(collection_name)` document matcher.
|
35
|
+
+ Add `to_allow(values)` chain matcher to `validate_inclusion_of`.
|
36
|
+
+ Add `validate_inclusion_of(field)` validation matcher.
|
37
|
+
+ Add `belong_to(association_name)` association matcher.
|
38
|
+
|
39
|
+
## 0.0.1 - 04/12/2012
|
40
|
+
|
41
|
+
+ Add `of_type(type)` chain matcher to association matcher.
|
42
|
+
+ Add `have_many(association_name)` association matcher.
|
43
|
+
+ Add `Mongoid::Matchers::Associations` module.
|
44
|
+
+ Add `to_not_allow(*values)` chain matcher to `validate_exclusion_of`.
|
45
|
+
+ Add `validate_exclusion_of(field)` validation matcher.
|
46
|
+
+ Add `to_not_allow(*values)` matcher to `validate_format_of`.
|
47
|
+
+ Add `to_allow(*values)` matcher to `validate_format_of`.
|
48
|
+
+ Add `validate_format_of(field)` validation matcher.
|
49
|
+
+ Add `with_max(value)` alias to `with_maximum` matcher.
|
50
|
+
+ Add `with_maximum(value)` chain matcher to `validate_length_of`
|
51
|
+
+ Add `with_min(value)` alias to `with_minimum` matcher.
|
52
|
+
+ Add `with_minimum(value)` matcher to `validate_length_of`.
|
53
|
+
+ Add `validate_length_of(field)` validation matcher.
|
54
|
+
+ Add `case_sensitive` chain matcher to `validate_uniqueness_of`.
|
55
|
+
+ Add `validate_uniqueness_of(field)` validation matcher.
|
56
|
+
+ Add `validate_presence_of(field)` validation matcher.
|
57
|
+
+ Add `have_fields(*fields)` document matcher.
|
58
|
+
+ Add `be_timestamped` document matcher.
|
59
|
+
+ Add `be_versioned` document matcher.
|
60
|
+
+ Add `be_paranoid` document matcher.
|
61
|
+
+ Add `be_document` document matcher.
|
62
|
+
+ Add `with_default_value(default)` chain matcher to `have_field`.
|
63
|
+
+ Add `of_type(type)` chain matcher to `have_field`.
|
64
|
+
+ Add `must` and `wont` methods to `MiniTest::Spec`.
|
65
|
+
+ Add `have_field(field)` document matcher.
|
66
|
+
+ Add default failure messages based on description matcher.
|
67
|
+
+ Add `must` and `wont` expectations.
|
68
|
+
+ Add `assert_must` and `assert_wont` to `MiniTest::Assertions`.
|
data/README.md
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
# mongoid-minitest [](http://travis-ci.org/frodsan/mongoid-minitest) [](https://gemnasium.com/frodsan/mongoid-minitest)
|
2
2
|
|
3
|
-
MiniTest matchers for Mongoid.
|
3
|
+
MiniTest matchers for Mongoid.
|
4
4
|
|
5
|
-
##
|
5
|
+
## Support
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
This gem supports:
|
8
|
+
|
9
|
+
* Ruby 1.9.3
|
10
|
+
* Mongoid ~>3.0.2
|
11
|
+
* MiniTest ~>3.3.0
|
9
12
|
|
10
13
|
## Installation
|
11
14
|
|
@@ -23,7 +26,7 @@ Or install it yourself as:
|
|
23
26
|
|
24
27
|
## Usage
|
25
28
|
|
26
|
-
Matchers are available at `Mongoid::Matchers` module.
|
29
|
+
Matchers are available at `Mongoid::Matchers` module.
|
27
30
|
Setup matchers according to your testing preference:
|
28
31
|
|
29
32
|
### minitest/unit
|
@@ -50,7 +53,7 @@ See the following examples:
|
|
50
53
|
|
51
54
|
# minitest/spec
|
52
55
|
describe Dummy
|
53
|
-
it "
|
56
|
+
it "should test matchers" do
|
54
57
|
Dummy.must have_field(:name)
|
55
58
|
Dummy.wont have_field(:none)
|
56
59
|
end
|
@@ -105,7 +108,7 @@ See the following examples:
|
|
105
108
|
subject { Person }
|
106
109
|
|
107
110
|
it { must validate_presence_of(:name) }
|
108
|
-
|
111
|
+
|
109
112
|
it { must validate_uniqueness_of(:login).case_insensitive }
|
110
113
|
it { must validate_uniqueness_of(:login).scoped_to(:site) }
|
111
114
|
|
@@ -162,20 +165,17 @@ See the following examples:
|
|
162
165
|
|
163
166
|
## Contributing
|
164
167
|
|
165
|
-
1. Fork it
|
166
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
167
|
-
3. Commit your changes (`git commit -am 'Added some feature'`)
|
168
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
169
|
-
5. Create new Pull Request
|
168
|
+
1. Fork it.
|
169
|
+
2. Create your feature branch (`git checkout -b my-new-feature`).
|
170
|
+
3. Commit your changes (`git commit -am 'Added some feature'`).
|
171
|
+
4. Push to the branch (`git push origin my-new-feature`).
|
172
|
+
5. Create new Pull Request.
|
170
173
|
|
171
174
|
## Unit Tests
|
172
175
|
|
173
|
-
To run unit tests, run `bundle exec rake
|
176
|
+
To run unit tests, run `bundle exec rake`.
|
174
177
|
|
175
|
-
##
|
178
|
+
## License
|
176
179
|
|
177
|
-
|
178
|
-
|
179
|
-
So, this gem is heavily inspired in Evan's gem and [minitest-matchers](https://github.com/zenspider/minitest-matchers) gem
|
180
|
-
by [zenspider](https://github.com/zenspider). We love [minitest](https://github.com/seattlerb/minitest) and
|
181
|
-
we hope that this will be helpful for you. Thanks!
|
180
|
+
MIT License. Copyright 2012 Francesco Rodriguez. See [LICENSE](https://github.com/frodsan/lego/blob/master/LICENSE)
|
181
|
+
for more information.
|
@@ -27,7 +27,7 @@ module Mongoid
|
|
27
27
|
|
28
28
|
def matches?(subject)
|
29
29
|
@klass = class_of(subject)
|
30
|
-
@metadata = @klass.relations[@association[:name]]
|
30
|
+
@metadata = @klass.relations[@association[:name]]
|
31
31
|
@result = true
|
32
32
|
|
33
33
|
check_association_name
|
@@ -86,19 +86,19 @@ module Mongoid
|
|
86
86
|
type ||= @association[:type]
|
87
87
|
case type.name
|
88
88
|
when HAS_ONE.name
|
89
|
-
(passive ?
|
89
|
+
(passive ? 'reference' : 'references') << ' one'
|
90
90
|
when HAS_MANY.name
|
91
|
-
(passive ?
|
91
|
+
(passive ? 'reference' : 'references') << ' many'
|
92
92
|
when HAS_AND_BELONGS_TO_MANY.name
|
93
|
-
(passive ?
|
93
|
+
(passive ? 'reference' : 'references') << ' and referenced in many'
|
94
94
|
when BELONGS_TO.name
|
95
|
-
(passive ?
|
95
|
+
(passive ? 'be referenced' : 'referenced') << ' in'
|
96
96
|
when EMBEDS_ONE.name
|
97
|
-
(passive ?
|
97
|
+
(passive ? 'embed' : 'embeds') << ' one'
|
98
98
|
when EMBEDS_MANY.name
|
99
|
-
(passive ?
|
99
|
+
(passive ? 'embed' : 'embeds') << ' many'
|
100
100
|
when EMBEDDED_IN.name
|
101
|
-
(passive ?
|
101
|
+
(passive ? 'be' : 'is') << ' embedded in'
|
102
102
|
else
|
103
103
|
raise "Unknown association type #{type}"
|
104
104
|
end
|
@@ -12,17 +12,17 @@ module Mongoid
|
|
12
12
|
def initialize(mod)
|
13
13
|
@mod = mod
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
def matches?(subject)
|
17
17
|
class_of(subject).included_modules.include?(@mod)
|
18
18
|
end
|
19
19
|
|
20
20
|
def description
|
21
21
|
msg = case
|
22
|
-
when @mod == DOCUMENT then
|
23
|
-
when @mod == PARANOIA then
|
24
|
-
when @mod == VERSIONING then
|
25
|
-
when @mod == TIMESTAMPS then
|
22
|
+
when @mod == DOCUMENT then ''
|
23
|
+
when @mod == PARANOIA then 'paranoid '
|
24
|
+
when @mod == VERSIONING then 'versioned '
|
25
|
+
when @mod == TIMESTAMPS then 'timestamped '
|
26
26
|
else raise "Unknow Mongoid module #{@mod}"
|
27
27
|
end
|
28
28
|
|
@@ -31,8 +31,8 @@ module Mongoid
|
|
31
31
|
error << " of type #{result_field.type.inspect}"
|
32
32
|
end
|
33
33
|
|
34
|
-
if check_default_with(result_field.
|
35
|
-
error << " with default value of #{result_field.
|
34
|
+
if check_default_with(result_field.default_val)
|
35
|
+
error << " with default value of #{result_field.default_val.inspect}"
|
36
36
|
end
|
37
37
|
|
38
38
|
@errors << "field #{field.inspect << error}" if !error.blank?
|
@@ -10,10 +10,12 @@ module Mongoid
|
|
10
10
|
def matches?(subject)
|
11
11
|
@klass = class_of(subject)
|
12
12
|
|
13
|
-
|
14
|
-
@
|
13
|
+
@klass.index_options.each do |key, options|
|
14
|
+
unless key[@field.to_sym] || key["#{@field}_id"]
|
15
|
+
@error = "no index for #{@field.inspect}"
|
15
16
|
|
16
|
-
|
17
|
+
return false
|
18
|
+
end
|
17
19
|
end
|
18
20
|
|
19
21
|
true
|
@@ -17,9 +17,9 @@ module Mongoid
|
|
17
17
|
if @not_allowed_values
|
18
18
|
allowed_values = @not_allowed_values - @validator.options[:in].to_a
|
19
19
|
if allowed_values.empty?
|
20
|
-
@positive_message <<
|
20
|
+
@positive_message << ' not allowing all values mentioned'
|
21
21
|
else
|
22
|
-
@negative_message <<
|
22
|
+
@negative_message << ' allowing the values:'
|
23
23
|
@negative_message << " #{to_sentence(allowed_values)}"
|
24
24
|
result = false
|
25
25
|
end
|
@@ -17,15 +17,15 @@ module Mongoid
|
|
17
17
|
if @allowed_values
|
18
18
|
not_allowed_values = @allowed_values - @validator.options[:in].to_a
|
19
19
|
if not_allowed_values.empty?
|
20
|
-
@positive_message <<
|
20
|
+
@positive_message << ' allowing all values mentioned'
|
21
21
|
else
|
22
|
-
@negative_message <<
|
22
|
+
@negative_message << ' not allowing the following the values:'
|
23
23
|
@negative_message << " #{not_allowed_values.inspect}"
|
24
24
|
result = false
|
25
25
|
end
|
26
26
|
end
|
27
|
-
|
28
|
-
result
|
27
|
+
|
28
|
+
result
|
29
29
|
end
|
30
30
|
|
31
31
|
def description
|
@@ -28,7 +28,7 @@ module Mongoid
|
|
28
28
|
def description
|
29
29
|
desc = []
|
30
30
|
desc << " scoped to #{to_sentence(@scope)}" if @scope
|
31
|
-
desc <<
|
31
|
+
desc << ' allowing case insensitive values' if @case_insensitive
|
32
32
|
super << desc.to_sentence
|
33
33
|
end
|
34
34
|
|
@@ -48,9 +48,9 @@ module Mongoid
|
|
48
48
|
|
49
49
|
def check_case_sensivity
|
50
50
|
if @validator.options[:case_sensitive] == false
|
51
|
-
@positive_message <<
|
51
|
+
@positive_message << ' with case insensitive values'
|
52
52
|
else
|
53
|
-
@negative_message <<
|
53
|
+
@negative_message << ' without case insensitive values'
|
54
54
|
@result = false
|
55
55
|
end
|
56
56
|
end
|
data/lib/mongoid-minitest.rb
CHANGED
@@ -1,24 +1,24 @@
|
|
1
|
-
gem
|
2
|
-
require
|
3
|
-
require
|
1
|
+
gem 'minitest'
|
2
|
+
require 'mongoid'
|
3
|
+
require 'minitest/spec'
|
4
4
|
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
13
|
-
require
|
14
|
-
require
|
15
|
-
require
|
16
|
-
require
|
17
|
-
require
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
21
|
-
require
|
5
|
+
require 'minitest/matchers'
|
6
|
+
require 'matchers/helpers'
|
7
|
+
require 'matchers/document/document'
|
8
|
+
require 'matchers/document/have_field'
|
9
|
+
require 'matchers/document/be_stored_in'
|
10
|
+
require 'matchers/document/have_index'
|
11
|
+
require 'matchers/validations/validations'
|
12
|
+
require 'matchers/validations/presence'
|
13
|
+
require 'matchers/validations/uniqueness'
|
14
|
+
require 'matchers/validations/length'
|
15
|
+
require 'matchers/validations/format'
|
16
|
+
require 'matchers/validations/inclusion'
|
17
|
+
require 'matchers/validations/exclusion'
|
18
|
+
require 'matchers/validations/confirmation'
|
19
|
+
require 'matchers/validations/acceptance'
|
20
|
+
require 'matchers/validations/associated'
|
21
|
+
require 'matchers/associations/associations'
|
22
22
|
|
23
23
|
module Mongoid
|
24
24
|
module Matchers
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid-minitest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,44 +9,43 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-08-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: minitest
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 3.3.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 3.3.0
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: mongoid
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ~>
|
31
36
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
37
|
+
version: 3.0.2
|
33
38
|
type: :runtime
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
36
|
-
- !ruby/object:Gem::Dependency
|
37
|
-
name: bson_ext
|
38
|
-
requirement: &70336897045340 !ruby/object:Gem::Requirement
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
41
|
none: false
|
40
42
|
requirements:
|
41
43
|
- - ~>
|
42
44
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
44
|
-
type: :development
|
45
|
-
prerelease: false
|
46
|
-
version_requirements: *70336897045340
|
45
|
+
version: 3.0.2
|
47
46
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
49
|
-
requirement:
|
47
|
+
name: rake
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
50
49
|
none: false
|
51
50
|
requirements:
|
52
51
|
- - ! '>='
|
@@ -54,18 +53,12 @@ dependencies:
|
|
54
53
|
version: '0'
|
55
54
|
type: :development
|
56
55
|
prerelease: false
|
57
|
-
version_requirements:
|
58
|
-
- !ruby/object:Gem::Dependency
|
59
|
-
name: rake
|
60
|
-
requirement: &70336897043900 !ruby/object:Gem::Requirement
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
61
57
|
none: false
|
62
58
|
requirements:
|
63
|
-
- -
|
59
|
+
- - ! '>='
|
64
60
|
- !ruby/object:Gem::Version
|
65
|
-
version: 0
|
66
|
-
type: :development
|
67
|
-
prerelease: false
|
68
|
-
version_requirements: *70336897043900
|
61
|
+
version: '0'
|
69
62
|
description: Minitest matchers for Mongoid
|
70
63
|
email:
|
71
64
|
- lrodriguezsanc@gmail.com
|
@@ -73,15 +66,6 @@ executables: []
|
|
73
66
|
extensions: []
|
74
67
|
extra_rdoc_files: []
|
75
68
|
files:
|
76
|
-
- .gitignore
|
77
|
-
- .rbenv-version
|
78
|
-
- .travis.yml
|
79
|
-
- CHANGELOG.md
|
80
|
-
- Gemfile
|
81
|
-
- Guardfile
|
82
|
-
- LICENSE
|
83
|
-
- README.md
|
84
|
-
- Rakefile
|
85
69
|
- lib/matchers/associations/associations.rb
|
86
70
|
- lib/matchers/document/be_stored_in.rb
|
87
71
|
- lib/matchers/document/document.rb
|
@@ -99,14 +83,11 @@ files:
|
|
99
83
|
- lib/matchers/validations/uniqueness.rb
|
100
84
|
- lib/matchers/validations/validations.rb
|
101
85
|
- lib/minitest/matchers.rb
|
102
|
-
- lib/mongoid-minitest.rb
|
103
86
|
- lib/mongoid-minitest/version.rb
|
104
|
-
- mongoid-minitest.
|
105
|
-
-
|
106
|
-
-
|
107
|
-
-
|
108
|
-
- test/models/models.rb
|
109
|
-
- test/test_helper.rb
|
87
|
+
- lib/mongoid-minitest.rb
|
88
|
+
- LICENSE
|
89
|
+
- README.md
|
90
|
+
- CHANGELOG.md
|
110
91
|
homepage: https://github.com/frodsan/mongoid-minitest
|
111
92
|
licenses: []
|
112
93
|
post_install_message:
|
@@ -116,9 +97,9 @@ require_paths:
|
|
116
97
|
required_ruby_version: !ruby/object:Gem::Requirement
|
117
98
|
none: false
|
118
99
|
requirements:
|
119
|
-
- -
|
100
|
+
- - '='
|
120
101
|
- !ruby/object:Gem::Version
|
121
|
-
version:
|
102
|
+
version: 1.9.3
|
122
103
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
104
|
none: false
|
124
105
|
requirements:
|
@@ -127,13 +108,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
108
|
version: '0'
|
128
109
|
requirements: []
|
129
110
|
rubyforge_project:
|
130
|
-
rubygems_version: 1.8.
|
111
|
+
rubygems_version: 1.8.23
|
131
112
|
signing_key:
|
132
113
|
specification_version: 3
|
133
114
|
summary: Minitest matchers for Mongoid
|
134
|
-
test_files:
|
135
|
-
|
136
|
-
- test/matchers/document_test.rb
|
137
|
-
- test/matchers/validations_test.rb
|
138
|
-
- test/models/models.rb
|
139
|
-
- test/test_helper.rb
|
115
|
+
test_files: []
|
116
|
+
has_rdoc:
|
data/.gitignore
DELETED
data/.rbenv-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
1.9.3-p125
|
data/.travis.yml
DELETED
data/Gemfile
DELETED
data/Guardfile
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
guard 'minitest' do
|
2
|
-
watch(%r|^test/(.*)_test\.rb|)
|
3
|
-
watch(%r|^test/test_helper\.rb|) { "test" }
|
4
|
-
watch(%r|^test/models/(.*)\.rb|) { "test" }
|
5
|
-
watch(%r|^lib/minitest/matchers\.rb|) { "test" }
|
6
|
-
watch(%r|^lib/mongoid-minitest\.rb|) { "test" }
|
7
|
-
|
8
|
-
watch(%r|^lib/matchers/helpers\.rb|) { "test" }
|
9
|
-
watch(%r|^lib/matchers/document/(.*)\.rb|) { "test/matchers/document_test.rb" }
|
10
|
-
watch(%r|^lib/matchers/validations/(.*)\.rb|) { "test/matchers/validations_test.rb" }
|
11
|
-
watch(%r|^lib/matchers/associations/(.*)\.rb|) { "test/matchers/associations_test.rb" }
|
12
|
-
end
|
data/Rakefile
DELETED
data/mongoid-minitest.gemspec
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
require File.expand_path("../lib/mongoid-minitest/version", __FILE__)
|
3
|
-
|
4
|
-
Gem::Specification.new do |gem|
|
5
|
-
gem.authors = ["Francesco Rodriguez"]
|
6
|
-
gem.email = ["lrodriguezsanc@gmail.com"]
|
7
|
-
gem.description = %q{Minitest matchers for Mongoid}
|
8
|
-
gem.summary = %q{Minitest matchers for Mongoid}
|
9
|
-
gem.homepage = "https://github.com/frodsan/mongoid-minitest"
|
10
|
-
|
11
|
-
gem.files = `git ls-files`.split($\)
|
12
|
-
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
-
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
-
gem.name = "mongoid-minitest"
|
15
|
-
gem.require_paths = ["lib"]
|
16
|
-
gem.version = Mongoid::MiniTest::VERSION
|
17
|
-
|
18
|
-
gem.add_dependency "minitest", "~> 2.12.0"
|
19
|
-
gem.add_dependency "mongoid" , "~> 2.4.7"
|
20
|
-
gem.add_development_dependency "bson_ext", "~> 1.6.1"
|
21
|
-
gem.add_development_dependency "guard-minitest"
|
22
|
-
gem.add_development_dependency "rake", "~> 0.9.2"
|
23
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
describe "Associations" do
|
4
|
-
|
5
|
-
describe Person do
|
6
|
-
subject { Person }
|
7
|
-
|
8
|
-
it { must have_many(:pets).of_type(Pet) }
|
9
|
-
it { must have_one(:account).of_type(Account) }
|
10
|
-
it { must have_and_belong_to_many(:friends).of_type(Person) }
|
11
|
-
|
12
|
-
it { must embed_one(:profile) }
|
13
|
-
it { must embed_many(:sites) }
|
14
|
-
end
|
15
|
-
|
16
|
-
describe Pet do
|
17
|
-
subject { Pet }
|
18
|
-
|
19
|
-
it { must belong_to(:person).of_type(Person) }
|
20
|
-
end
|
21
|
-
|
22
|
-
describe Account do
|
23
|
-
subject { Account }
|
24
|
-
|
25
|
-
it { must belong_to(:person).of_type(Person) }
|
26
|
-
end
|
27
|
-
|
28
|
-
describe Site do
|
29
|
-
subject { Site }
|
30
|
-
|
31
|
-
it { must embedded_in(:person) }
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
describe "Document" do
|
4
|
-
describe Person do
|
5
|
-
subject { Person }
|
6
|
-
|
7
|
-
it { must be_document }
|
8
|
-
it { must be_paranoid }
|
9
|
-
it { must be_versioned }
|
10
|
-
it { must be_timestamped }
|
11
|
-
|
12
|
-
it { must be_stored_in(:people) }
|
13
|
-
|
14
|
-
it { must have_field(:name).of_type(String).with_default_value("me") }
|
15
|
-
it { must have_fields(:name, :login).of_type(String).with_default_value("me") }
|
16
|
-
|
17
|
-
it { must have_index_for(:name) }
|
18
|
-
end
|
19
|
-
|
20
|
-
describe Pet do
|
21
|
-
subject { Pet }
|
22
|
-
|
23
|
-
it { must have_index_for(:person) }
|
24
|
-
end
|
25
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
describe "Validations" do
|
4
|
-
describe Person do
|
5
|
-
subject { Person }
|
6
|
-
|
7
|
-
it { must validate_presence_of(:name) }
|
8
|
-
it { must validate_presence_of(:role).with_message("no role") }
|
9
|
-
|
10
|
-
it { must validate_uniqueness_of(:login).case_insensitive }
|
11
|
-
it { must validate_uniqueness_of(:login).scoped_to(:site) }
|
12
|
-
|
13
|
-
it { must validate_length_of(:login).in(5..12) }
|
14
|
-
it { must validate_length_of(:login).within(5..12) }
|
15
|
-
|
16
|
-
it { must validate_length_of(:password).with_min(8) }
|
17
|
-
it { must validate_length_of(:password).with_minimum(8) }
|
18
|
-
|
19
|
-
it { must validate_length_of(:password).with_max(16) }
|
20
|
-
it { must validate_length_of(:password).with_maximum(16) }
|
21
|
-
|
22
|
-
it { must validate_format_of(:email).to_allow("foo@bar.com") }
|
23
|
-
it { must validate_format_of(:email).to_not_allow("foo_bar_com") }
|
24
|
-
|
25
|
-
it { must validate_inclusion_of(:role).to_allow("user", "admin") }
|
26
|
-
it { must validate_exclusion_of(:email).to_not_allow("foo@bar.com", "fizz@buzz.com") }
|
27
|
-
|
28
|
-
it { must validate_confirmation_of(:password) }
|
29
|
-
it { must validate_acceptance_of(:terms_of_use).accept_with("1") }
|
30
|
-
|
31
|
-
it { must validate_associated(:pets) }
|
32
|
-
end
|
33
|
-
end
|
data/test/models/models.rb
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
class Person
|
2
|
-
include Mongoid::Document
|
3
|
-
include Mongoid::Paranoia
|
4
|
-
include Mongoid::Versioning
|
5
|
-
include Mongoid::Timestamps
|
6
|
-
|
7
|
-
field :login, type: String, default: "me"
|
8
|
-
field :password, type: String
|
9
|
-
field :name, type: String, default: "me"
|
10
|
-
field :age, type: Integer
|
11
|
-
field :email, type: String
|
12
|
-
field :role, type: String
|
13
|
-
field :site, type: String
|
14
|
-
|
15
|
-
index :name
|
16
|
-
|
17
|
-
has_one :account
|
18
|
-
has_many :pets
|
19
|
-
has_and_belongs_to_many :friends, class_name: "Person"
|
20
|
-
|
21
|
-
embeds_one :profile
|
22
|
-
embeds_many :sites
|
23
|
-
|
24
|
-
validates_presence_of(:name)
|
25
|
-
validates_presence_of(:role, message: "no role")
|
26
|
-
|
27
|
-
validates_confirmation_of(:password)
|
28
|
-
validates_acceptance_of(:terms_of_use)
|
29
|
-
|
30
|
-
validates_uniqueness_of(:email)
|
31
|
-
validates_uniqueness_of(:login, scope: :site, case_sensitive: false)
|
32
|
-
|
33
|
-
validates_length_of(:password, minimum: 8, maximum: 16)
|
34
|
-
validates_length_of(:login, in: 5..12)
|
35
|
-
|
36
|
-
validates_format_of(:email, with: /^([^\s]+)((?:[-a-z0-9]\.)[a-z]{2,})$/i)
|
37
|
-
|
38
|
-
validates_inclusion_of(:role, in: ["admin", "user"])
|
39
|
-
validates_exclusion_of(:email, in: ["foo@bar.com", "fizz@buzz.com"])
|
40
|
-
end
|
41
|
-
|
42
|
-
class Pet
|
43
|
-
include Mongoid::Document
|
44
|
-
|
45
|
-
belongs_to :person, index: :true
|
46
|
-
end
|
47
|
-
|
48
|
-
class Account
|
49
|
-
include Mongoid::Document
|
50
|
-
|
51
|
-
belongs_to :person
|
52
|
-
end
|
53
|
-
|
54
|
-
class Profile
|
55
|
-
include Mongoid::Document
|
56
|
-
end
|
57
|
-
|
58
|
-
class Site
|
59
|
-
include Mongoid::Document
|
60
|
-
|
61
|
-
embedded_in :person
|
62
|
-
end
|
data/test/test_helper.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
require "mongoid-minitest"
|
2
|
-
require "minitest/autorun"
|
3
|
-
|
4
|
-
Dir[File.dirname(__FILE__) + "/models/*.rb"].each { |f| require f }
|
5
|
-
|
6
|
-
Mongoid.configure do |config|
|
7
|
-
config.master = Mongo::Connection.new.db("mongoid-minitest-test")
|
8
|
-
end
|
9
|
-
|
10
|
-
class MiniTest::Spec
|
11
|
-
include Mongoid::Matchers
|
12
|
-
end
|