mongoid-minitest 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 6a8515ad792ea491178ce0350b57e4f84d4325fb
4
- data.tar.gz: b9d87d463baa601969be68b7cb2d642dbc6a9e3c
2
+ SHA256:
3
+ metadata.gz: 7e7d151bd415a03266cbd23f7f5759a55ebefd293ecab15ee4e986399cb93455
4
+ data.tar.gz: 0a4500ab217b2401de3991867bede83fa7fd8508946f875b505e4f36512747e9
5
5
  SHA512:
6
- metadata.gz: 1124b1d5e81d9388b4617b985c147aaad04d5aa656d7505acc039d0b1bc4a04b90abcd06447796cc3acaab797843c46f947d73393c12ae74caf85e5d9ae55fab
7
- data.tar.gz: 08fb6f6c5fe7b4344e664f45e41e73f2d05db78b3514c12c3b000d743d31ddba37367b5c5ffd308a0527aa0b0879e91c8b623824ec366144ff230c6c35cea8a0
6
+ metadata.gz: b5c5a35743a6ec3a5ade509f1b2857439f469c043bda289365b4a5c3cbde07b0b7d4c499d1f80e42180697e603015289d95611d4127a01e67a11ddcdebad2c05
7
+ data.tar.gz: 9ebebf9424cd8d7d6d1f27e83570cb538b856a1433f5619f908c411cb7b836e904cc7e44adbe3deecd70c09d13470fb2144e0d825f4c1c68c1af30c2ba7d9a52
@@ -2,15 +2,24 @@ language: ruby
2
2
  rvm:
3
3
  - 2.1
4
4
  - 2.2
