Class: Shoulda::Matchers::ActiveRecord::AcceptNestedAttributesForMatcher
- Inherits:
-
Object
- Object
- Shoulda::Matchers::ActiveRecord::AcceptNestedAttributesForMatcher
- Defined in:
- lib/shoulda/matchers/active_record/accept_nested_attributes_for_matcher.rb
Instance Method Summary collapse
- #allow_destroy(allow_destroy) ⇒ Object
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(name) ⇒ AcceptNestedAttributesForMatcher
constructor
A new instance of AcceptNestedAttributesForMatcher.
- #limit(limit) ⇒ Object
- #matches?(subject) ⇒ Boolean
- #update_only(update_only) ⇒ Object
Constructor Details
#initialize(name) ⇒ AcceptNestedAttributesForMatcher
Returns a new instance of AcceptNestedAttributesForMatcher.
99 100 101 102 |
# File 'lib/shoulda/matchers/active_record/accept_nested_attributes_for_matcher.rb', line 99 def initialize(name) @name = name @options = {} end |
Instance Method Details
#allow_destroy(allow_destroy) ⇒ Object
104 105 106 107 |
# File 'lib/shoulda/matchers/active_record/accept_nested_attributes_for_matcher.rb', line 104 def allow_destroy(allow_destroy) @options[:allow_destroy] = allow_destroy self end |
#description ⇒ Object
135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/shoulda/matchers/active_record/accept_nested_attributes_for_matcher.rb', line 135 def description description = "accepts_nested_attributes_for :#{@name}" if @options.key?(:allow_destroy) description += " allow_destroy => #{@options[:allow_destroy]}" end if @options.key?(:limit) description += " limit => #{@options[:limit]}" end if @options.key?(:update_only) description += " update_only => #{@options[:update_only]}" end description end |
#failure_message ⇒ Object
127 128 129 |
# File 'lib/shoulda/matchers/active_record/accept_nested_attributes_for_matcher.rb', line 127 def "Expected #{expectation} (#{@problem})" end |
#failure_message_when_negated ⇒ Object
131 132 133 |
# File 'lib/shoulda/matchers/active_record/accept_nested_attributes_for_matcher.rb', line 131 def "Did not expect #{expectation}" end |
#limit(limit) ⇒ Object
109 110 111 112 |
# File 'lib/shoulda/matchers/active_record/accept_nested_attributes_for_matcher.rb', line 109 def limit(limit) @options[:limit] = limit self end |
#matches?(subject) ⇒ Boolean
119 120 121 122 123 124 125 |
# File 'lib/shoulda/matchers/active_record/accept_nested_attributes_for_matcher.rb', line 119 def matches?(subject) @subject = subject exists? && allow_destroy_correct? && limit_correct? && update_only_correct? end |
#update_only(update_only) ⇒ Object
114 115 116 117 |
# File 'lib/shoulda/matchers/active_record/accept_nested_attributes_for_matcher.rb', line 114 def update_only(update_only) @options[:update_only] = update_only self end |