rad_matchers 0.2 → 0.3
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.
@@ -6,7 +6,6 @@ class ValidateAssociatedMatcher
|
|
6
6
|
|
7
7
|
def matches?(instance)
|
8
8
|
@instance = instance
|
9
|
-
association_class = @instance.class.reflect_on_association(@attribute).klass
|
10
9
|
invalid_record = association_class.new
|
11
10
|
invalid_record.stub!(:valid?).and_return(false)
|
12
11
|
@instance.send("#{@attribute}=", invalid_record)
|
@@ -16,6 +15,17 @@ class ValidateAssociatedMatcher
|
|
16
15
|
def failure_message_for_should
|
17
16
|
"expected #{@instance} to validate associated #{@attribute}"
|
18
17
|
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def association_class
|
22
|
+
reflection = @instance.class.reflect_on_association(@attribute)
|
23
|
+
if reflection.options[:polymorphic] == true
|
24
|
+
@instance.send(reflection.options[:foreign_type]).constantize
|
25
|
+
else
|
26
|
+
reflection.klass
|
27
|
+
end
|
28
|
+
end
|
19
29
|
end
|
20
30
|
|
21
31
|
def validate_associated(attribute)
|
data/lib/rad_matchers/version.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.3"
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Eric Carty-Fickes
|
@@ -10,8 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-04-
|
14
|
-
default_executable:
|
13
|
+
date: 2011-04-25 00:00:00 Z
|
15
14
|
dependencies: []
|
16
15
|
|
17
16
|
description: additional matchers for rspec-rails
|
@@ -31,7 +30,6 @@ files:
|
|
31
30
|
- lib/rad_matchers/validate_associated_matcher.rb
|
32
31
|
- lib/rad_matchers/version.rb
|
33
32
|
- rad_matchers.gemspec
|
34
|
-
has_rdoc: true
|
35
33
|
homepage:
|
36
34
|
licenses: []
|
37
35
|
|
@@ -55,9 +53,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
55
53
|
requirements: []
|
56
54
|
|
57
55
|
rubyforge_project: rad_matchers
|
58
|
-
rubygems_version: 1.
|
56
|
+
rubygems_version: 1.7.2
|
59
57
|
signing_key:
|
60
58
|
specification_version: 3
|
61
|
-
summary: rad_matchers-0.
|
59
|
+
summary: rad_matchers-0.3
|
62
60
|
test_files: []
|
63
61
|
|