mongoid-rspec 2.1.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/matchers/validations/confirmation_of.rb +14 -1
- data/lib/mongoid-rspec/version.rb +1 -1
- data/spec/models/user.rb +1 -0
- data/spec/unit/validations_spec.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 699ec1b87e5b320dcbaf578f80eafe007efd931a
|
4
|
+
data.tar.gz: 3d2c164d79f3bf55fe230acc7dbe1d79e8368dfc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46af8cab737f63a787aab8896a0e89ba59cbf71e842bfe4e36474d596e30a6c56b99ea5650f72ddd086fdbecd25af8f44842ac4d83dbd0cd49dbac2706d15fa9
|
7
|
+
data.tar.gz: 7fe2a140a8fe81af936df050101600d0adf56d406b25207cd8f7b65397b7a1f63109b71b6cdd9136c0f3eded554ecaa5a82005224e994b88971eca0edbc6160c
|
@@ -1,8 +1,21 @@
|
|
1
1
|
module Mongoid
|
2
2
|
module Matchers
|
3
3
|
module Validations
|
4
|
+
class ValidateConfirmationOfMatcher < HaveValidationMatcher
|
5
|
+
include WithMessage
|
6
|
+
|
7
|
+
def initialize(name)
|
8
|
+
super(name, :confirmation)
|
9
|
+
end
|
10
|
+
|
11
|
+
def with_message(message)
|
12
|
+
@expected_message = message
|
13
|
+
self
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
4
17
|
def validate_confirmation_of(field)
|
5
|
-
|
18
|
+
ValidateConfirmationOfMatcher.new(field)
|
6
19
|
end
|
7
20
|
end
|
8
21
|
end
|
data/spec/models/user.rb
CHANGED
@@ -25,6 +25,7 @@ class User
|
|
25
25
|
validates :age, presence: true, numericality: true, inclusion: { in: 23..42 }, on: [:create, :update]
|
26
26
|
validates :password, presence: true, on: [:create, :update]
|
27
27
|
validates :password, exclusion: { in: ->(user) { ['password'] } }
|
28
|
+
validates :password, confirmation: { message: "Password confirmation must match given password" }
|
28
29
|
validates :provider_uid, presence: true
|
29
30
|
validates :locale, inclusion: { in: ->(user) { [:en, :ru] } }
|
30
31
|
|
@@ -21,6 +21,7 @@ RSpec.describe "Validations" do
|
|
21
21
|
it { is_expected.to validate_numericality_of(:age).on(:create, :update) }
|
22
22
|
it { is_expected.to validate_inclusion_of(:age).to_allow(23..42).on([:create, :update]) }
|
23
23
|
it { is_expected.to validate_presence_of(:password).on(:create) }
|
24
|
+
it { is_expected.to validate_confirmation_of(:password).with_message("Password confirmation must match given password") }
|
24
25
|
it { is_expected.to validate_presence_of(:provider_uid).on(:create) }
|
25
26
|
it { is_expected.to validate_inclusion_of(:locale).to_allow([:en, :ru]) }
|
26
27
|
end
|
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: 2.
|
4
|
+
version: 2.2.0
|
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: 2015-
|
12
|
+
date: 2015-03-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|