Class: Warp::ControllerMatchers::AssignMatcher
- Defined in:
- lib/warp/controller_matchers/assign_matcher.rb
Instance Attribute Summary collapse
-
#assign_key ⇒ Object
readonly
Returns the value of attribute assign_key.
-
#assign_with ⇒ Object
readonly
Returns the value of attribute assign_with.
-
#assign_with_a ⇒ Object
readonly
Returns the value of attribute assign_with_a.
-
#assign_with_a_new ⇒ Object
readonly
Returns the value of attribute assign_with_a_new.
-
#controller ⇒ Object
readonly
Returns the value of attribute controller.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#failure_message ⇒ Object
readonly
Returns the value of attribute failure_message.
-
#failure_message_when_negated ⇒ Object
readonly
Returns the value of attribute failure_message_when_negated.
Instance Method Summary collapse
-
#initialize(assign_key, controller) ⇒ AssignMatcher
constructor
A new instance of AssignMatcher.
- #matches?(actual) ⇒ Boolean
- #with(assign_eq) ⇒ Object
- #with_a(assign_class) ⇒ Object
- #with_a_new(assign_class) ⇒ Object
Methods inherited from Matcher
#description_of, #failure_message_for_should, #failure_message_for_should_not, #values_match?
Constructor Details
#initialize(assign_key, controller) ⇒ AssignMatcher
Returns a new instance of AssignMatcher.
7 8 9 10 |
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 7 def initialize(assign_key, controller) @assign_key = assign_key @controller = controller end |
Instance Attribute Details
#assign_key ⇒ Object (readonly)
Returns the value of attribute assign_key.
4 5 6 |
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 4 def assign_key @assign_key end |
#assign_with ⇒ Object (readonly)
Returns the value of attribute assign_with.
4 5 6 |
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 4 def assign_with @assign_with end |
#assign_with_a ⇒ Object (readonly)
Returns the value of attribute assign_with_a.
4 5 6 |
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 4 def assign_with_a @assign_with_a end |
#assign_with_a_new ⇒ Object (readonly)
Returns the value of attribute assign_with_a_new.
4 5 6 |
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 4 def assign_with_a_new @assign_with_a_new end |
#controller ⇒ Object (readonly)
Returns the value of attribute controller.
5 6 7 |
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 5 def controller @controller end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
5 6 7 |
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 5 def description @description end |
#failure_message ⇒ Object (readonly)
Returns the value of attribute failure_message.
5 6 7 |
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 5 def @failure_message end |
#failure_message_when_negated ⇒ Object (readonly)
Returns the value of attribute failure_message_when_negated.
5 6 7 |
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 5 def @failure_message_when_negated end |
Instance Method Details
#matches?(actual) ⇒ Boolean
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 27 def matches?(actual) @controller = actual if actual.is_a?(ActionController::Metal) if multiple_assertions? raise "Only one of .with, .with_a, and .with_a_new can be used with the assigns matcher." end return check_assign_with if assign_with return check_assign_with_a if assign_with_a return check_assign_with_a_new if assign_with_a_new return check_assign end |
#with(assign_eq) ⇒ Object
12 13 14 15 |
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 12 def with(assign_eq) @assign_with = assign_eq self end |
#with_a(assign_class) ⇒ Object
17 18 19 20 |
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 17 def with_a(assign_class) @assign_with_a = assign_class self end |
#with_a_new(assign_class) ⇒ Object
22 23 24 25 |
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 22 def with_a_new(assign_class) @assign_with_a_new = assign_class self end |