minitest_rails_tools 0.1.0 → 0.1.1
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/lib/validation_matchers.rb +3 -1
- metadata +1 -1
data/lib/validation_matchers.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
# Allows for some automagic association tests.
|
2
|
+
# Expects 'subject' to be defined. E.g.
|
3
|
+
# subject { FactoryGirl.create :foo }
|
2
4
|
|
3
5
|
def must_validate_presence_of(attribute_name)
|
4
6
|
it "validates_presence_of :#{attribute_name.to_s.parameterize.underscore}" do
|
@@ -10,7 +12,7 @@ end
|
|
10
12
|
|
11
13
|
def must_validate_uniqueness_of(attribute_name)
|
12
14
|
it "validates_uniqueness_of :#{attribute_name.to_s.parameterize.underscore}" do
|
13
|
-
other =
|
15
|
+
other = subject.class.new
|
14
16
|
subject.send "#{attribute_name}=".to_sym, other.send(attribute_name)
|
15
17
|
subject.valid?.must_equal false
|
16
18
|
subject.errors.messages[attribute_name.to_sym].must_include "has already been taken"
|