Class: Consent::Rspec::ConsentAction

Inherits:
Object
  • Object
show all
Defined in:
lib/consent/rspec/consent_action.rb

Instance Method Summary collapse

Constructor Details

#initialize(action_key) ⇒ ConsentAction

Returns a new instance of ConsentAction.



10
11
12
# File 'lib/consent/rspec/consent_action.rb', line 10

def initialize(action_key)
  @action_key = action_key
end

Instance Method Details

#descriptionObject



19
20
21
22
# File 'lib/consent/rspec/consent_action.rb', line 19

def description
  message = "consents action #{@action_key}"
  "#{message} with views #{@views}" if @views
end

#failure_messageObject



37
38
39
# File 'lib/consent/rspec/consent_action.rb', line 37

def failure_message
  failure_message_base "to"
end

#failure_message_when_negatedObject



41
42
43
# File 'lib/consent/rspec/consent_action.rb', line 41

def failure_message_when_negated
  failure_message_base "to not"
end

#matches?(subject_key) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/consent/rspec/consent_action.rb', line 24

def matches?(subject_key)
  @subject_key = subject_key
  @action = Consent.find_action(@subject_key, @action_key)
  if @action && @views
    RSpec::Support::FuzzyMatcher.values_match?(
      @action.views.keys.sort,
      @views.sort
    )
  else
    !@action.nil?
  end
end

#with_views(*views) ⇒ Object



14
15
16
17
# File 'lib/consent/rspec/consent_action.rb', line 14

def with_views(*views)
  @views = views
  self
end