Class: Warp::ControllerMatchers::AssignWithANewMatcher
- Inherits:
-
AssignMatcher
- Object
- Matcher
- AssignMatcher
- Warp::ControllerMatchers::AssignWithANewMatcher
- Defined in:
- lib/warp/controller_matchers/assign_matcher.rb
Instance Attribute Summary collapse
-
#assign_with_a_new ⇒ Object
readonly
Returns the value of attribute assign_with_a_new.
Attributes inherited from AssignMatcher
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(controller, assign_key, assign_with_a_new) ⇒ AssignWithANewMatcher
constructor
A new instance of AssignWithANewMatcher.
Methods inherited from AssignMatcher
Constructor Details
#initialize(controller, assign_key, assign_with_a_new) ⇒ AssignWithANewMatcher
Returns a new instance of AssignWithANewMatcher.
144 145 146 147 |
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 144 def initialize(controller, assign_key, assign_with_a_new) super(controller, assign_key) @assign_with_a_new = assign_with_a_new end |
Instance Attribute Details
#assign_with_a_new ⇒ Object (readonly)
Returns the value of attribute assign_with_a_new.
142 143 144 |
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 142 def assign_with_a_new @assign_with_a_new end |
Instance Method Details
#description ⇒ Object
149 150 151 |
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 149 def description "assign @#{assign_key} with a new instance of #{assign_with_a_new.name}" end |
#failure_message ⇒ Object
153 154 155 156 157 158 159 |
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 153 def if assign_value.nil? "expected @#{assign_key} to be assigned with a new instance of #{assign_with_a_new.name} but was not assigned" else "expected @#{assign_key} to be assigned with a new instance of #{assign_with_a_new.name} but was assigned with a #{assign_value.try(:persisted?) ? "persisted" : "new"} instance of #{assign_value.class.name}" end end |
#failure_message_when_negated ⇒ Object
161 162 163 |
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 161 def "expected @#{assign_key} to not be assigned with a new instance of #{assign_with_a_new.name}" end |