Class: Shoulda::ActionController::Matchers::SetSessionMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/shoulda/action_controller/matchers/set_session_matcher.rb

Overview

:nodoc:

Instance Method Summary collapse

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

#descriptionObject



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_messageObject



34
35
36
# File 'lib/shoulda/action_controller/matchers/set_session_matcher.rb', line 34

def failure_message
  "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

Returns:

  • (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_messageObject



38
39
40
# File 'lib/shoulda/action_controller/matchers/set_session_matcher.rb', line 38

def negative_failure_message
  "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