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



40
41
42
43
44
# File 'lib/shoulda/action_controller/matchers/set_session_matcher.rb', line 40

def description
  description = "set session variable #{@key.inspect}"
  description << " to #{@value.inspect}" if defined?(@value)
  description
end

#failure_messageObject



32
33
34
# File 'lib/shoulda/action_controller/matchers/set_session_matcher.rb', line 32

def failure_message
  "Expected #{expectation}, but #{result}"
end

#matches?(controller) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
30
# File 'lib/shoulda/action_controller/matchers/set_session_matcher.rb', line 27

def matches?(controller)
  @controller = controller
  (assigned_value? && assigned_correct_value?) || cleared_value?
end

#negative_failure_messageObject



36
37
38
# File 'lib/shoulda/action_controller/matchers/set_session_matcher.rb', line 36

def negative_failure_message
  "Didn't expect #{expectation}, but #{result}"
end

#to(value) ⇒ Object



22
23
24
25
# File 'lib/shoulda/action_controller/matchers/set_session_matcher.rb', line 22

def to(value)
  @value = value
  self
end