Class: Shoulda::Matchers::ActionController::FlashStore

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeFlashStore

Returns a new instance of FlashStore.



17
18
19
# File 'lib/shoulda/matchers/action_controller/flash_store.rb', line 17

def initialize
  @use_now = false
end

Instance Attribute Details

#controllerObject

Returns the value of attribute controller.



15
16
17
# File 'lib/shoulda/matchers/action_controller/flash_store.rb', line 15

def controller
  @controller
end

Class Method Details

.futureObject



7
8
9
# File 'lib/shoulda/matchers/action_controller/flash_store.rb', line 7

def self.future
  new
end

.nowObject



11
12
13
# File 'lib/shoulda/matchers/action_controller/flash_store.rb', line 11

def self.now
  new.use_now!
end

Instance Method Details

#has_key?(key) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/shoulda/matchers/action_controller/flash_store.rb', line 29

def has_key?(key)
  values_to_check.include?(key.to_s)
end

#has_value?(expected_value) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
36
37
# File 'lib/shoulda/matchers/action_controller/flash_store.rb', line 33

def has_value?(expected_value)
  values_to_check.values.any? do |actual_value|
    expected_value === actual_value
  end
end

#nameObject



21
22
23
24
25
26
27
# File 'lib/shoulda/matchers/action_controller/flash_store.rb', line 21

def name
  if @use_now
    'flash.now'
  else
    'flash'
  end
end

#use_now!Object



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

def use_now!
  @use_now = true
  self
end