Class: Shoulda::ActionController::Matchers::AssignToMatcher
- Inherits:
-
Object
- Object
- Shoulda::ActionController::Matchers::AssignToMatcher
- Defined in:
- lib/shoulda/action_controller/matchers/assign_to_matcher.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#failure_message ⇒ Object
readonly
Returns the value of attribute failure_message.
-
#negative_failure_message ⇒ Object
readonly
Returns the value of attribute negative_failure_message.
Instance Method Summary collapse
- #description ⇒ Object
-
#initialize(variable) ⇒ AssignToMatcher
constructor
A new instance of AssignToMatcher.
- #matches?(controller) ⇒ Boolean
- #with(expected_value) ⇒ Object
- #with_kind_of(expected_class) ⇒ Object
Constructor Details
#initialize(variable) ⇒ AssignToMatcher
Returns a new instance of AssignToMatcher.
24 25 26 |
# File 'lib/shoulda/action_controller/matchers/assign_to_matcher.rb', line 24 def initialize(variable) @variable = variable.to_s end |
Instance Attribute Details
#failure_message ⇒ Object (readonly)
Returns the value of attribute failure_message.
43 44 45 |
# File 'lib/shoulda/action_controller/matchers/assign_to_matcher.rb', line 43 def end |
#negative_failure_message ⇒ Object (readonly)
Returns the value of attribute negative_failure_message.
43 44 45 |
# File 'lib/shoulda/action_controller/matchers/assign_to_matcher.rb', line 43 def end |
Instance Method Details
#description ⇒ Object
45 46 47 48 49 |
# File 'lib/shoulda/action_controller/matchers/assign_to_matcher.rb', line 45 def description description = "assign @#{@variable}" description << " with a kind of #{@expected_class}" if @expected_class description end |
#matches?(controller) ⇒ Boolean
38 39 40 41 |
# File 'lib/shoulda/action_controller/matchers/assign_to_matcher.rb', line 38 def matches?(controller) @controller = controller assigned_value? && kind_of_expected_class? && equal_to_expected_value? end |
#with(expected_value) ⇒ Object
33 34 35 36 |
# File 'lib/shoulda/action_controller/matchers/assign_to_matcher.rb', line 33 def with(expected_value) @expected_value = expected_value self end |
#with_kind_of(expected_class) ⇒ Object
28 29 30 31 |
# File 'lib/shoulda/action_controller/matchers/assign_to_matcher.rb', line 28 def with_kind_of(expected_class) @expected_class = expected_class self end |