shoulda-matchers 1.5.5 → 1.5.6
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.
- data/Gemfile.lock +1 -1
- data/NEWS.md +4 -0
- data/gemfiles/3.0.gemfile.lock +1 -1
- data/gemfiles/3.1.gemfile.lock +1 -1
- data/gemfiles/3.2.gemfile.lock +1 -1
- data/lib/shoulda/matchers/active_model/allow_value_matcher.rb +8 -16
- data/lib/shoulda/matchers/version.rb +1 -1
- data/spec/shoulda/matchers/active_model/ensure_inclusion_of_matcher_spec.rb +1 -10
- metadata +4 -4
data/Gemfile.lock
CHANGED
data/NEWS.md
CHANGED
data/gemfiles/3.0.gemfile.lock
CHANGED
data/gemfiles/3.1.gemfile.lock
CHANGED
data/gemfiles/3.2.gemfile.lock
CHANGED
@@ -56,9 +56,10 @@ module Shoulda # :nodoc:
|
|
56
56
|
def matches?(instance)
|
57
57
|
self.instance = instance
|
58
58
|
|
59
|
-
values_to_match.
|
60
|
-
|
61
|
-
|
59
|
+
values_to_match.none? do |value|
|
60
|
+
self.value = value
|
61
|
+
instance.send("#{attribute}=", value)
|
62
|
+
errors_match?
|
62
63
|
end
|
63
64
|
end
|
64
65
|
|
@@ -79,21 +80,12 @@ module Shoulda # :nodoc:
|
|
79
80
|
attr_accessor :values_to_match, :message_finder_factory,
|
80
81
|
:instance, :attribute, :value, :matched_error
|
81
82
|
|
82
|
-
def
|
83
|
-
|
84
|
-
instance.send("#{attribute}=", current_value)
|
83
|
+
def errors_match?
|
84
|
+
has_messages? && errors_for_attribute_match?
|
85
85
|
end
|
86
86
|
|
87
|
-
def
|
88
|
-
|
89
|
-
end
|
90
|
-
|
91
|
-
def errors_do_not_match?
|
92
|
-
has_no_messages? || !errors_for_attribute_match?
|
93
|
-
end
|
94
|
-
|
95
|
-
def has_no_messages?
|
96
|
-
!message_finder.has_messages?
|
87
|
+
def has_messages?
|
88
|
+
message_finder.has_messages?
|
97
89
|
end
|
98
90
|
|
99
91
|
def errors_for_attribute_match?
|
@@ -79,13 +79,6 @@ describe Shoulda::Matchers::ActiveModel::EnsureInclusionOfMatcher do
|
|
79
79
|
end
|
80
80
|
|
81
81
|
context 'an attribute which must be included in an array' do
|
82
|
-
context 'given an attribute that does not accept strings' do
|
83
|
-
it 'allows an attribute to be set as an integer' do
|
84
|
-
validating_inclusion(:in => [0,1,2], :column_type => :integer).
|
85
|
-
should ensure_inclusion_of(:attr).in_array([0,1,2])
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
82
|
it 'accepts with correct array' do
|
90
83
|
validating_inclusion(:in => %w(one two)).
|
91
84
|
should ensure_inclusion_of(:attr).in_array(%w(one two))
|
@@ -172,9 +165,7 @@ describe Shoulda::Matchers::ActiveModel::EnsureInclusionOfMatcher do
|
|
172
165
|
end
|
173
166
|
|
174
167
|
def validating_inclusion(options)
|
175
|
-
|
176
|
-
|
177
|
-
define_model(:example, :attr => options[:column_type]) do
|
168
|
+
define_model(:example, :attr => :string) do
|
178
169
|
validates_inclusion_of :attr, options
|
179
170
|
end.new
|
180
171
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shoulda-matchers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -14,7 +14,7 @@ authors:
|
|
14
14
|
autorequire:
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
|
-
date: 2013-03-
|
17
|
+
date: 2013-03-29 00:00:00.000000000 Z
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: activesupport
|
@@ -309,7 +309,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
309
309
|
version: '0'
|
310
310
|
segments:
|
311
311
|
- 0
|
312
|
-
hash:
|
312
|
+
hash: 1811541480195488740
|
313
313
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
314
314
|
none: false
|
315
315
|
requirements:
|
@@ -318,7 +318,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
318
318
|
version: '0'
|
319
319
|
segments:
|
320
320
|
- 0
|
321
|
-
hash:
|
321
|
+
hash: 1811541480195488740
|
322
322
|
requirements: []
|
323
323
|
rubyforge_project:
|
324
324
|
rubygems_version: 1.8.25
|