Class: Shoulda::ActionController::Matchers::SetSessionMatcher
- Inherits:
-
Object
- Object
- Shoulda::ActionController::Matchers::SetSessionMatcher
- Defined in:
- lib/shoulda/action_controller/matchers/set_session_matcher.rb
Overview
:nodoc:
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
- #in_context(context) ⇒ Object
-
#initialize(key) ⇒ SetSessionMatcher
constructor
A new instance of SetSessionMatcher.
- #matches?(controller) ⇒ Boolean
- #negative_failure_message ⇒ Object
- #to(value = nil, &block) ⇒ Object
Constructor Details
#initialize(key) ⇒ SetSessionMatcher
Returns a new instance of SetSessionMatcher.
18 19 20 |
# File 'lib/shoulda/action_controller/matchers/set_session_matcher.rb', line 18 def initialize(key) @key = key.to_s end |
Instance Method Details
#description ⇒ Object
42 43 44 45 46 |
# File 'lib/shoulda/action_controller/matchers/set_session_matcher.rb', line 42 def description description = "set session variable #{@key.inspect}" description << " to #{@value.inspect}" if defined?(@value) description end |
#failure_message ⇒ Object
34 35 36 |
# File 'lib/shoulda/action_controller/matchers/set_session_matcher.rb', line 34 def "Expected #{expectation}, but #{result}" end |
#in_context(context) ⇒ Object
48 49 50 51 |
# File 'lib/shoulda/action_controller/matchers/set_session_matcher.rb', line 48 def in_context(context) @context = context self end |
#matches?(controller) ⇒ Boolean
28 29 30 31 32 |
# File 'lib/shoulda/action_controller/matchers/set_session_matcher.rb', line 28 def matches?(controller) @controller = controller @value = @context.instance_eval(&@value_block) if @value_block (assigned_value? && assigned_correct_value?) || cleared_value? end |
#negative_failure_message ⇒ Object
38 39 40 |
# File 'lib/shoulda/action_controller/matchers/set_session_matcher.rb', line 38 def "Didn't expect #{expectation}, but #{result}" end |
#to(value = nil, &block) ⇒ Object
22 23 24 25 26 |
# File 'lib/shoulda/action_controller/matchers/set_session_matcher.rb', line 22 def to(value = nil, &block) @value = value @value_block = block self end |