class Shoulda::Matchers::ActionController::SetSessionMatcher
@private
Public Class Methods
new(key)
click to toggle source
# File lib/shoulda/matchers/action_controller/set_session_matcher.rb, line 74 def initialize(key) @key = key.to_s end
Public Instance Methods
description()
click to toggle source
# File lib/shoulda/matchers/action_controller/set_session_matcher.rb, line 102 def description description = "set session variable #{@key.inspect}" if @value description << " to #{@value.inspect}" end description end
failure_message()
click to toggle source
# File lib/shoulda/matchers/action_controller/set_session_matcher.rb, line 92 def failure_message "Expected #{expectation}, but #{result}" end
Also aliased as: failure_message_for_should
failure_message_when_negated()
click to toggle source
# File lib/shoulda/matchers/action_controller/set_session_matcher.rb, line 97 def failure_message_when_negated "Didn't expect #{expectation}, but #{result}" end
Also aliased as: failure_message_for_should_not
in_context(context)
click to toggle source
# File lib/shoulda/matchers/action_controller/set_session_matcher.rb, line 110 def in_context(context) @context = context self end
matches?(controller)
click to toggle source
# File lib/shoulda/matchers/action_controller/set_session_matcher.rb, line 84 def matches?(controller) @controller = controller if @value_block @value = @context.instance_eval(&@value_block) end assigned_correct_value? || cleared_value? end
to(value = nil, &block)
click to toggle source
# File lib/shoulda/matchers/action_controller/set_session_matcher.rb, line 78 def to(value = nil, &block) @value = value @value_block = block self end
Private Instance Methods
assigned_correct_value?()
click to toggle source
# File lib/shoulda/matchers/action_controller/set_session_matcher.rb, line 125 def assigned_correct_value? if assigned_value? if @value.nil? true else assigned_value == @value end end end
assigned_value()
click to toggle source
# File lib/shoulda/matchers/action_controller/set_session_matcher.rb, line 135 def assigned_value session[@key] end
assigned_value?()
click to toggle source
# File lib/shoulda/matchers/action_controller/set_session_matcher.rb, line 117 def assigned_value? !assigned_value.nil? end
cleared_value?()
click to toggle source
# File lib/shoulda/matchers/action_controller/set_session_matcher.rb, line 121 def cleared_value? defined?(@value) && @value.nil? && assigned_value.nil? end
expectation()
click to toggle source
# File lib/shoulda/matchers/action_controller/set_session_matcher.rb, line 139 def expectation expectation = "session variable #{@key} to be set" if @value expectation << " to #{@value.inspect}" end end
result()
click to toggle source
# File lib/shoulda/matchers/action_controller/set_session_matcher.rb, line 146 def result if session.empty? 'no session variables were set' else "the session was #{session.inspect}" end end
session()
click to toggle source
# File lib/shoulda/matchers/action_controller/set_session_matcher.rb, line 154 def session if @controller.request.respond_to?(:session) @controller.request.session.to_hash else @controller.response.session.data end end