mongoid-rspec 1.5.3 → 2.0.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.
Files changed (45) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +2 -0
  3. data/.ruby-gemset +1 -0
  4. data/.ruby-version +1 -0
  5. data/.travis.yml +7 -2
  6. data/README.md +227 -152
  7. data/lib/matchers/accept_nested_attributes.rb +67 -0
  8. data/lib/matchers/allow_mass_assignment.rb +1 -0
  9. data/lib/matchers/associations.rb +127 -22
  10. data/lib/matchers/document.rb +31 -2
  11. data/lib/matchers/indexes.rb +48 -15
  12. data/lib/matchers/validations/acceptance_of.rb +2 -2
  13. data/lib/matchers/validations/associated.rb +5 -5
  14. data/lib/matchers/validations/confirmation_of.rb +2 -2
  15. data/lib/matchers/validations/custom_validation_of.rb +2 -19
  16. data/lib/matchers/validations/exclusion_of.rb +8 -1
  17. data/lib/matchers/validations/format_of.rb +21 -21
  18. data/lib/matchers/validations/inclusion_of.rb +13 -13
  19. data/lib/matchers/validations/length_of.rb +66 -19
  20. data/lib/matchers/validations/numericality_of.rb +10 -10
  21. data/lib/matchers/validations/presence_of.rb +2 -2
  22. data/lib/matchers/validations/uniqueness_of.rb +13 -30
  23. data/lib/matchers/validations/with_message.rb +27 -0
  24. data/lib/matchers/validations.rb +18 -3
  25. data/lib/mongoid-rspec/version.rb +1 -1
  26. data/lib/mongoid-rspec.rb +5 -1
  27. data/mongoid-rspec.gemspec +5 -5
  28. data/spec/models/article.rb +18 -12
  29. data/spec/models/comment.rb +2 -2
  30. data/spec/models/movie_article.rb +6 -5
  31. data/spec/models/permalink.rb +1 -1
  32. data/spec/models/person.rb +0 -3
  33. data/spec/models/profile.rb +9 -7
  34. data/spec/models/record.rb +1 -1
  35. data/spec/models/site.rb +2 -3
  36. data/spec/models/user.rb +14 -14
  37. data/spec/unit/accept_nested_attributes_spec.rb +12 -0
  38. data/spec/unit/associations_spec.rb +6 -6
  39. data/spec/unit/document_spec.rb +6 -6
  40. data/spec/unit/indexes_spec.rb +3 -2
  41. data/spec/unit/validations_spec.rb +7 -0
  42. data/spec/validators/ssn_validator.rb +3 -1
  43. metadata +43 -32
  44. data/.rvmrc +0 -1
  45. data/spec/unit/allow_mass_assignment_spec.rb +0 -14
@@ -2,13 +2,13 @@ require 'spec_helper'
2
2
 
3
3
  describe "Associations" do
4
4
  describe User do
5
- it { should have_many(:articles).with_foreign_key(:author_id) }
5
+ it { should have_many(:articles).with_foreign_key(:author_id).ordered_by(:title) }
6
6
 
7
- it { should have_one(:record) }
7
+ it { should have_one(:record).with_autobuild }
8
8
 
9
9
  it { should have_many(:comments).with_dependent(:destroy).with_autosave }
10
10
 
11
- it { should embed_one :profile }
11
+ it { should embed_one(:profile) }
12
12
 
13
13
  it { should have_and_belong_to_many(:children).of_type(User) }
14
14
  end
@@ -19,12 +19,12 @@ describe "Associations" do
19
19
 
20
20
  describe Article do
21
21
  it { should belong_to(:author).of_type(User).as_inverse_of(:articles).with_index }
22
- it { should embed_many(:comments) }
22
+ it { should embed_many(:comments).with_cascading_callbacks }
23
23
  it { should embed_one(:permalink) }
24
24
  end
25
25
 
26
26
  describe Comment do
27
- it { should be_embedded_in(:article).as_inverse_of(:comments) }
27
+ it { should be_embedded_in(:article).as_inverse_of(:comments).with_polymorphism }
28
28
  it { should belong_to(:user).as_inverse_of(:comments) }
29
29
  end
30
30
 
@@ -37,6 +37,6 @@ describe "Associations" do
37
37
  end
38
38
 
39
39
  describe Site do
40
- it { should have_many(:users).as_inverse_of(:site) }
40
+ it { should have_many(:users).as_inverse_of(:site).ordered_by(:email.desc) }
41
41
  end
