Class: Shoulda::Matchers::ActionController::SetSessionOrFlashMatcher
- Inherits:
-
Object
- Object
- Shoulda::Matchers::ActionController::SetSessionOrFlashMatcher
- Defined in:
- lib/shoulda/matchers/action_controller/set_session_or_flash_matcher.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #description ⇒ Object
- #failure_message ⇒ Object (also: #failure_message_for_should)
- #failure_message_when_negated ⇒ Object (also: #failure_message_for_should_not)
- #in_context(context) ⇒ Object
-
#initialize(store) ⇒ SetSessionOrFlashMatcher
constructor
A new instance of SetSessionOrFlashMatcher.
- #matches?(controller) ⇒ Boolean
- #to(expected_value = nil, &block) ⇒ Object
Constructor Details
#initialize(store) ⇒ SetSessionOrFlashMatcher
Returns a new instance of SetSessionOrFlashMatcher.
6 7 8 |
# File 'lib/shoulda/matchers/action_controller/set_session_or_flash_matcher.rb', line 6 def initialize(store) @store = store end |
Instance Method Details
#[](key) ⇒ Object
15 16 17 18 |
# File 'lib/shoulda/matchers/action_controller/set_session_or_flash_matcher.rb', line 15 def [](key) @key = key self end |
#description ⇒ Object
37 38 39 |
# File 'lib/shoulda/matchers/action_controller/set_session_or_flash_matcher.rb', line 37 def description "should #{expectation_description}" end |
#failure_message ⇒ Object Also known as: failure_message_for_should
46 47 48 49 |
# File 'lib/shoulda/matchers/action_controller/set_session_or_flash_matcher.rb', line 46 def "Expected #{controller.class} to #{expectation_description},"\ ' but it did not' end |
#failure_message_when_negated ⇒ Object Also known as: failure_message_for_should_not
52 53 54 55 |
# File 'lib/shoulda/matchers/action_controller/set_session_or_flash_matcher.rb', line 52 def "Expected #{controller.class} not to #{expectation_description},"\ ' but it did' end |
#in_context(context) ⇒ Object
10 11 12 13 |
# File 'lib/shoulda/matchers/action_controller/set_session_or_flash_matcher.rb', line 10 def in_context(context) @context = context self end |
#matches?(controller) ⇒ Boolean
41 42 43 44 |
# File 'lib/shoulda/matchers/action_controller/set_session_or_flash_matcher.rb', line 41 def matches?(controller) @controller = store.controller = controller !store.empty? && key_matches? && expected_value_matches? end |
#to(expected_value = nil, &block) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/shoulda/matchers/action_controller/set_session_or_flash_matcher.rb', line 20 def to(expected_value = nil, &block) if block unless context_set? = 'When specifying a value as a block, a context must be'\ ' specified beforehand,'\ " e.g., #{store.name}.in_context(context).to { ... }" raise ArgumentError, end @expected_value = context.instance_eval(&block) else @expected_value = expected_value end self end |