mongoid-rspec 1.13.0 → 2.0.0.rc1

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
2
  SHA1:
3
- metadata.gz: 9a4c1a2239f0fe2d5fa2e91f8c33d3e481700810
4
- data.tar.gz: 8c6e6f83f5a1d01d5ee9820fb56e76913f568dbd
3
+ metadata.gz: 5bdc2a27713108ecf952f448fa9c81049b2f443f
4
+ data.tar.gz: 2c20f5c24c8b6832ff2dd28abd64f91cd84d5840
5
5
  SHA512:
6
- metadata.gz: 51b893ad1bf9837b1c7e5183cd4033be0397953b90169852cdad26a26388b60e193d834bc035eb274ef4c6434a02c4f2c75e8eee72534fb88cc53b035465edc2
7
- data.tar.gz: 8d35fbfdb8b35e44050330f06fa00e98cb3670a1fe444159d12e182f1f50efdc11616de71d0685dc49d6a128104964ed9c08d08d8e71a2a0653c641e1ded6c97
6
+ metadata.gz: a536ed5c7c52ad02421c10e8eeaa125f3fd4cb3278569cc2ddea90e429756a948cb1d9bf8b606cc7c81505c5b12f07b11ff996162f7c941c50bb6214983a206c
7
+ data.tar.gz: 89a7a1fe81649605c7e1328f9e6d8b6c37cbd49141ef37db0c72f34d766a24aed967f606139be9cff6bb1bee1c03a25e97a90e52794d447c35ab8b6ebf3f2965
@@ -1 +1 @@
1
- ruby-2.1.0
1
+ ruby-2.1.2
@@ -5,8 +5,7 @@ rvm:
5
5
  - 2.0.0
6
6
  - 2.1.0
7
7
  - 2.1.2
8
- - 2.1.3
9
- - 2.2.0
10
8
  - jruby-19mode
9
+
11
10
  gemfile:
12
11
  - Gemfile
data/README.md CHANGED
@@ -1,19 +1,38 @@
1
1
  mongoid-rspec
2
- =
2
+ =============
3
3
 
