Sha256: 41ec44700a3685be5428855bd1bdd5b460a323a6d2480a8d0c7a8635b994f620
Contents?: true
Size: 1.18 KB
Versions: 17
Compression:
Stored size: 1.18 KB
Contents
require "integration_spec_helper" RSpec.describe NulogyMessageBusProducer::Subscriptions::QueryValidator do subject(:validator) { described_class.new } describe "#validate" do context "when a valid query is present" do it "return true" do self_serve_subscription(query: <<~GRAPHQL) foo { id } GRAPHQL expect(validator.validate).to be(true) end end context "when an invalid query is present" do let(:subscription_with_error) do subscription = self_serve_subscription(query: <<~GRAPHQL) foo { id } GRAPHQL subscription.query.gsub!(/\bid\b/, "a_field_that_does_not_exist") subscription.save(validate: false) subscription end it "returns false" do subscription_with_error expect(validator.validate).to be(false) end it "has errors" do subscription_with_error validator.validate expect(validator.errors).to contain_exactly( "Field 'a_field_that_does_not_exist' doesn't exist on type 'testObject' (id: #{subscription_with_error.id})" ) end end end end
Version data entries
17 entries across 17 versions & 1 rubygems