accept_values_for 0.7.1 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/accept_values_for.gemspec +1 -1
- data/lib/accept_values_for/matcher.rb +7 -3
- data/spec/accept_values_for_spec.rb +16 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c6f068b399901b27d75288a2ad5714a5742c3af
|
4
|
+
data.tar.gz: d46db566833ad63b589d3bc909ffe449e9f0e386
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3604e0184e5b49342069e1db9e52167d9095f6a4ea3ca505c9c3f8d0cbe92537db53370076b54052c400c40b2576b57d28aae5533480fde761648e845997d9e8
|
7
|
+
data.tar.gz: 6da39f470c2152654c4b94f5c5a4b8e10d4e79ff4da18ab5d260aef90ec39b4c7d8f89f073a8d72f5584dd7e2e2d3a97ec8e36d5b3d16ca03a4a535fd0e71d6b
|
data/accept_values_for.gemspec
CHANGED
@@ -26,8 +26,8 @@ module AcceptValuesFor
|
|
26
26
|
|
27
27
|
def failure_message
|
28
28
|
result = "expected #{@model.inspect} to accept values #{formatted_failed_values} for #{@attribute.inspect}, but it was not\n"
|
29
|
-
|
30
|
-
result << "\nValue: #{key}\tErrors: #{@attribute} #{@failed_values[key]}"
|
29
|
+
sorted_failed_values.each do |key|
|
30
|
+
result << "\nValue: #{key.inspect}\tErrors: #{@attribute} #{@failed_values[key]}"
|
31
31
|
end
|
32
32
|
result
|
33
33
|
end
|
@@ -63,7 +63,11 @@ module AcceptValuesFor
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def formatted_failed_values
|
66
|
-
|
66
|
+
sorted_failed_values.map(&:inspect).join(", ")
|
67
|
+
end
|
68
|
+
|
69
|
+
def sorted_failed_values
|
70
|
+
@failed_values.keys.sort_by(&:to_s)
|
67
71
|
end
|
68
72
|
end
|
69
73
|
end
|
@@ -15,7 +15,7 @@ describe "AcceptValuesFor" do
|
|
15
15
|
it { should eq(false) }
|
16
16
|
it "should have correct failure message for should" do
|
17
17
|
accept_values_for_object.matches?(person)
|
18
|
-
accept_values_for_object.failure_message_for_should.should == "expected #{person.inspect} to accept values \"INVALID\" for :gender, but it was not\n\nValue: INVALID\tErrors: gender is not included in the list"
|
18
|
+
accept_values_for_object.failure_message_for_should.should == "expected #{person.inspect} to accept values \"INVALID\" for :gender, but it was not\n\nValue: \"INVALID\"\tErrors: gender is not included in the list"
|
19
19
|
end
|
20
20
|
it "should assign the old value for attribute" do
|
21
21
|
accept_values_for_object.matches?(person)
|
@@ -27,7 +27,21 @@ describe "AcceptValuesFor" do
|
|
27
27
|
it { should eq(false) }
|
28
28
|
it "should have correct failure message for should" do
|
29
29
|
accept_values_for_object.matches?(person)
|
30
|
-
accept_values_for_object.failure_message_for_should.should == "expected #{person.inspect} to accept values \"INVALID\", \"WRONG\" for :gender, but it was not\n\nValue: INVALID\tErrors: gender is not included in the list\nValue: WRONG\tErrors: gender is not included in the list"
|
30
|
+
accept_values_for_object.failure_message_for_should.should == "expected #{person.inspect} to accept values \"INVALID\", \"WRONG\" for :gender, but it was not\n\nValue: \"INVALID\"\tErrors: gender is not included in the list\nValue: \"WRONG\"\tErrors: gender is not included in the list"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
context "when not accepte values of different types" do
|
34
|
+
let(:values) { ['INVALID', nil, 1] }
|
35
|
+
it { should eq(false) }
|
36
|
+
it "should have correct failure message for should" do
|
37
|
+
accept_values_for_object.matches?(person)
|
38
|
+
accept_values_for_object.failure_message_for_should.should == <<MSG.strip
|
39
|
+
expected #{person.inspect} to accept values nil, 1, \"INVALID\" for :gender, but it was not
|
40
|
+
|
41
|
+
Value: nil\tErrors: gender is not included in the list
|
42
|
+
Value: 1\tErrors: gender is not included in the list
|
43
|
+
Value: \"INVALID\"\tErrors: gender is not included in the list
|
44
|
+
MSG
|
31
45
|
end
|
32
46
|
end
|
33
47
|
context "when one value is accept and other is not" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: accept_values_for
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bogdan Gusiev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -123,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
123
|
version: '0'
|
124
124
|
requirements: []
|
125
125
|
rubyforge_project:
|
126
|
-
rubygems_version: 2.
|
126
|
+
rubygems_version: 2.4.5
|
127
127
|
signing_key:
|
128
128
|
specification_version: 4
|
129
129
|
summary: Test complex Active Record validations with RSpec
|