Sha256: 2e11c5ae2bb4fbea9406d3214baea5ad06d1d8f1fc2eb6f659d98d900105b88b
Contents?: true
Size: 850 Bytes
Versions: 2
Compression:
Stored size: 850 Bytes
Contents
# frozen_string_literal: true # This module assumes you have `let(:query_string)` in your spec. # It provides `errors` which are the validation errors for that string, # as validated against `DummySchema`. # You can override `schema` to provide another schema # @example testing static validation # include StaticValidationHelpers # let(:query_string) { " ... " } # it "validates" do # assert_equal(errors, [ ... ]) # assert_equal(error_messages, [ ... ]) # end module StaticValidationHelpers def errors target_schema = schema validator = GraphQL::StaticValidation::Validator.new(schema: target_schema) query = GraphQL::Query.new(target_schema, query_string) validator.validate(query)[:errors].map(&:to_h) end def error_messages errors.map { |e| e["message"] } end def schema DummySchema end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
graphql-1.4.0 | spec/support/static_validation_helpers.rb |
graphql-1.3.0 | spec/support/static_validation_helpers.rb |