42
42
  end
@@ -9,13 +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) }
14
- it { should_not have_field(:allow_comments).of_type(Boolean).with_default_value_of(false) }
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
+ it { should belong_to(:author) }
15
+ it { should have_field(:title).localized }
16
+ it { should_not have_field(:allow_comments).of_type(Mongoid::Boolean).with_default_value_of(false) }
17
+ it { should_not have_field(:number_of_comments).of_type(Integer).with_default_value_of(1) }
15
18
  it { should be_mongoid_document }
16
- it { should be_versioned_document }
17
19
  it { should be_timestamped_document }
18
- it { should be_paranoid_document }
19
- it { should be_multiparameted_document }
20
20
  end
21
21
  end
@@ -3,9 +3,10 @@ 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, dropDups: true) }
7
+ it { should have_index_for('permalink._id' => 1) }
7
8
  end
8
-
9
+
9
10
  describe Profile do
10
11
  it { should have_index_for(first_name: 1, last_name: 1) }
11
12
  end
@@ -13,7 +13,9 @@ describe "Validations" do
13
13
  it { should validate_format_of(:login).to_allow("valid_login").not_to_allow("invalid login") }
14
14
  it { should validate_associated(:profile) }
15
15
  it { should validate_exclusion_of(:login).to_not_allow("super", "index", "edit") }
16
+ it { should validate_exclusion_of(:password).to_not_allow("password") }
16
17
  it { should validate_inclusion_of(:role).to_allow("admin", "member") }
18
+ it { should validate_inclusion_of(:role).to_allow(["admin", "member"]) }
17
19
  it { should validate_confirmation_of(:email) }
18
20
  it { should validate_presence_of(:age).on(:create, :update) }
19
21
  it { should validate_numericality_of(:age).on(:create, :update) }
@@ -26,10 +28,15 @@ describe "Validations" do
26
28
  describe Profile do
27
29
  it { should validate_numericality_of(:age).greater_than(0) }
28
30
  it { should validate_acceptance_of(:terms_of_service) }
31
+ it { should validate_length_of(:hobbies).with_minimum(1).with_message("requires at least one hobby") }
29
32
  end
30
33
 
31
34
  describe Article do
32
35
  it { should validate_length_of(:title).within(8..16) }
36
+ it { should_not validate_length_of(:content).greater_than(200).less_than(16) }
37
+ it { should validate_length_of(:content).greater_than(200) }
38
+ it { should validate_inclusion_of(:status).to_allow([:pending]).on( :create ) }
39
+ it { should validate_inclusion_of(:status).to_allow([:approved, :rejected]).on( :update ) }
33
40
  end
34
41
 
35
42
  describe MovieArticle do
@@ -1,7 +1,9 @@
1
1
  class SsnValidator < ActiveModel::EachValidator
2
2
 
3
3
  def validate_each(record, attribute, value)
4
- record.errors[attribute] << "#{value} is not a valid Social Security Number" unless valid_ssn?(record, attribute, value)
4
+ unless valid_ssn?(record, attribute, value)
5
+ record.errors[attribute] << "#{value} is not a valid Social Security Number"
6
+ end
5
7
  end
6
8
 
7
9
  def self.kind() :custom end
metadata CHANGED
@@ -1,65 +1,76 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid-rspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.3
5
- prerelease:
4
+ version: 2.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Evan Sagge
8
+ - Rodrigo Pinto
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-20 00:00:00.000000000 Z
12
+ date: 2015-01-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &70177756732360 !ruby/object:Gem::Requirement
17
- none: false
16
+ requirement: !ruby/object:Gem::Requirement
18
17
  requirements:
19
- - - ! '>='
18
+ - - ">="
20
19
  - !ruby/object:Gem::Version
21
20
  version: '0'
22
21
  type: :runtime
23
22
  prerelease: false
24
- version_requirements: *70177756732360
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
25
28
  - !ruby/object:Gem::Dependency
26
29
  name: mongoid
27
- requirement: &70177756731080 !ruby/object:Gem::Requirement
28
- none: false
30
+ requirement: !ruby/object:Gem::Requirement
29
31
  requirements:
30
- - - ! '>='
32
+ - - "~>"
31
33
  - !ruby/object:Gem::Version
32
- version: 3.0.1
34
+ version: 4.0.0
33
35
  type: :runtime
34
36
  prerelease: false
