mongoid-minitest 1.1.0 → 1.2.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.
- checksums.yaml +5 -5
- data/.travis.yml +11 -2
- data/CHANGELOG.md +5 -0
- data/README.md +105 -77
- data/gemfiles/mongoid-5.1.gemfile +4 -0
- data/gemfiles/mongoid-6.0.gemfile +4 -0
- data/gemfiles/mongoid-7.0.gemfile +4 -0
- data/lib/matchers/associations/associations.rb +24 -8
- data/lib/mongoid-minitest.rb +2 -0
- data/mongoid-minitest.gemspec +3 -2
- metadata +26 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7e7d151bd415a03266cbd23f7f5759a55ebefd293ecab15ee4e986399cb93455
|
4
|
+
data.tar.gz: 0a4500ab217b2401de3991867bede83fa7fd8508946f875b505e4f36512747e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5c5a35743a6ec3a5ade509f1b2857439f469c043bda289365b4a5c3cbde07b0b7d4c499d1f80e42180697e603015289d95611d4127a01e67a11ddcdebad2c05
|
7
|
+
data.tar.gz: 9ebebf9424cd8d7d6d1f27e83570cb538b856a1433f5619f908c411cb7b836e904cc7e44adbe3deecd70c09d13470fb2144e0d825f4c1c68c1af30c2ba7d9a52
|
data/.travis.yml
CHANGED
@@ -2,15 +2,24 @@ language: ruby
|
|
2
2
|
rvm:
|
3
3
|
- 2.1
|
4
4
|
- 2.2
|
5
|
-
-
|
5
|
+
- 2.3
|
6
|
+
- 2.5
|
6
7
|
- jruby-19mode
|
7
8
|
gemfile:
|
8
9
|
- gemfiles/mongoid-3.1.gemfile
|
9
10
|
- gemfiles/mongoid-4.0.gemfile
|
11
|
+
- gemfiles/mongoid-5.1.gemfile
|
12
|
+
- gemfiles/mongoid-6.0.gemfile
|
13
|
+
- gemfiles/mongoid-7.0.gemfile
|
10
14
|
- gemfiles/edge.gemfile
|
11
15
|
- Gemfile
|
12
16
|
|
13
17
|
matrix:
|
14
18
|
allow_failures:
|
15
19
|
- gemfile: gemfiles/edge.gemfile
|
16
|
-
fast_finish: true
|
20
|
+
fast_finish: true
|
21
|
+
exclude:
|
22
|
+
- rvm: 2.1
|
23
|
+
gemfile: gemfiles/mongoid-6.0.gemfile
|
24
|
+
- rvm: 2.1
|
25
|
+
gemfile: gemfiles/mongoid-7.0.gemfile
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -5,8 +5,7 @@ MiniTest matchers for Mongoid.
|
|
5
5
|
|
6
6
|
[](https://rubygems.org/gems/mongoid-minitest)
|
7
7
|
[](http://travis-ci.org/frodsan/mongoid-minitest)
|
8
|
-
[](https://codeclimate.com/github/frodsan/mongoid-minitest)
|
8
|
+
[](https://codeclimate.com/github/frodsan/mongoid-minitest/maintainability)
|
10
9
|
|
11
10
|
Support
|
12
11
|
-------
|
@@ -24,7 +23,22 @@ Installation
|
|
24
23
|
|
25
24
|
Add this line to your application's Gemfile:
|
26
25
|
|
27
|
-
|
26
|
+
```ruby
|
27
|
+
gem 'mongoid-minitest', group: :test
|
28
|
+
```
|
29
|
+
|
30
|
+
Depend on either
|
31
|
+
[`minitest-matchers`](https://github.com/wojtekmach/minitest-matchers) or
|
32
|
+
[`minitest-matchers_vaccine`](https://github.com/rmm5t/minitest-matchers_vaccine)
|
33
|
+
by adding one to your application's Gemfile.
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
gem 'minitest-matchers', group: :test
|
37
|
+
|
38
|
+
# - OR - #
|
39
|
+
|
40
|
+
gem 'minitest-matchers_vaccine', group: :test
|
41
|
+
```
|
28
42
|
|
29
43
|
And then execute:
|
30
44
|
|
@@ -40,117 +54,131 @@ Usage
|
|
40
54
|
Require `mongoid-minitest` in your `test_helper.rb` or
|
41
55
|
`spec_helper.rb` file:
|
42
56
|
|
43
|
-
|
44
|
-
|
45
|
-
|
57
|
+
```ruby
|
58
|
+
require 'minitest/autorun'
|
59
|
+
require 'mongoid'
|
60
|
+
require 'mongoid-minitest'
|
61
|
+
```
|
46
62
|
|
47
63
|
Matchers are available at `Mongoid::Matchers` module.
|
48
64
|
Setup matchers according to your testing preference:
|
49
65
|
|
50
66
|
### minitest/unit
|
51
67
|
|
52
|
-
|
53
|
-
|
54
|
-
|
68
|
+
```ruby
|
69
|
+
class MiniTest::Unit::TestCase
|
70
|
+
include Mongoid::Matchers
|
71
|
+
end
|
72
|
+
```
|
55
73
|
|
56
74
|
### minitest/spec
|
57
75
|
|
58
|
-
|
59
|
-
|
60
|
-
|
76
|
+
```ruby
|
77
|
+
class MiniTest::Spec
|
78
|
+
include Mongoid::Matchers
|
79
|
+
end
|
80
|
+
```
|
61
81
|
|
62
82
|
See the following examples:
|
63
83
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
84
|
+
```ruby
|
85
|
+
# minitest/unit
|
86
|
+
class DummyTest < MiniTest::Unit::TestCase
|
87
|
+
def test_matchers
|
88
|
+
assert_must Dummy, have_field(:name)
|
89
|
+
assert_wont Dummy, have_field(:none)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
# minitest/spec
|
94
|
+
describe Dummy
|
95
|
+
it "should test matchers" do
|
96
|
+
Dummy.must have_field(:name)
|
97
|
+
Dummy.wont have_field(:none)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
# minitest/spec with subject
|
102
|
+
describe Dummy
|
103
|
+
it { must have_field(:name) }
|
104
|
+
it { wont have_field(:none) }
|
105
|
+
end
|
106
|
+
```
|
85
107
|
|
86
108
|
Matchers
|
87
109
|
--------
|
88
110
|
|
89
111
|
`Mongoid::Matchers` include the following modules:
|
90
112
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
113
|
+
```ruby
|
114
|
+
Module Mongoid
|
115
|
+
Module Matchers
|
116
|
+
include Document
|
117
|
+
include Associations
|
118
|
+
include MiniTest::Matchers::ActiveModel
|
119
|
+
end
|
120
|
+
end
|
121
|
+
```
|
98
122
|
|
99
123
|
**NOTE:** [minitest-activemodel](https://github.com/frodsan/minitest-activemodel)
|
100
124
|
gem is a dependency of this gem.
|
101
125
|
|
102
126
|
### Document Matchers
|
103
127
|
|
104
|
-
|
105
|
-
|
128
|
+
```ruby
|
129
|
+
describe Mongoid::Matchers::Document do
|
130
|
+
subject { Person }
|
106
131
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
132
|
+
it { must be_document } # if model includes Mongoid::Document
|
133
|
+
it { must be_paranoid } # if model includes Mongoid::Paranoia (Only in Mongoid <= 4.0.0)
|
134
|
+
it { must be_versioned } # if model includes Mongoid::Versioning (Only in Mongoid <= 4.0.0)
|
135
|
+
it { must be_timestamped } # if model includes Mongoid::Timestamps
|
111
136
|
|
112
|
-
|
137
|
+
it { must be_stored_in(:people) } # checks the collection for model's document
|
113
138
|
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
139
|
+
it { must have_field(:name) }
|
140
|
+
it { must have_field(:name).of_type(String) }
|
141
|
+
it { must have_field(:name).with_default_value("me") }
|
142
|
+
it { must have_field(:name).of_type(String).with_default_value("me") }
|
118
143
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
144
|
+
it { must have_fields(:name, :login) }
|
145
|
+
it { must have_fields(:name, :login).of_type(String) }
|
146
|
+
it { must have_fields(:name, :login).with_default_value("me") }
|
147
|
+
it { must have_fields(:name, :login).of_type(String).with_default_value("me") }
|
123
148
|
|
124
|
-
|
125
|
-
|
126
|
-
|
149
|
+
it { must have_index_for(:name) }
|
150
|
+
it { must have_index_for(:account_id, :email) }
|
151
|
+
end
|
152
|
+
```
|
127
153
|
|
128
154
|
### Association Matchers
|
129
155
|
|
130
|
-
|
131
|
-
|
132
|
-
|
156
|
+
```ruby
|
157
|
+
describe Mongoid::Matchers::Associations do
|
158
|
+
describe Person do
|
159
|
+
subject { Person }
|
133
160
|
|
134
|
-
|
135
|
-
|
136
|
-
|
161
|
+
it { must have_one(:account) }
|
162
|
+
it { must have_many(:pets).of_type(Pet) }
|
163
|
+
it { must have_and_belong_to_many(:friends) }
|
137
164
|
|
138
|
-
|
139
|
-
|
140
|
-
|
165
|
+
it { must embed_one(:profile) }
|
166
|
+
it { must embed_many(:sites) }
|
167
|
+
end
|
141
168
|
|
142
|
-
|
143
|
-
|
169
|
+
describe Pet do
|
170
|
+
subject { Pet }
|
144
171
|
|
145
|
-
|
146
|
-
|
172
|
+
it { must belong_to(:person) }
|
173
|
+
end
|
147
174
|
|
148
|
-
|
149
|
-
|
175
|
+
describe Site do
|
176
|
+
subject { Site }
|
150
177
|
|
151
|
-
|
152
|
-
|
153
|
-
|
178
|
+
it { must embedded_in(:person) }
|
179
|
+
end
|
180
|
+
end
|
181
|
+
```
|
154
182
|
|
155
183
|
### Validation Matchers
|
156
184
|
|
@@ -182,5 +210,5 @@ Maintainers
|
|
182
210
|
License
|
183
211
|
-------
|
184
212
|
|
185
|
-
MIT License. Copyright 2012 Francesco Rodriguez. See [LICENSE](
|
213
|
+
MIT License. Copyright 2012 Francesco Rodriguez. See [LICENSE](LICENSE.md)
|
186
214
|
for more information.
|
@@ -1,13 +1,23 @@
|
|
1
1
|
module Mongoid
|
2
2
|
module Matchers
|
3
3
|
module Associations
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
4
|
+
if Mongoid::Compatibility::Version.mongoid7_or_newer?
|
5
|
+
HAS_ONE = Mongoid::Association::Referenced::HasOne
|
6
|
+
HAS_MANY = Mongoid::Association::Referenced::HasMany
|
7
|
+
HAS_AND_BELONGS_TO_MANY = Mongoid::Association::Referenced::HasAndBelongsToMany
|
8
|
+
BELONGS_TO = Mongoid::Association::Referenced::BelongsTo
|
9
|
+
EMBEDS_ONE = Mongoid::Association::Embedded::EmbedsOne
|
10
|
+
EMBEDS_MANY = Mongoid::Association::Embedded::EmbedsMany
|
11
|
+
EMBEDDED_IN = Mongoid::Association::Embedded::EmbeddedIn
|
12
|
+
else
|
13
|
+
HAS_ONE = Mongoid::Relations::Referenced::One
|
14
|
+
HAS_MANY = Mongoid::Relations::Referenced::Many
|
15
|
+
HAS_AND_BELONGS_TO_MANY = Mongoid::Relations::Referenced::ManyToMany
|
16
|
+
BELONGS_TO = Mongoid::Relations::Referenced::In
|
17
|
+
EMBEDS_ONE = Mongoid::Relations::Embedded::One
|
18
|
+
EMBEDS_MANY = Mongoid::Relations::Embedded::Many
|
19
|
+
EMBEDDED_IN = Mongoid::Relations::Embedded::In
|
20
|
+
end
|
11
21
|
|
12
22
|
class HaveAssociationMatcher < Matcher
|
13
23
|
def initialize name, type
|
@@ -62,7 +72,13 @@ module Mongoid
|
|
62
72
|
end
|
63
73
|
|
64
74
|
def check_association_type
|
65
|
-
if
|
75
|
+
is_failure = if Mongoid::Compatibility::Version.mongoid7_or_newer?
|
76
|
+
!@metadata.nil? && @metadata.class != @association[:type]
|
77
|
+
else
|
78
|
+
!@metadata.nil? && @metadata.relation != @association[:type]
|
79
|
+
end
|
80
|
+
|
81
|
+
if is_failure
|
66
82
|
@negative_message = association_type_failure_message
|
67
83
|
@result = false
|
68
84
|
else
|
data/lib/mongoid-minitest.rb
CHANGED
data/mongoid-minitest.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |gem|
|
4
4
|
gem.name = 'mongoid-minitest'
|
5
|
-
gem.version = '1.
|
5
|
+
gem.version = '1.2.0'
|
6
6
|
|
7
7
|
gem.authors = ['Francesco Rodriguez', 'Sascha Wessel', 'Godfrey Chan', 'Ryan McGeary']
|
8
8
|
gem.email = ['frodsan@protonmail.ch', 'godfreykfc@gmail.com', 'ryan@mcgeary.org']
|
@@ -21,8 +21,9 @@ Gem::Specification.new do |gem|
|
|
21
21
|
gem.required_ruby_version = '>= 1.9.3'
|
22
22
|
|
23
23
|
gem.add_dependency 'minitest', '~> 5.0'
|
24
|
-
gem.add_dependency 'mongoid' ,
|
24
|
+
gem.add_dependency 'mongoid' ,'>= 3', '< 8.0'
|
25
25
|
gem.add_dependency 'minitest-activemodel', '~> 1.1'
|
26
|
+
gem.add_dependency 'mongoid-compatibility'
|
26
27
|
|
27
28
|
gem.add_development_dependency 'minitest-matchers'
|
28
29
|
gem.add_development_dependency 'rake'
|
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: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Francesco Rodriguez
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2018-05-02 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: minitest
|
@@ -34,6 +34,9 @@ dependencies:
|
|
34
34
|
- - ">="
|
35
35
|
- !ruby/object:Gem::Version
|
36
36
|
version: '3'
|
37
|
+
- - "<"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '8.0'
|
37
40
|
type: :runtime
|
38
41
|
prerelease: false
|
39
42
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -41,6 +44,9 @@ dependencies:
|
|
41
44
|
- - ">="
|
42
45
|
- !ruby/object:Gem::Version
|
43
46
|
version: '3'
|
47
|
+
- - "<"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '8.0'
|
44
50
|
- !ruby/object:Gem::Dependency
|
45
51
|
name: minitest-activemodel
|
46
52
|
requirement: !ruby/object:Gem::Requirement
|
@@ -55,6 +61,20 @@ dependencies:
|
|
55
61
|
- - "~>"
|
56
62
|
- !ruby/object:Gem::Version
|
57
63
|
version: '1.1'
|
64
|
+
- !ruby/object:Gem::Dependency
|
65
|
+
name: mongoid-compatibility
|
66
|
+
requirement: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
type: :runtime
|
72
|
+
prerelease: false
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
58
78
|
- !ruby/object:Gem::Dependency
|
59
79
|
name: minitest-matchers
|
60
80
|
requirement: !ruby/object:Gem::Requirement
|
@@ -105,6 +125,9 @@ files:
|
|
105
125
|
- gemfiles/edge.gemfile
|
106
126
|
- gemfiles/mongoid-3.1.gemfile
|
107
127
|
- gemfiles/mongoid-4.0.gemfile
|
128
|
+
- gemfiles/mongoid-5.1.gemfile
|
129
|
+
- gemfiles/mongoid-6.0.gemfile
|
130
|
+
- gemfiles/mongoid-7.0.gemfile
|
108
131
|
- lib/matchers/associations/associations.rb
|
109
132
|
- lib/matchers/document/be_stored_in.rb
|
110
133
|
- lib/matchers/document/document.rb
|
@@ -138,7 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
161
|
version: '0'
|
139
162
|
requirements: []
|
140
163
|
rubyforge_project:
|
141
|
-
rubygems_version: 2.
|
164
|
+
rubygems_version: 2.7.6
|
142
165
|
signing_key:
|
143
166
|
specification_version: 4
|
144
167
|
summary: MiniTest matchers for Mongoid
|