rad_matchers 0.1 → 0.2
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/.gitignore +1 -0
- data/lib/rad_matchers/validate_associated_matcher.rb +23 -0
- data/lib/rad_matchers/version.rb +1 -1
- data/lib/rad_matchers.rb +1 -0
- metadata +3 -2
data/.gitignore
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
class ValidateAssociatedMatcher
|
2
|
+
|
3
|
+
def initialize(attribute)
|
4
|
+
@attribute = attribute
|
5
|
+
end
|
6
|
+
|
7
|
+
def matches?(instance)
|
8
|
+
@instance = instance
|
9
|
+
association_class = @instance.class.reflect_on_association(@attribute).klass
|
10
|
+
invalid_record = association_class.new
|
11
|
+
invalid_record.stub!(:valid?).and_return(false)
|
12
|
+
@instance.send("#{@attribute}=", invalid_record)
|
13
|
+
@instance.valid? == false && @instance.errors_on(@attribute)
|
14
|
+
end
|
15
|
+
|
16
|
+
def failure_message_for_should
|
17
|
+
"expected #{@instance} to validate associated #{@attribute}"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def validate_associated(attribute)
|
22
|
+
ValidateAssociatedMatcher.new attribute
|
23
|
+
end
|
data/lib/rad_matchers/version.rb
CHANGED
data/lib/rad_matchers.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: rad_matchers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: "0.
|
5
|
+
version: "0.2"
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Eric Carty-Fickes
|
@@ -28,6 +28,7 @@ files:
|
|
28
28
|
- Licence.txt
|
29
29
|
- README.markdown
|
30
30
|
- lib/rad_matchers.rb
|
31
|
+
- lib/rad_matchers/validate_associated_matcher.rb
|
31
32
|
- lib/rad_matchers/version.rb
|
32
33
|
- rad_matchers.gemspec
|
33
34
|
has_rdoc: true
|
@@ -57,6 +58,6 @@ rubyforge_project: rad_matchers
|
|
57
58
|
rubygems_version: 1.6.2
|
58
59
|
signing_key:
|
59
60
|
specification_version: 3
|
60
|
-
summary: rad_matchers-0.
|
61
|
+
summary: rad_matchers-0.2
|
61
62
|
test_files: []
|
62
63
|
|