mongoid-rspec 1.9.0 → 1.11.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 +7 -0
- data/.gitignore +2 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +8 -3
- data/README.md +2 -2
- data/lib/matchers/associations.rb +3 -9
- data/lib/matchers/indexes.rb +14 -2
- data/lib/mongoid-rspec/version.rb +1 -1
- data/lib/mongoid-rspec.rb +3 -1
- data/mongoid-rspec.gemspec +1 -1
- data/spec/models/article.rb +1 -1
- data/spec/unit/associations_spec.rb +1 -1
- data/spec/unit/indexes_spec.rb +1 -1
- metadata +21 -34
- data/.rvmrc +0 -1
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 90683af43b99f047532aad535c6e43dd6967f95d
|
|
4
|
+
data.tar.gz: 6dc40541b28ba2944e2a28e1db7aac2a1d8f986f
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 4600c194356594e38e1ce975412e3a64ae740deaef458adc1f069936254bc2b85c59fffbee44ee6272197affab3a998e8bf76f4d2f62eab7715cdca68e58cb74
|
|
7
|
+
data.tar.gz: fbd39276f0ae7b8bf388c488df939ce343bbeaa25377b79094ff24b8593590e402549681e1290ba857d5a318d4675ca1e7ed3abe449c1cad20c4cd5b5d005350
|
data/.gitignore
CHANGED
data/.ruby-gemset
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
mongoid-rspec
|
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ruby-2.1.0
|
data/.travis.yml
CHANGED
|
@@ -2,11 +2,16 @@ language: ruby
|
|
|
2
2
|
rvm:
|
|
3
3
|
- 1.9.3
|
|
4
4
|
- 2.0.0
|
|
5
|
+
- 2.1.0
|
|
5
6
|
- ruby-head
|
|
7
|
+
- jruby-18mode
|
|
6
8
|
- jruby-19mode
|
|
7
|
-
-
|
|
9
|
+
- jruby-head
|
|
10
|
+
- rbx-2.1.1
|
|
11
|
+
- rbx-head
|
|
12
|
+
- ree
|
|
8
13
|
matrix:
|
|
9
14
|
allow_failures:
|
|
10
15
|
- rvm: ruby-head
|
|
11
|
-
- rvm: jruby-
|
|
12
|
-
- rvm: rbx-
|
|
16
|
+
- rvm: jruby-head
|
|
17
|
+
- rvm: rbx-head
|
data/README.md
CHANGED
|
@@ -18,8 +18,8 @@ Add to your Gemfile
|
|
|
18
18
|
Drop in existing or dedicated support file in spec/support (spec/support/mongoid.rb)
|
|
19
19
|
|
|
20
20
|
```ruby
|
|
21
|
-
RSpec.configure do |
|
|
22
|
-
|
|
21
|
+
RSpec.configure do |config|
|
|
22
|
+
config.include Mongoid::Matchers, type: :model
|
|
23
23
|
end
|
|
24
24
|
```
|
|
25
25
|
|
|
@@ -12,16 +12,11 @@ module Mongoid
|
|
|
12
12
|
EMBEDS_ONE = Mongoid::Relations::Embedded::One
|
|
13
13
|
EMBEDDED_IN = Mongoid::Relations::Embedded::In
|
|
14
14
|
|
|
15
|
-
|
|
16
15
|
class HaveAssociationMatcher
|
|
17
16
|
def initialize(name, association_type)
|
|
18
17
|
@association = {}
|
|
19
18
|
@association[:name] = name.to_s
|
|
20
19
|
@association[:type] = association_type
|
|
21
|
-
# begin
|
|
22
|
-
# @association[:class] = name.to_s.classify.constantize
|
|
23
|
-
# rescue
|
|
24
|
-
# end
|
|
25
20
|
@expectation_message = "#{type_description} #{@association[:name].inspect}"
|
|
26
21
|
@expectation_message << " of type #{@association[:class].inspect}" unless @association[:class].nil?
|
|
27
22
|
end
|
|
@@ -278,10 +273,9 @@ module Mongoid
|
|
|
278
273
|
end
|
|
279
274
|
|
|
280
275
|
private
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
end
|
|
276
|
+
def order_way(operator)
|
|
277
|
+
[nil, "ascending", "descending"][operator]
|
|
278
|
+
end
|
|
285
279
|
end
|
|
286
280
|
|
|
287
281
|
def embed_one(association_name)
|
data/lib/matchers/indexes.rb
CHANGED
|
@@ -13,13 +13,12 @@ module Mongoid
|
|
|
13
13
|
def matches?(klass)
|
|
14
14
|
@klass = klass.is_a?(Class) ? klass : klass.class
|
|
15
15
|
@errors = []
|
|
16
|
-
|
|
17
16
|
unless @klass.index_options[@index_fields]
|
|
18
17
|
@errors.push "no index for #{@index_fields}"
|
|
19
18
|
else
|
|
20
19
|
if !@options.nil? && !@options.empty?
|
|
21
20
|
@options.each do |option, option_value|
|
|
22
|
-
if @klass.index_options[@index_fields][option] != option_value
|
|
21
|
+
if denormalising_options(@klass.index_options[@index_fields])[option] != option_value
|
|
23
22
|
@errors.push "index for #{@index_fields.inspect} with options of #{@klass.index_options[@index_fields].inspect}"
|
|
24
23
|
end
|
|
25
24
|
end
|
|
@@ -42,6 +41,19 @@ module Mongoid
|
|
|
42
41
|
desc << " with options of #{@options.inspect}" if @options
|
|
43
42
|
desc
|
|
44
43
|
end
|
|
44
|
+
|
|
45
|
+
private
|
|
46
|
+
MAPPINGS = {
|
|
47
|
+
dropDups: :drop_dups
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
def denormalising_options(opts)
|
|
51
|
+
options = {}
|
|
52
|
+
opts.each_pair do |option, value|
|
|
53
|
+
options[MAPPINGS[option] || option] = value
|
|
54
|
+
end
|
|
55
|
+
options
|
|
56
|
+
end
|
|
45
57
|
end
|
|
46
58
|
|
|
47
59
|
def have_index_for(index_fields)
|
data/lib/mongoid-rspec.rb
CHANGED
data/mongoid-rspec.gemspec
CHANGED
data/spec/models/article.rb
CHANGED
|
@@ -24,7 +24,7 @@ class Article
|
|
|
24
24
|
validates_length_of :title, within: 8..16
|
|
25
25
|
validates_length_of :content, minimum: 200
|
|
26
26
|
|
|
27
|
-
index({ title: 1 }, { unique: true, background: true })
|
|
27
|
+
index({ title: 1 }, { unique: true, background: true, drop_dups: true })
|
|
28
28
|
index({ published: 1 })
|
|
29
29
|
index({ 'permalink._id' => 1 })
|
|
30
30
|
|
data/spec/unit/indexes_spec.rb
CHANGED
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
|
3
3
|
describe "Indexes" do
|
|
4
4
|
describe Article do
|
|
5
5
|
it { should have_index_for(published: 1) }
|
|
6
|
-
it { should have_index_for(title: 1).with_options(unique: true, background: true) }
|
|
6
|
+
it { should have_index_for(title: 1).with_options(unique: true, background: true, drop_dups: true) }
|
|
7
7
|
it { should have_index_for('permalink._id' => 1) }
|
|
8
8
|
end
|
|
9
9
|
|
metadata
CHANGED
|
@@ -1,62 +1,55 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mongoid-rspec
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
5
|
-
prerelease:
|
|
4
|
+
version: 1.11.0
|
|
6
5
|
platform: ruby
|
|
7
6
|
authors:
|
|
8
7
|
- Evan Sagge
|
|
9
8
|
autorequire:
|
|
10
9
|
bindir: bin
|
|
11
10
|
cert_chain: []
|
|
12
|
-
date:
|
|
11
|
+
date: 2014-02-15 00:00:00.000000000 Z
|
|
13
12
|
dependencies:
|
|
14
13
|
- !ruby/object:Gem::Dependency
|
|
15
14
|
name: rake
|
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
|
17
|
-
none: false
|
|
18
16
|
requirements:
|
|
19
|
-
- -
|
|
17
|
+
- - ">="
|
|
20
18
|
- !ruby/object:Gem::Version
|
|
21
19
|
version: '0'
|
|
22
20
|
type: :runtime
|
|
23
21
|
prerelease: false
|
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
-
none: false
|
|
26
23
|
requirements:
|
|
27
|
-
- -
|
|
24
|
+
- - ">="
|
|
28
25
|
- !ruby/object:Gem::Version
|
|
29
26
|
version: '0'
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
|
31
28
|
name: mongoid
|
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
|
33
|
-
none: false
|
|
34
30
|
requirements:
|
|
35
|
-
- -
|
|
31
|
+
- - "~>"
|
|
36
32
|
- !ruby/object:Gem::Version
|
|
37
|
-
version: 3.
|
|
33
|
+
version: 3.1.6
|
|
38
34
|
type: :runtime
|
|
39
35
|
prerelease: false
|
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
41
|
-
none: false
|
|
42
37
|
requirements:
|
|
43
|
-
- -
|
|
38
|
+
- - "~>"
|
|
44
39
|
- !ruby/object:Gem::Version
|
|
45
|
-
version: 3.
|
|
40
|
+
version: 3.1.6
|
|
46
41
|
- !ruby/object:Gem::Dependency
|
|
47
42
|
name: rspec
|
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
|
49
|
-
none: false
|
|
50
44
|
requirements:
|
|
51
|
-
- -
|
|
45
|
+
- - ">="
|
|
52
46
|
- !ruby/object:Gem::Version
|
|
53
47
|
version: '2.14'
|
|
54
48
|
type: :runtime
|
|
55
49
|
prerelease: false
|
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
57
|
-
none: false
|
|
58
51
|
requirements:
|
|
59
|
-
- -
|
|
52
|
+
- - ">="
|
|
60
53
|
- !ruby/object:Gem::Version
|
|
61
54
|
version: '2.14'
|
|
62
55
|
description: RSpec matches for Mongoid models, including association and validation
|
|
@@ -66,11 +59,12 @@ executables: []
|
|
|
66
59
|
extensions: []
|
|
67
60
|
extra_rdoc_files: []
|
|
68
61
|
files:
|
|
69
|
-
- .bundle/config
|
|
70
|
-
- .document
|
|
71
|
-
- .gitignore
|
|
72
|
-
- .
|
|
73
|
-
- .
|
|
62
|
+
- ".bundle/config"
|
|
63
|
+
- ".document"
|
|
64
|
+
- ".gitignore"
|
|
65
|
+
- ".ruby-gemset"
|
|
66
|
+
- ".ruby-version"
|
|
67
|
+
- ".travis.yml"
|
|
74
68
|
- Gemfile
|
|
75
69
|
- LICENSE
|
|
76
70
|
- README.md
|
|
@@ -118,33 +112,26 @@ files:
|
|
|
118
112
|
- spec/validators/ssn_validator.rb
|
|
119
113
|
homepage: http://github.com/evansagge/mongoid-rspec
|
|
120
114
|
licenses: []
|
|
115
|
+
metadata: {}
|
|
121
116
|
post_install_message:
|
|
122
117
|
rdoc_options: []
|
|
123
118
|
require_paths:
|
|
124
119
|
- lib
|
|
125
120
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
126
|
-
none: false
|
|
127
121
|
requirements:
|
|
128
|
-
- -
|
|
122
|
+
- - ">="
|
|
129
123
|
- !ruby/object:Gem::Version
|
|
130
124
|
version: '0'
|
|
131
|
-
segments:
|
|
132
|
-
- 0
|
|
133
|
-
hash: 2533253103994848490
|
|
134
125
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
|
-
none: false
|
|
136
126
|
requirements:
|
|
137
|
-
- -
|
|
127
|
+
- - ">="
|
|
138
128
|
- !ruby/object:Gem::Version
|
|
139
129
|
version: '0'
|
|
140
|
-
segments:
|
|
141
|
-
- 0
|
|
142
|
-
hash: 2533253103994848490
|
|
143
130
|
requirements: []
|
|
144
131
|
rubyforge_project: mongoid-rspec
|
|
145
|
-
rubygems_version:
|
|
132
|
+
rubygems_version: 2.2.2
|
|
146
133
|
signing_key:
|
|
147
|
-
specification_version:
|
|
134
|
+
specification_version: 4
|
|
148
135
|
summary: RSpec matchers for Mongoid
|
|
149
136
|
test_files:
|
|
150
137
|
- spec/models/article.rb
|
data/.rvmrc
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
rvm use --create 1.9.3@mongoid-rspec
|