Class: RailsAuditLog::Graphql::Testing::RSpecMatchers::HaveGraphqlAuditEntry Private
- Inherits:
-
Object
- Object
- RailsAuditLog::Graphql::Testing::RSpecMatchers::HaveGraphqlAuditEntry
- Defined in:
- lib/rails_audit_log/graphql/testing/rspec_matchers.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
- #failure_message ⇒ Object private
- #failure_message_when_negated ⇒ Object private
-
#for_type(item_type) ⇒ self
private
Requires all matching entries to have
itemTypeequal toitem_type. -
#initialize(event) ⇒ HaveGraphqlAuditEntry
constructor
private
A new instance of HaveGraphqlAuditEntry.
- #matches?(response) ⇒ Boolean private
-
#touching(attribute) ⇒ self
private
Requires at least one matching entry’s
diffto containattribute.
Constructor Details
#initialize(event) ⇒ HaveGraphqlAuditEntry
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of HaveGraphqlAuditEntry.
48 49 50 51 52 |
# File 'lib/rails_audit_log/graphql/testing/rspec_matchers.rb', line 48 def initialize(event) @event = event @touching = nil @item_type = nil end |
Instance Method Details
#failure_message ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
85 86 87 88 89 |
# File 'lib/rails_audit_log/graphql/testing/rspec_matchers.rb', line 85 def "expected GraphQL response to include an audit entry with event #{@event.inspect}" \ "#{touching_clause}#{type_clause}, but it did not.\n" \ "Entries found: #{extract_entries(@response).map { |e| e["event"] }.inspect}" end |
#failure_message_when_negated ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
92 93 94 95 |
# File 'lib/rails_audit_log/graphql/testing/rspec_matchers.rb', line 92 def "expected GraphQL response not to include an audit entry with event #{@event.inspect}" \ "#{touching_clause}#{type_clause}, but one was found." end |
#for_type(item_type) ⇒ self
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Requires all matching entries to have itemType equal to item_type.
68 69 70 71 |
# File 'lib/rails_audit_log/graphql/testing/rspec_matchers.rb', line 68 def for_type(item_type) @item_type = item_type.to_s self end |
#matches?(response) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
74 75 76 77 78 79 80 81 82 |
# File 'lib/rails_audit_log/graphql/testing/rspec_matchers.rb', line 74 def matches?(response) @response = response matched = extract_entries(response).select { |e| e["event"] == @event } matched = matched.select { |e| e["itemType"] == @item_type } if @item_type if @touching matched = matched.select { |e| e["diff"]&.any? { |d| d["attribute"] == @touching } } end matched.any? end |
#touching(attribute) ⇒ self
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Requires at least one matching entry’s diff to contain attribute. The query must include diff { attribute } for this chain to work.
59 60 61 62 |
# File 'lib/rails_audit_log/graphql/testing/rspec_matchers.rb', line 59 def touching(attribute) @touching = attribute.to_s self end |