Sha256: e31cf4e61389c29d18170d6643e654ce15593ac784c4ff2e024d0a25e40fdba1

Contents?: true

Size: 808 Bytes

Versions: 5

Compression:

Stored size: 808 Bytes

Contents

# 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]
  end

  def error_messages
    errors.map { |e| e["message"] }
  end

  def schema
    DummySchema
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
graphql-0.19.4 spec/support/static_validation_helpers.rb
graphql-0.19.3 spec/support/static_validation_helpers.rb
graphql-0.19.2 spec/support/static_validation_helpers.rb
graphql-0.19.1 spec/support/static_validation_helpers.rb
graphql-0.19.0 spec/support/static_validation_helpers.rb