Module: RailsAuditLog::Graphql::Testing::MinitestAssertions
- Defined in:
- lib/rails_audit_log/graphql/testing/minitest_assertions.rb
Overview
Minitest assertions for GraphQL audit log entries.
Include this module in a test class or in a shared support file:
class ActiveSupport::TestCase
include RailsAuditLog::Graphql::Testing::MinitestAssertions
end
The assertions inspect the auditLogEntries and auditLogEntriesConnection.nodes keys in the response data. To use the touching: option, include diff { attribute } in your GraphQL query.
Instance Method Summary collapse
-
#assert_graphql_audit_entry(response, event:, touching: nil, item_type: nil, message: nil) ⇒ Object
Asserts that the GraphQL response contains at least one audit log entry matching the given criteria.
-
#refute_graphql_audit_entry(response, event:, touching: nil, item_type: nil, message: nil) ⇒ Object
Asserts that the GraphQL response does NOT contain an audit log entry matching the given criteria.
Instance Method Details
#assert_graphql_audit_entry(response, event:, touching: nil, item_type: nil, message: nil) ⇒ Object
Asserts that the GraphQL response contains at least one audit log entry matching the given criteria.
35 36 37 38 39 |
# File 'lib/rails_audit_log/graphql/testing/minitest_assertions.rb', line 35 def assert_graphql_audit_entry(response, event:, touching: nil, item_type: nil, message: nil) matched = filter_entries(response, event: event, touching: touching, item_type: item_type) default_msg = ("Expected", event, touching, item_type) assert matched.any?, || default_msg end |
#refute_graphql_audit_entry(response, event:, touching: nil, item_type: nil, message: nil) ⇒ Object
Asserts that the GraphQL response does NOT contain an audit log entry matching the given criteria.
49 50 51 52 53 |
# File 'lib/rails_audit_log/graphql/testing/minitest_assertions.rb', line 49 def refute_graphql_audit_entry(response, event:, touching: nil, item_type: nil, message: nil) matched = filter_entries(response, event: event, touching: touching, item_type: item_type) default_msg = ("Expected no", event, touching, item_type) refute matched.any?, || default_msg end |