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

Constructor Details

#initialize(flash_key, controller) ⇒ SetFlashMatcher

Returns a new instance of SetFlashMatcher.



9
10
11
12
# File 'lib/warp/controller_matchers/set_flash_matcher.rb', line 9

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

Instance Attribute Details

#controllerObject (readonly)

Returns the value of attribute controller.



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

def controller
  @controller
end

#descriptionObject (readonly)

Returns the value of attribute description.



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

def description
  @description
end

#expected_flash_valueObject (readonly)

Returns the value of attribute expected_flash_value.



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

def expected_flash_value
  @expected_flash_value
end

#failure_messageObject (readonly)

Returns the value of attribute failure_message.



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

def failure_message
  @failure_message
end

#failure_message_when_negatedObject (readonly)

Returns the value of attribute failure_message_when_negated.



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

def failure_message_when_negated
  @failure_message_when_negated
end

#flash_keyObject (readonly)

Returns the value of attribute flash_key.



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

def flash_key
  @flash_key
end

Instance Method Details

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


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

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



14
15
16
17
# File 'lib/warp/controller_matchers/set_flash_matcher.rb', line 14

def to(expected_flash_value)
  @expected_flash_value = expected_flash_value
  self
end