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.
9 10 11 12 |
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 9 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.
6 7 8 |
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 6 def assign_key @assign_key end |
#assign_with ⇒ Object (readonly)
Returns the value of attribute assign_with.
6 7 8 |
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 6 def assign_with @assign_with end |
#assign_with_a ⇒ Object (readonly)
Returns the value of attribute assign_with_a.
6 7 8 |
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 6 def assign_with_a @assign_with_a end |
#assign_with_a_new ⇒ Object (readonly)
Returns the value of attribute assign_with_a_new.
6 7 8 |
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 6 def assign_with_a_new @assign_with_a_new end |
#controller ⇒ Object (readonly)
Returns the value of attribute controller.
7 8 9 |
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 7 def controller @controller end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
7 8 9 |
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 7 def description @description end |
#failure_message ⇒ Object (readonly)
Returns the value of attribute failure_message.
7 8 9 |
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 7 def @failure_message end |
#failure_message_when_negated ⇒ Object (readonly)
Returns the value of attribute failure_message_when_negated.
7 8 9 |
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 7 def @failure_message_when_negated end |
Instance Method Details
#matches?(actual) ⇒ Boolean
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 29 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
14 15 16 17 |
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 14 def with(assign_eq) @assign_with = assign_eq self end |
#with_a(assign_class) ⇒ Object
19 20 21 22 |
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 19 def with_a(assign_class) @assign_with_a = assign_class self end |
#with_a_new(assign_class) ⇒ Object
24 25 26 27 |
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 24 def with_a_new(assign_class) @assign_with_a_new = assign_class self end |