mongoid-rspec 4.4.0 → 4.4.1
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 +4 -4
- data/README.md +24 -26
- data/Rakefile +23 -6
- data/lib/mongoid/rspec/version.rb +1 -1
- metadata +3 -17
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '0098f4dea9795cc546a9a7811196f626bf1c9d7e9dacd2d61513b928c41a364d'
|
|
4
|
+
data.tar.gz: 565dd273714ec142bfa4758e4e2c59c5e925b4c157c6c76c503dec7cf0b49753
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 79ecc75a098413aff5a13ada133e78b3a84d022ac9d3d747cce4b61648bbf732adbbe3ef1c67aa199fadd609eda7d792e22c0c91453a1f752c168e43266609cb
|
|
7
|
+
data.tar.gz: 28ea7b17e94dc470b7a5d6d27de7a84eedeabdcef2f6a710c310a6caeadb86fa6a26d2f26e222bf83d634a1f3bdedbb7dfdad8b17ba1acbd60b88849bea6cf4e
|
data/README.md
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Mongoid RSpec
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
[](https://coveralls.io/github/mongoid/mongoid-rspec?branch=master)
|
|
3
|
+
A collection of RSpec-compatible matchers that help to test Mongoid documents.
|
|
4
|
+
|
|
5
|
+
[](https://badge.fury.io/rb/mongoid-rspec) [](https://github.com/mongoid/mongoid-rspec/actions/workflows/rspec.yml?query=branch%3Amaster) [](https://github.com/mongoid/mongoid-rspec/actions/workflows/lint.yml?query=branch%3Amaster) [](https://coveralls.io/github/mongoid/mongoid-rspec?branch=master)
|
|
7
6
|
|
|
8
7
|
CI collects SimpleCov coverage on Ruby 3.4 with Mongoid 9 and MongoDB 8.0 and submits one report to Coveralls using GitHub's workflow token. To generate a local report, run `COVERAGE=true BUNDLE_GEMFILE=gemfiles/mongoid_9.gemfile bundle install` followed by `COVERAGE=true BUNDLE_GEMFILE=gemfiles/mongoid_9.gemfile bundle exec rake spec`. Reports are written to `coverage/`.
|
|
9
8
|
|
|
10
9
|
The mongoid-rspec library provides a collection of RSpec-compatible matchers that help to test Mongoid documents.
|
|
11
10
|
|
|
12
11
|
[Tested](https://github.com/mongoid/mongoid-rspec/actions/workflows/rspec.yml) against:
|
|
12
|
+
|
|
13
13
|
- MRI: `2.6.x`, `2.7.x`, `3.0.x`, `3.1.x`, `3.2.x`
|
|
14
14
|
- Mongoid: `4`, `5`, `6`, `7`, `8`, `9`
|
|
15
15
|
|
|
@@ -44,7 +44,7 @@ RSpec.configure do |config|
|
|
|
44
44
|
end
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
-
### Using Mongoid and ActiveRecord with
|
|
47
|
+
### Using Mongoid and ActiveRecord with Shoulda-Matchers
|
|
48
48
|
|
|
49
49
|
Both libraries define matcher names such as `validate_length_of` and `belong_to`, but their chain methods and implementations differ. In an application with both Mongoid and ActiveRecord models, include Mongoid matchers only for a custom `:mongoid_model` type instead of all `:model` examples. Keep Shoulda's ActiveModel and ActiveRecord matchers scoped to `:model`:
|
|
50
50
|
|
|
@@ -85,7 +85,7 @@ end
|
|
|
85
85
|
|
|
86
86
|
## Matchers
|
|
87
87
|
|
|
88
|
-
### be_mongoid_document
|
|
88
|
+
### The `be_mongoid_document` Matcher
|
|
89
89
|
|
|
90
90
|
```ruby
|
|
91
91
|
class Post
|
|
@@ -97,7 +97,7 @@ RSpec.describe Post, type: :model do
|
|
|
97
97
|
end
|
|
98
98
|
```
|
|
99
99
|
|
|
100
|
-
### be_dynamic_document
|
|
100
|
+
### The `be_dynamic_document` Matcher
|
|
101
101
|
|
|
102
102
|
```ruby
|
|
103
103
|
class User
|
|
@@ -110,7 +110,7 @@ RSpec.describe User, type: :model do
|
|
|
110
110
|
end
|
|
111
111
|
```
|
|
112
112
|
|
|
113
|
-
### have_timestamps
|
|
113
|
+
### The `have_timestamps` Matcher
|
|
114
114
|
|
|
115
115
|
With full timestamps.
|
|
116
116
|
|
|
@@ -166,7 +166,7 @@ RSpec.describe Short, type: :model do
|
|
|
166
166
|
end
|
|
167
167
|
```
|
|
168
168
|
|
|
169
|
-
### be_stored_in
|
|
169
|
+
### The `be_stored_in` Matcher
|
|
170
170
|
|
|
171
171
|
```ruby
|
|
172
172
|
class Post
|
|
@@ -200,7 +200,7 @@ It works fine with lambdas and procs.
|
|
|
200
200
|
class User
|
|
201
201
|
include Mongoid::Document
|
|
202
202
|
|
|
203
|
-
store_in database: ->{ Thread.current[:database] }
|
|
203
|
+
store_in database: -> { Thread.current[:database] }
|
|
204
204
|
end
|
|
205
205
|
|
|
206
206
|
RSpec.describe Post, type: :model do
|
|
@@ -214,7 +214,7 @@ RSpec.describe Post, type: :model do
|
|
|
214
214
|
end
|
|
215
215
|
```
|
|
216
216
|
|
|
217
|
-
### have_index_for
|
|
217
|
+
### The `have_index_for` Matcher
|
|
218
218
|
|
|
219
219
|
```ruby
|
|
220
220
|
class Article
|
|
@@ -234,7 +234,7 @@ RSpec.describe Article, type: :model do
|
|
|
234
234
|
end
|
|
235
235
|
```
|
|
236
236
|
|
|
237
|
-
### execute_mongodb_command
|
|
237
|
+
### The `execute_mongodb_command` Matcher
|
|
238
238
|
|
|
239
239
|
Use `execute_mongodb_command` with a block expectation to verify that code issues a MongoDB command. Without an argument, the matcher passes when any command is issued on the block's thread. An expected command matches the entire application command document exactly, not just a subset or query selector; nested String and Symbol keys are normalized to Strings. Driver-added top-level `$db`, `lsid`, and `$clusterTime` fields are excluded from comparison, while all other command fields and values must match. The matcher ignores unrelated background-thread activity and raises `NotImplementedError` when the driver does not expose command monitoring, including the legacy driver used with Mongoid 4.
|
|
240
240
|
|
|
@@ -261,7 +261,7 @@ RSpec.describe Article do
|
|
|
261
261
|
end
|
|
262
262
|
```
|
|
263
263
|
|
|
264
|
-
### be_covered_query
|
|
264
|
+
### The `be_covered_query` Matcher
|
|
265
265
|
|
|
266
266
|
Check that MongoDB's winning plan uses an index without fetching documents:
|
|
267
267
|
|
|
@@ -392,7 +392,7 @@ describe Comment do
|
|
|
392
392
|
end
|
|
393
393
|
|
|
394
394
|
describe Permalink do
|
|
395
|
-
it { is_expected.to be_embedded_in(:linkable).as_inverse_of(:link).with_touch(false) }
|
|
395
|
+
it { is_expected.to be_embedded_in(:linkable).as_inverse_of(:link).with_touch(false) }
|
|
396
396
|
end
|
|
397
397
|
|
|
398
398
|
# touch can also take a symbol representing a field on the parent to touch
|
|
@@ -433,18 +433,18 @@ end
|
|
|
433
433
|
RSpec.describe User do
|
|
434
434
|
it { is_expected.to validate_presence_of(:login) }
|
|
435
435
|
it { is_expected.to validate_uniqueness_of(:login).scoped_to(:site) }
|
|
436
|
-
it { is_expected.to validate_uniqueness_of(:email).case_insensitive.with_message(
|
|
437
|
-
it { is_expected.to validate_format_of(:login).to_allow(
|
|
436
|
+
it { is_expected.to validate_uniqueness_of(:email).case_insensitive.with_message('is already taken') }
|
|
437
|
+
it { is_expected.to validate_format_of(:login).to_allow('valid_login').not_to_allow('invalid login') }
|
|
438
438
|
it { is_expected.to validate_associated(:profile) }
|
|
439
|
-
it { is_expected.to validate_exclusion_of(:login).to_not_allow(
|
|
440
|
-
it { is_expected.to validate_inclusion_of(:role).to_allow(
|
|
439
|
+
it { is_expected.to validate_exclusion_of(:login).to_not_allow('super', 'index', 'edit') }
|
|
440
|
+
it { is_expected.to validate_inclusion_of(:role).to_allow('admin', 'member') }
|
|
441
441
|
it { is_expected.to validate_confirmation_of(:email) }
|
|
442
442
|
it { is_expected.to validate_presence_of(:age).on(:create, :update) }
|
|
443
443
|
it { is_expected.to validate_numericality_of(:age).on(:create, :update) }
|
|
444
|
-
it { is_expected.to validate_inclusion_of(:age).to_allow(23..42).on([
|
|
444
|
+
it { is_expected.to validate_inclusion_of(:age).to_allow(23..42).on(%i[create update]) }
|
|
445
445
|
it { is_expected.to validate_presence_of(:password).on(:create) }
|
|
446
446
|
it { is_expected.to validate_presence_of(:provider_uid).on(:create) }
|
|
447
|
-
it { is_expected.to validate_inclusion_of(:locale).to_allow([
|
|
447
|
+
it { is_expected.to validate_inclusion_of(:locale).to_allow(%i[en ru]) }
|
|
448
448
|
end
|
|
449
449
|
|
|
450
450
|
RSpec.describe Article do
|
|
@@ -461,8 +461,8 @@ RSpec.describe Profile do
|
|
|
461
461
|
end
|
|
462
462
|
|
|
463
463
|
RSpec.describe MovieArticle do
|
|
464
|
-
it { is_expected.to validate_numericality_of(:rating).to_allow(:
|
|
465
|
-
it { is_expected.to validate_numericality_of(:classification).to_allow(:
|
|
464
|
+
it { is_expected.to validate_numericality_of(:rating).to_allow(greater_than: 0).less_than_or_equal_to(5) }
|
|
465
|
+
it { is_expected.to validate_numericality_of(:classification).to_allow(even: true, only_integer: true, nil: false) }
|
|
466
466
|
end
|
|
467
467
|
|
|
468
468
|
RSpec.describe Person do
|
|
@@ -518,9 +518,7 @@ end
|
|
|
518
518
|
|
|
519
519
|
## Contributing
|
|
520
520
|
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
`bundle exec rake` runs the unit suite without third-party integration dependencies. Each integration has its own Appraisal bundle and directory under `spec/integration/`. For example, run `BUNDLE_GEMFILE=gemfiles/shoulda_matchers.gemfile bundle install`, then `BUNDLE_GEMFILE=gemfiles/shoulda_matchers.gemfile bundle exec rspec spec/integration/shoulda_matchers`. To add an integration, define its dependencies in Appraisals, generate its gemfile, add its specs under a matching directory, and add its name to the integration matrix in `.github/workflows/rspec.yml`. CI runs each listed integration in a separate process and bundle.
|
|
521
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md), [CHANGELOG.md](CHANGELOG.md), and [RELEASING.md](RELEASING.md).
|
|
524
522
|
|
|
525
523
|
## Copyright and License
|
|
526
524
|
|
data/Rakefile
CHANGED
|
@@ -1,19 +1,36 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
$LOAD_PATH.push File.expand_path('
|
|
3
|
+
$LOAD_PATH.push File.expand_path('lib', __dir__)
|
|
4
4
|
|
|
5
5
|
require 'bundler'
|
|
6
6
|
Bundler::GemHelper.install_tasks
|
|
7
7
|
|
|
8
|
+
if RUBY_ENGINE == 'ruby' && Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.3') &&
|
|
9
|
+
Gem.loaded_specs.key?('ruby-gem-release')
|
|
10
|
+
require_relative 'script/release'
|
|
11
|
+
MongoidRSpecRelease.workflow.install_tasks
|
|
12
|
+
|
|
13
|
+
%w[release release:rubygem_push release:source_control_push].each do |name|
|
|
14
|
+
Rake::Task[name].clear
|
|
15
|
+
desc 'Disabled; releases run through GitHub Actions, see RELEASING.md'
|
|
16
|
+
task(name) { abort "#{name} is disabled; releases run through GitHub Actions, see RELEASING.md" }
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
8
20
|
require 'rspec/core/rake_task'
|
|
9
21
|
|
|
10
22
|
RSpec::Core::RakeTask.new(:spec) do |spec|
|
|
11
|
-
spec.pattern = './spec/unit/**/*_spec.rb'
|
|
23
|
+
spec.pattern = FileList['./spec/unit/**/*_spec.rb', './spec/release/**/*_spec.rb']
|
|
12
24
|
end
|
|
13
25
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
26
|
+
lint = RUBY_ENGINE == 'ruby' && Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.3') &&
|
|
27
|
+
Gem.loaded_specs.key?('rubocop')
|
|
28
|
+
if lint
|
|
29
|
+
require 'rubocop/rake_task'
|
|
30
|
+
RuboCop::RakeTask.new(:rubocop)
|
|
31
|
+
|
|
32
|
+
desc 'Lint Ruby, Markdown, YAML, and spelling'
|
|
33
|
+
task lint: :rubocop
|
|
17
34
|
end
|
|
18
35
|
|
|
19
|
-
task default: %i[spec]
|
|
36
|
+
task default: lint ? %i[rubocop spec] : %i[spec]
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mongoid-rspec
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.4.
|
|
4
|
+
version: 4.4.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Evan Sagge
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2026-
|
|
12
|
+
date: 2026-11-24 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: appraisal
|
|
@@ -81,20 +81,6 @@ dependencies:
|
|
|
81
81
|
- - ">="
|
|
82
82
|
- !ruby/object:Gem::Version
|
|
83
83
|
version: '0'
|
|
84
|
-
- !ruby/object:Gem::Dependency
|
|
85
|
-
name: rubocop
|
|
86
|
-
requirement: !ruby/object:Gem::Requirement
|
|
87
|
-
requirements:
|
|
88
|
-
- - "~>"
|
|
89
|
-
- !ruby/object:Gem::Version
|
|
90
|
-
version: 1.36.0
|
|
91
|
-
type: :development
|
|
92
|
-
prerelease: false
|
|
93
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
94
|
-
requirements:
|
|
95
|
-
- - "~>"
|
|
96
|
-
- !ruby/object:Gem::Version
|
|
97
|
-
version: 1.36.0
|
|
98
84
|
- !ruby/object:Gem::Dependency
|
|
99
85
|
name: mongoid
|
|
100
86
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -188,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
188
174
|
- !ruby/object:Gem::Version
|
|
189
175
|
version: 1.3.6
|
|
190
176
|
requirements: []
|
|
191
|
-
rubygems_version: 3.5.
|
|
177
|
+
rubygems_version: 3.5.22
|
|
192
178
|
signing_key:
|
|
193
179
|
specification_version: 4
|
|
194
180
|
summary: RSpec matchers for Mongoid
|