class Shoulda::Matchers::ActionController::SetSessionOrFlashMatcher
@private
def [](key)
def [](key) @key = key self end
def context_set?
def context_set? defined?(@context) end
def description
def description "should #{expectation_description}" end
def expectation_description
def expectation_description String.new('set').tap do |string| string << if key_set? " #{store.name}[#{key.inspect}]" else " any key in #{store.name}" end if expected_value_set? string << if expected_value.is_a?(Regexp) " to a value matching #{expected_value.inspect}" else " to #{expected_value.inspect}" end end end end
def expected_value_matches?
def expected_value_matches? !expected_value_set? || store.has_value?(expected_value) end
def expected_value_set?
def expected_value_set? defined?(@expected_value) end
def failure_message
def failure_message "Expected #{controller.class} to #{expectation_description},"\ ' but it did not' end
def failure_message_when_negated
def failure_message_when_negated "Expected #{controller.class} not to #{expectation_description},"\ ' but it did' end
def in_context(context)
def in_context(context) @context = context self end
def initialize(store)
def initialize(store) @store = store end
def key_matches?
def key_matches? !key_set? || store.has_key?(key) end
def key_set?
def key_set? defined?(@key) end
def matches?(controller)
def matches?(controller) @controller = store.controller = controller !store.empty? && key_matches? && expected_value_matches? end
def to(expected_value = nil, &block)
def to(expected_value = nil, &block) if block unless context_set? message = 'When specifying a value as a block, a context must be'\ ' specified beforehand,'\ " e.g., #{store.name}.in_context(context).to { ... }" raise ArgumentError, message end @expected_value = context.instance_eval(&block) else @expected_value = expected_value end self end