35
- version_requirements: *70177756731080
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: 4.0.0
36
42
  - !ruby/object:Gem::Dependency
37
43
  name: rspec
38
- requirement: &70177756728480 !ruby/object:Gem::Requirement
39
- none: false
44
+ requirement: !ruby/object:Gem::Requirement
40
45
  requirements:
41
- - - ! '>='
46
+ - - "~>"
42
47
  - !ruby/object:Gem::Version
43
- version: '2.9'
48
+ version: '3.1'
44
49
  type: :runtime
45
50
  prerelease: false
46
- version_requirements: *70177756728480
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '3.1'
47
56
  description: RSpec matches for Mongoid models, including association and validation
48
57
  matchers
49
- email: evansagge@gmail.com
58
+ email: evansagge@gmail.com contato@rodrigopinto.me
50
59
  executables: []
51
60
  extensions: []
52
61
  extra_rdoc_files: []
53
62
  files:
54
- - .bundle/config
55
- - .document
56
- - .gitignore
57
- - .rvmrc
58
- - .travis.yml
63
+ - ".bundle/config"
64
+ - ".document"
65
+ - ".gitignore"
66
+ - ".ruby-gemset"
67
+ - ".ruby-version"
68
+ - ".travis.yml"
59
69
  - Gemfile
60
70
  - LICENSE
61
71
  - README.md
62
72
  - Rakefile
73
+ - lib/matchers/accept_nested_attributes.rb
63
74
  - lib/matchers/allow_mass_assignment.rb
64
75
  - lib/matchers/associations.rb
65
76
  - lib/matchers/collections.rb
@@ -77,6 +88,7 @@ files:
77
88
  - lib/matchers/validations/numericality_of.rb
78
89
  - lib/matchers/validations/presence_of.rb
79
90
  - lib/matchers/validations/uniqueness_of.rb
91
+ - lib/matchers/validations/with_message.rb
80
92
  - lib/mongoid-rspec.rb
81
93
  - lib/mongoid-rspec/version.rb
82
94
  - mongoid-rspec.gemspec
@@ -91,36 +103,35 @@ files:
91
103
  - spec/models/site.rb
92
104
  - spec/models/user.rb
93
105
  - spec/spec_helper.rb
94
- - spec/unit/allow_mass_assignment_spec.rb
106
+ - spec/unit/accept_nested_attributes_spec.rb
95
107
  - spec/unit/associations_spec.rb
96
108
  - spec/unit/collections_spec.rb
97
109
  - spec/unit/document_spec.rb
98
110
  - spec/unit/indexes_spec.rb
99
111
  - spec/unit/validations_spec.rb
100
112
  - spec/validators/ssn_validator.rb
101
- homepage: http://github.com/evansagge/mongoid-rspec
113
+ homepage: http://github.com/mongoid-rspec/mongoid-rspec
102
114
  licenses: []
115
+ metadata: {}
103
116
  post_install_message:
104
117
  rdoc_options: []
105
118
  require_paths:
106
119
  - lib
107
120
  required_ruby_version: !ruby/object:Gem::Requirement
108
- none: false
109
121
  requirements:
110
- - - ! '>='
122
+ - - ">="
111
123
  - !ruby/object:Gem::Version
112
124
  version: '0'
113
125
  required_rubygems_version: !ruby/object:Gem::Requirement
114
- none: false
115
126
  requirements:
116
- - - ! '>='
127
+ - - ">="
117
128
  - !ruby/object:Gem::Version
118
129
  version: '0'
119
130
  requirements: []
120
131
  rubyforge_project: mongoid-rspec
121
- rubygems_version: 1.8.10
132
+ rubygems_version: 2.4.5
122
133
  signing_key:
123
- specification_version: 3
134
+ specification_version: 4
124
135
  summary: RSpec matchers for Mongoid
125
136
  test_files:
126
137
  - spec/models/article.rb
@@ -134,7 +145,7 @@ test_files:
134
145
  - spec/models/site.rb
135
146
  - spec/models/user.rb
136
147
  - spec/spec_helper.rb
137
- - spec/unit/allow_mass_assignment_spec.rb
148
+ - spec/unit/accept_nested_attributes_spec.rb
138
149
  - spec/unit/associations_spec.rb
139
150
  - spec/unit/collections_spec.rb
140
151
  - spec/unit/document_spec.rb
data/.rvmrc DELETED
@@ -1 +0,0 @@
1
- rvm use --create 1.9.3@mongoid-rspec
@@ -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