rad_matchers 0.2 → 0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -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)
@@ -1,5 +1,5 @@
1
1
  module RadMatchers
2
2
  module Version
3
- STRING = "0.2"
3
+ STRING = "0.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: rad_matchers
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: "0.2"
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-01 00:00:00 -05:00
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.6.2
56
+ rubygems_version: 1.7.2
59
57
  signing_key:
60
58
  specification_version: 3
61
- summary: rad_matchers-0.2
59
+ summary: rad_matchers-0.3
62
60
  test_files: []
63
61