Class: Consent::Rspec::ConsentView
- Inherits:
-
Object
- Object
- Consent::Rspec::ConsentView
- Defined in:
- lib/consent/rspec/consent_view.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(view_key, conditions) ⇒ ConsentView
constructor
A new instance of ConsentView.
- #matches?(subject_key) ⇒ Boolean
- #to(*context) ⇒ Object
- #with_conditions(conditions) ⇒ Object
Constructor Details
#initialize(view_key, conditions) ⇒ ConsentView
Returns a new instance of ConsentView.
7 8 9 10 |
# File 'lib/consent/rspec/consent_view.rb', line 7 def initialize(view_key, conditions) @conditions = comparable_conditions(conditions) if conditions @view_key = view_key end |
Instance Method Details
#description ⇒ Object
17 18 19 20 |
# File 'lib/consent/rspec/consent_view.rb', line 17 def description = "consents view #{@view_key}" "#{} with conditions #{@conditions}" if @conditions end |
#failure_message ⇒ Object
38 39 40 |
# File 'lib/consent/rspec/consent_view.rb', line 38 def 'to' end |
#failure_message_when_negated ⇒ Object
42 43 44 |
# File 'lib/consent/rspec/consent_view.rb', line 42 def 'to not' end |
#matches?(subject_key) ⇒ Boolean
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/consent/rspec/consent_view.rb', line 27 def matches?(subject_key) @subject_key = subject_key @target = Consent.find_subjects(subject_key) .map do |subject| subject.views[@view_key]&.conditions(*@context) end .compact .map(&method(:comparable_conditions)) @target.include?(@conditions) end |
#to(*context) ⇒ Object
12 13 14 15 |
# File 'lib/consent/rspec/consent_view.rb', line 12 def to(*context) @context = context self end |
#with_conditions(conditions) ⇒ Object
22 23 24 25 |
# File 'lib/consent/rspec/consent_view.rb', line 22 def with_conditions(conditions) @conditions = comparable_conditions(conditions) self end |