Class: Warp::ControllerMatchers::SetFlashMatcher

Inherits:
Matcher
  • Object
show all
Defined in:
lib/warp/controller_matchers/set_flash_matcher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Matcher

#description_of, #failure_message_for_should, #failure_message_for_should_not, #values_match?

Constructor Details

#initialize(flash_key, controller) ⇒ SetFlashMatcher

Returns a new instance of SetFlashMatcher.



7
8
9
10
# File 'lib/warp/controller_matchers/set_flash_matcher.rb', line 7

def initialize(flash_key, controller)
  @flash_key = flash_key
  @controller = controller
end

Instance Attribute Details

#controllerObject (readonly)

Returns the value of attribute controller.



5
6
7
# File 'lib/warp/controller_matchers/set_flash_matcher.rb', line 5

def controller
  @controller
end

#descriptionObject (readonly)

Returns the value of attribute description.



5
6
7
# File 'lib/warp/controller_matchers/set_flash_matcher.rb', line 5

def description
  @description
end

#expected_flash_valueObject (readonly)

Returns the value of attribute expected_flash_value.



4
5
6
# File 'lib/warp/controller_matchers/set_flash_matcher.rb', line 4

def expected_flash_value
  @expected_flash_value
end

#failure_messageObject (readonly)

Returns the value of attribute failure_message.



5
6
7
# File 'lib/warp/controller_matchers/set_flash_matcher.rb', line 5

def failure_message
  @failure_message
end

#failure_message_when_negatedObject (readonly)

Returns the value of attribute failure_message_when_negated.



5
6
7
# File 'lib/warp/controller_matchers/set_flash_matcher.rb', line 5

def failure_message_when_negated
  @failure_message_when_negated
end

#flash_keyObject (readonly)

Returns the value of attribute flash_key.



4
5
6
# File 'lib/warp/controller_matchers/set_flash_matcher.rb', line 4

def flash_key
  @flash_key
end

Instance Method Details

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
20
21
22
# File 'lib/warp/controller_matchers/set_flash_matcher.rb', line 17

def matches?(actual)
  @controller = actual if actual.is_a?(ActionController::Metal)

  return check_expected_value if expected_flash_value
  return check_assigned
end

#to(expected_flash_value) ⇒ Object



12
13
14
15
# File 'lib/warp/controller_matchers/set_flash_matcher.rb', line 12

def to(expected_flash_value)
  @expected_flash_value = expected_flash_value
  self
end