5
- - rbx-19mode
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
@@ -1,3 +1,8 @@
1
+ ## 1.2.0
2
+
3
+ + Add support for Mongoid 7
4
+ Pull Request [#24](https://github.com/frodsan/mongoid-minitest/pull/24) - *Tomáš Celizna*.
5
+
1
6
  ## 1.1.0
2
7
 
3
8
  + Upgrade to minitest 5
data/README.md CHANGED
@@ -5,8 +5,7 @@ MiniTest matchers for Mongoid.
5
5
 
6
6
  [![Gem Version](http://img.shields.io/gem/v/mongoid-minitest.svg)](https://rubygems.org/gems/mongoid-minitest)
7
7
  [![Build Status](https://travis-ci.org/frodsan/mongoid-minitest.svg?branch=master)](http://travis-ci.org/frodsan/mongoid-minitest)
8
- [![Dependency Status](http://img.shields.io/gemnasium/frodsan/mongoid-minitest.svg)](https://gemnasium.com/frodsan/mongoid-minitest)
9
- [![Code Climate](http://img.shields.io/codeclimate/github/frodsan/mongoid-minitest.svg)](https://codeclimate.com/github/frodsan/mongoid-minitest)
8
+ [![Maintainability](https://api.codeclimate.com/v1/badges/a1e122b1599009eaad18/maintainability)](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
- gem 'mongoid-minitest', group: :test
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
- require 'minitest/autorun'
44
- require 'mongoid'
45
- require 'mongoid-minitest'
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
- class MiniTest::Unit::TestCase
53
- include Mongoid::Matchers
54
- end
68
+ ```ruby
69
+ class MiniTest::Unit::TestCase
70
+ include Mongoid::Matchers
71
+ end
72
+ ```
55
73
 
56
74
  ### minitest/spec
57
75
 
58
- class MiniTest::Spec
59
- include Mongoid::Matchers
60
- end
76
+ ```ruby
77
+ class MiniTest::Spec
78
+ include Mongoid::Matchers
79
+ end
80
+ ```
61
81
 
62
82
  See the following examples:
63
83
 
64
- # minitest/unit
65
- class DummyTest < MiniTest::Unit::TestCase
66
- def test_matchers
67
- assert_must Dummy, have_field(:name)
68
- assert_wont Dummy, have_field(:none)
69
- end
70
- end
71
-
72
- # minitest/spec
73
- describe Dummy
74
- it "should test matchers" do
75
- Dummy.must have_field(:name)
76
- Dummy.wont have_field(:none)
77
- end
78
- end
79
-
80
- # minitest/spec with subject
81
- describe Dummy
82
- it { must have_field(:name) }
83
- it { wont have_field(:none) }
84
- end
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
- Module Mongoid
92
- Module Matchers
93
- include Document
94
- include Associations
95
- include MiniTest::Matchers::ActiveModel
96
- end
97
- end
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
- describe Mongoid::Matchers::Document do
105
- subject { Person }
128
+ ```ruby
129
+ describe Mongoid::Matchers::Document do
130
+ subject { Person }
106
131
 
107
- it { must be_document } # if model includes Mongoid::Document
108
- it { must be_paranoid } # if model includes Mongoid::Paranoia (Only in Mongoid <= 4.0.0)
109
- it { must be_versioned } # if model includes Mongoid::Versioning (Only in Mongoid <= 4.0.0)
110
- it { must be_timestamped } # if model includes Mongoid::Timestamps
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
- it { must be_stored_in(:people) } # checks the collection for model's document
137
+ it { must be_stored_in(:people) } # checks the collection for model's document
113
138
 
114
- it { must have_field(:name) }
115
- it { must have_field(:name).of_type(String) }
116
- it { must have_field(:name).with_default_value("me") }
117
- it { must have_field(:name).of_type(String).with_default_value("me") }
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
- it { must have_fields(:name, :login) }
120
- it { must have_fields(:name, :login).of_type(String) }
121
- it { must have_fields(:name, :login).with_default_value("me") }
122
- it { must have_fields(:name, :login).of_type(String).with_default_value("me") }
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
- it { must have_index_for(:name) }
125
- it { must have_index_for(:account_id, :email) }
126
- end
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
- describe Mongoid::Matchers::Associations do
131
- describe Person do
132
- subject { Person }
156
+ ```ruby
157
+ describe Mongoid::Matchers::Associations do
158
+ describe Person do
159
+ subject { Person }
133
160
 
134
- it { must have_one(:account) }
135
- it { must have_many(:pets).of_type(Pet) }
136
- it { must have_and_belong_to_many(:friends) }
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
- it { must embed_one(:profile) }
139
- it { must embed_many(:sites) }
140
- end
165
+ it { must embed_one(:profile) }
166
+ it { must embed_many(:sites) }
167
+ end
141
168
 
142
- describe Pet do
143
- subject { Pet }
169
+ describe Pet do
170
+ subject { Pet }
144
171
 
145
- it { must belong_to(:person) }
146
- end
172
+ it { must belong_to(:person) }
173
+ end
147
174
 
148
- describe Site do
149
- subject { Site }
175
+ describe Site do
176
+ subject { Site }
150
177
 
151
- it { must embedded_in(:person) }
152
- end
153
- end
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](https://github.com/frodsan/lego/blob/master/LICENSE)
213
+ MIT License. Copyright 2012 Francesco Rodriguez. See [LICENSE](LICENSE.md)
186
214
  for more information.
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec path: "../"
4
+ gem 'mongoid', '~> 5.1'
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec path: "../"
4
+ gem 'mongoid', '~> 6.0'
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec path: "../"
4
+ gem 'mongoid', '~> 7.0'
@@ -1,13 +1,23 @@
1
1
  module Mongoid
2
2
  module Matchers
3
3
  module Associations
4
- HAS_ONE = Mongoid::Relations::Referenced::One
5
- HAS_MANY = Mongoid::Relations::Referenced::Many
6
- HAS_AND_BELONGS_TO_MANY = Mongoid::Relations::Referenced::ManyToMany
7
- BELONGS_TO = Mongoid::Relations::Referenced::In
8
- EMBEDS_ONE = Mongoid::Relations::Embedded::One
9
- EMBEDS_MANY = Mongoid::Relations::Embedded::Many
10
- EMBEDDED_IN = Mongoid::Relations::Embedded::In
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 !@metadata.nil? && @metadata.relation != @association[:type]
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
@@ -1,3 +1,5 @@
1
+ require 'mongoid-compatibility'
2
+
1
3
  require 'minitest-activemodel'
2
4
  require 'matchers/matcher'
3
5
  require 'matchers/document/document'
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = 'mongoid-minitest'
5
- gem.version = '1.1.0'
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' , '>= 3'
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.1.0
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: 2015-06-08 00:00:00.000000000 Z
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.4.6
164
+ rubygems_version: 2.7.6
142
165
  signing_key:
143
166
  specification_version: 4
144
167
  summary: MiniTest matchers for Mongoid