4
- [![Build Status][travis_badge]][travis]
4
+ [![Build Status](https://secure.travis-ci.org/mongoid-rspec/mongoid-rspec.png?branch=master)](https://travis-ci.org/mongoid-rspec/mongoid-rspec)
5
5
 
6
- RSpec matchers for Mongoid 3.x.
6
+ [![Gem Version](https://badge.fury.io/rb/mongoid-rspec.svg)](http://badge.fury.io/rb/mongoid-rspec)
7
7
 
8
- For Mongoid 2.x, use [mongoid-rspec 1.4.5](http://rubygems.org/gems/mongoid-rspec/versions/1.4.5)
8
+ [![Code Climate](https://codeclimate.com/github/mongoid-rspec/mongoid-rspec/badges/gpa.svg)](https://codeclimate.com/github/mongoid-rspec/mongoid-rspec)
9
9
 
10
- Installation
11
- -
12
- Add to your Gemfile
10
+ mongoid-rspec provides a collection of RSpec-compatible matchers that help to test mongoid documents.
13
11
 
14
- gem 'mongoid-rspec'
12
+ ## Installation
15
13
 
16
- Drop in existing or dedicated support file in spec/support (spec/support/mongoid.rb)
14
+ ### With Mongoid 4.x
15
+
16
+ Use mongoid-rspec [2.0.0.rc1][mongo4]
17
+
18
+ gem 'mongoid-rspec', '~> 2.0.0.rc1'
19
+
20
+ ### With Mongoid 3.x
21
+
22
+ Use mongoid-rspec [1.11.0][mongo3].
23
+
24
+ gem 'mongoid-rspec', '~> 1.11.0'
25
+
26
+ ### With Mongoid 2.x
27
+
28
+ Use mongoid-rspec [1.4.5][mongo2]
29
+
30
+ gem 'mongoid-rspec', '1.4.5'
31
+
32
+ ### Configuring
33
+
34
+ Drop in existing or dedicated support file in spec/support.
35
+ i.e: `spec/support/mongoid.rb`
17
36
 
18
37
  ```ruby
19
38
  RSpec.configure do |config|
@@ -21,8 +40,9 @@ RSpec.configure do |config|
21
40
  end
22
41
  ```
23
42
 
24
- Association Matchers
25
- -
43
+ ## Matchers
44
+
45
+ ### Association Matchers
26
46
 
27
47
  ```ruby
28
48
  describe User do
@@ -69,8 +89,7 @@ describe Site do
69
89
  end
70
90
  ```
71
91
 
72
- Mass Assignment Matcher
73
- -
92
+ ### Mass Assignment Matcher
74
93
 
75
94
  ```ruby
76
95
  describe User do
@@ -85,8 +104,7 @@ describe User do
85
104
  end
86
105
  ```
87
106
 
88
- Validation Matchers
89
- -
107
+ ### Validation Matchers
90
108
 
91
109
  ```ruby
92
110
  describe Site do
@@ -131,8 +149,7 @@ describe Person do
131
149
  end
132
150
  ```
133
151
 
134
- Accepts Nested Attributes Matcher
135
- -
152
+ ### Accepts Nested Attributes Matcher
136
153
 
137
154
  ```ruby
138
155
  describe User do
@@ -145,8 +162,7 @@ describe Article do
145
162
  end
146
163
  ```
147
164
 
148
- Index Matcher
149
- -
165
+ ### Index Matcher
150
166
 
151
167
  ```ruby
152
168
  describe Article do
@@ -159,8 +175,7 @@ describe Profile do
159
175
  end
160
176
  ```
161
177
 
162
- Others
163
- -
178
+ ### Others
164
179
 
165
180
  ```ruby
166
181
  describe User do
@@ -191,17 +206,17 @@ describe Article do
191
206
  end
192
207
  ```
193
208
 
194
- Known issues
195
- -
209
+ ## Known issues
196
210
 
197
- accept_nested_attributes_for matcher must test options [issue 91](https://github.com/evansagge/mongoid-rspec/issues/91).
211
+ accept_nested_attributes_for matcher must test options [issue 91](https://github.com/mongoid-rspec/mongoid-rspec/issues/91).
198
212
 
199
- Acknowledgement
200
- -
201
- Thanks to [Durran Jordan](https://github.com/durran) for providing the changes necessary to make
202
- this compatible with mongoid 2.0.0.rc, and for other [contributors](https://github.com/evansagge/mongoid-rspec/contributors)
203
- to this project.
213
+ ## Acknowledgement
204
214
 
215
+ Thanks to [Durran Jordan][durran] for providing the changes necessary to make
216
+ this compatible with mongoid 2.0.0.rc, and for other [contributors](https://github.com/mongoid-rspec/mongoid-rspec/contributors)
217
+ to this project.
205
218
 
206
- [travis_badge]: https://travis-ci.org/mongoid-rspec/mongoid-rspec.svg?branch=mongoid-3-1
207
- [travis]: https://travis-ci.org/mongoid-rspec/mongoid-rspec
219
+ [durran]: https://github.com/durran
220
+ [mongo2]: http://rubygems.org/gems/mongoid-rspec/versions/1.4.5
221
+ [mongo3]: http://rubygems.org/gems/mongoid-rspec/versions/1.11.0
222
+ [mongo4]: http://rubygems.org/gems/mongoid-rspec/versions/2.0.0.rc1
@@ -13,13 +13,31 @@ module Mongoid
13
13
  def matches?(klass)
14
14
  @klass = klass.is_a?(Class) ? klass : klass.class
15
15
  @errors = []
16
- unless @klass.index_options[@index_fields]
17
- @errors.push "no index for #{@index_fields}"
16
+
17
+ if @klass.respond_to?(:index_options)
18
+ # Mongoid 3
19
+ unless @klass.index_options[@index_fields]
20
+ @errors.push "no index for #{@index_fields}"
21
+ else
22
+ if !@options.nil? && !@options.empty?
23
+ @options.each do |option, option_value|
24
+ if denormalising_options(@klass.index_options[@index_fields])[option] != option_value
25
+ @errors.push "index for #{@index_fields.inspect} with options of #{@klass.index_options[@index_fields].inspect}"
26
+ end
27
+ end
28
+ end
29
+ end
18
30
  else
19
- if !@options.nil? && !@options.empty?
20
- @options.each do |option, option_value|
21
- if denormalising_options(@klass.index_options[@index_fields])[option] != option_value
22
- @errors.push "index for #{@index_fields.inspect} with options of #{@klass.index_options[@index_fields].inspect}"
31
+ # Mongoid 4
32
+ unless @klass.index_specifications.map(&:key).include?(@index_fields)
33
+ @errors.push "no index for #{@index_fields}"
34
+ else
35
+ if !@options.nil? && !@options.empty?
36
+ index_options = @klass.index_specifications.select { |is| is.key == @index_fields }.first.options
37
+ @options.each do |option, option_value|
38
+ if index_options[option] != option_value
39
+ @errors.push "index for #{@index_fields.inspect} with options of #{index_options.inspect}"
40
+ end
23
41
  end
24
42
  end
25
43
  end
@@ -7,7 +7,7 @@ module Mongoid
7
7
  end
8
8
 
9
9
  def to_allow(*values)
10
- @allowed_values = values.map(&:to_a).flatten
10
+ @allowed_values = values.map { |v| v.respond_to?(:to_a) ? v.to_a : v }.flatten
11
11
  self
12
12
  end
13
13
 
@@ -1,5 +1,5 @@
1
1
  module Mongoid
2
2
  module Rspec
3
- VERSION = "1.13.0"
3
+ VERSION = "2.0.0.rc1"
4
4
  end
5
5
  end
@@ -6,9 +6,9 @@ Gem::Specification.new do |s|
6
6
  s.name = "mongoid-rspec"
7
7
  s.version = Mongoid::Rspec::VERSION
8
8
  s.platform = Gem::Platform::RUBY
9
- s.authors = ["Evan Sagge"]
10
- s.email = %q{evansagge@gmail.com}
11
- s.homepage = %q{http://github.com/evansagge/mongoid-rspec}
9
+ s.authors = ["Evan Sagge", "Rodrigo Pinto"]
10
+ s.email = %q{evansagge@gmail.com contato@rodrigopinto.me}
11
+ s.homepage = %q{http://github.com/mongoid-rspec/mongoid-rspec}
12
12
  s.summary = %q{RSpec matchers for Mongoid}
13
13
  s.description = %q{RSpec matches for Mongoid models, including association and validation matchers}
14
14
 
@@ -20,6 +20,6 @@ Gem::Specification.new do |s|
20
20
  s.require_paths = ["lib"]
21
21
 
22
22
  s.add_dependency 'rake'
23
- s.add_dependency 'mongoid', '~> 3.1'
24
- s.add_dependency 'rspec', '~> 3.1'
23
+ s.add_dependency 'mongoid', '~> 4.0.0'
24
+ s.add_dependency 'rspec', '~> 3.0'
25
25
  end
@@ -1,9 +1,6 @@
1
1
  class Article
2
2
  include Mongoid::Document
3
3
  include Mongoid::Timestamps
4
- include Mongoid::Paranoia
5
- include Mongoid::Versioning
6
- include Mongoid::MultiParameterAttributes
7
4
 
8
5
  field :title, localize: true
9
6
  field :content
@@ -18,7 +18,7 @@ class User
18
18
 
19
19
  embeds_one :profile
20
20
 
21
- validates :login, presence: true, uniqueness: { scope: :site }, format: { with: /^[\w\-]+$/ }, exclusion: { in: ["super", "index", "edit"] }
21
+ validates :login, presence: true, uniqueness: { scope: :site }, format: { with: /\A[\w\-]+\z/ }, exclusion: { in: ["super", "index", "edit"] }
22
22
  validates :email, uniqueness: { case_sensitive: false, scope: :site, message: "is already taken" }, confirmation: true
23
23
  validates :role, presence: true, inclusion: { in: ["admin", "moderator", "member"] }
24
24
  validates :profile, presence: true, associated: true
@@ -28,9 +28,6 @@ class User
28
28
  validates :provider_uid, presence: true
29
29
  validates :locale, inclusion: { in: ->(user) { [:en, :ru] } }
30
30
 
31
- attr_accessible :login, :email, :age, :password
32
- attr_accessible :role, as: :admin
33
-
34
31
  accepts_nested_attributes_for :articles, :comments
35
32
 
36
33
  def admin?
@@ -9,16 +9,13 @@ describe "Document" do
9
9
  end
10
10
 
11
11
  describe Article do
12
- it { should have_field(:published).of_type(Boolean).with_default_value_of(false) }
13
- it { should have_field(:allow_comments).of_type(Boolean).with_default_value_of(true) }
12
+ it { should have_field(:published).of_type(Mongoid::Boolean).with_default_value_of(false) }
13
+ it { should have_field(:allow_comments).of_type(Mongoid::Boolean).with_default_value_of(true) }
14
14
  it { should belong_to(:author) }
15
15
  it { should have_field(:title).localized }
16
- it { should_not have_field(:allow_comments).of_type(Boolean).with_default_value_of(false) }
16
+ it { should_not have_field(:allow_comments).of_type(Mongoid::Boolean).with_default_value_of(false) }
17
17
  it { should_not have_field(:number_of_comments).of_type(Integer).with_default_value_of(1) }
18
18
  it { should be_mongoid_document }
19
- it { should be_versioned_document }
20
19
  it { should be_timestamped_document }
21
- it { should be_paranoid_document }
22
- it { should be_multiparameted_document }
23
20
  end
24
21
  end
@@ -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, drop_dups: true) }
6
+ it { should have_index_for(title: 1).with_options(unique: true, background: true, dropDups: true) }
7
7
  it { should have_index_for('permalink._id' => 1) }
8
8
  end
9
9
 
@@ -15,6 +15,7 @@ describe "Validations" do
15
15
  it { should validate_exclusion_of(:login).to_not_allow("super", "index", "edit") }
16
16
  it { should validate_exclusion_of(:password).to_not_allow("password") }
17
17
  it { should validate_inclusion_of(:role).to_allow("admin", "member") }
18
+ it { should validate_inclusion_of(:role).to_allow(["admin", "member"]) }
18
19
  it { should validate_confirmation_of(:email) }
19
20
  it { should validate_presence_of(:age).on(:create, :update) }
20
21
  it { should validate_numericality_of(:age).on(:create, :update) }
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid-rspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.13.0
4
+ version: 2.0.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan Sagge
8
+ - Rodrigo Pinto
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2015-01-05 00:00:00.000000000 Z
12
+ date: 2014-09-24 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: rake
@@ -30,31 +31,31 @@ dependencies:
30
31
  requirements:
31
32
  - - "~>"
32
33
  - !ruby/object:Gem::Version
33
- version: '3.1'
34
+ version: 4.0.0
34
35
  type: :runtime
35
36
  prerelease: false
36
37
  version_requirements: !ruby/object:Gem::Requirement
37
38
  requirements:
38
39
  - - "~>"
39
40
  - !ruby/object:Gem::Version
40
- version: '3.1'
41
+ version: 4.0.0
41
42
  - !ruby/object:Gem::Dependency
42
43
  name: rspec
43
44
  requirement: !ruby/object:Gem::Requirement
44
45
  requirements:
45
46
  - - "~>"
46
47
  - !ruby/object:Gem::Version
47
- version: '3.1'
48
+ version: '3.0'
48
49
  type: :runtime
49
50
  prerelease: false
50
51
  version_requirements: !ruby/object:Gem::Requirement
51
52
  requirements:
52
53
  - - "~>"
53
54
  - !ruby/object:Gem::Version
54
- version: '3.1'
55
+ version: '3.0'
55
56
  description: RSpec matches for Mongoid models, including association and validation
56
57
  matchers
57
- email: evansagge@gmail.com
58
+ email: evansagge@gmail.com contato@rodrigopinto.me
58
59
  executables: []
59
60
  extensions: []
60
61
  extra_rdoc_files: []
@@ -103,14 +104,13 @@ files:
103
104
  - spec/models/user.rb
104
105
  - spec/spec_helper.rb
105
106
  - spec/unit/accept_nested_attributes_spec.rb
106
- - spec/unit/allow_mass_assignment_spec.rb
107
107
  - spec/unit/associations_spec.rb
108
108
  - spec/unit/collections_spec.rb
109
109
  - spec/unit/document_spec.rb
110
110
  - spec/unit/indexes_spec.rb
111
111
  - spec/unit/validations_spec.rb
112
112
  - spec/validators/ssn_validator.rb
113
- homepage: http://github.com/evansagge/mongoid-rspec
113
+ homepage: http://github.com/mongoid-rspec/mongoid-rspec
114
114
  licenses: []
115
115
  metadata: {}
116
116
  post_install_message:
@@ -124,12 +124,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
124
124
  version: '0'
125
125
  required_rubygems_version: !ruby/object:Gem::Requirement
126
126
  requirements:
127
- - - ">="
127
+ - - ">"
128
128
  - !ruby/object:Gem::Version
129
- version: '0'
129
+ version: 1.3.1
130
130
  requirements: []
131
131
  rubyforge_project: mongoid-rspec
132
- rubygems_version: 2.4.5
132
+ rubygems_version: 2.2.2
133
133
  signing_key:
134
134
  specification_version: 4
135
135
  summary: RSpec matchers for Mongoid
@@ -146,7 +146,6 @@ test_files:
146
146
  - spec/models/user.rb
147
147
  - spec/spec_helper.rb
148
148
  - spec/unit/accept_nested_attributes_spec.rb
149
- - spec/unit/allow_mass_assignment_spec.rb
150
149
  - spec/unit/associations_spec.rb
151
150
  - spec/unit/collections_spec.rb
152
151
  - spec/unit/document_spec.rb
@@ -1,14 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "AllowMassAssignment" do
4
- describe User do
5
- it { should allow_mass_assignment_of(:login) }
6
- it { should allow_mass_assignment_of(:email) }
7
- it { should allow_mass_assignment_of(:age) }
8
- it { should allow_mass_assignment_of(:password) }
9
- it { should allow_mass_assignment_of(:password) }
10
- it { should allow_mass_assignment_of(:role).as(:admin) }
11
-
12
- it { should_not allow_mass_assignment_of(:role) }
13
- end
14
- end