Sha256: fbf689c54cad38eeb18f67624c5b765392da82f658b6f7a4a1b60157ceba4279
Contents?: true
Size: 1.54 KB
Versions: 2
Compression:
Stored size: 1.54 KB
Contents
require "integration_spec_helper" RSpec.describe NulogyMessageBusProducer::Subscription do context "when validating" do it "is invalid with a blank query" do model = build_subscription(query: "") model.validate expect(model.errors[:query]).to contain_exactly("can't be blank") end it "is invalid with blank schema_key" do model = build_subscription(schema_key: "") model.validate expect(model.errors[:schema_key]).to contain_exactly("can't be blank") end it "is invalid with an invalid schema_key" do model = build_subscription(schema_key: "invalid") model.validate expect(model.errors[:query]).to contain_exactly(/Could not find a schema for schema_key 'invalid'/) end it "is invalid with an invalid query" do model = build_subscription( query: subscription_query(query: "foo { a_field_that_does_not_exist }") ) model.validate expect(model).not_to be_valid expect(model.errors[:query]).to contain_exactly( "Field 'a_field_that_does_not_exist' doesn't exist on type 'testObject' (id: <new_record>)" ) end it "valid with a valid query" do model = build_subscription( query: subscription_query(query: "foo { id }") ) model.validate expect(model.errors).not_to include(:query) end end def build_subscription(overrides = {}) attrs = { schema_key: "test", query: subscription_query }.merge(overrides) NulogyMessageBusProducer::Subscription.new(attrs) end end
Version data entries
2 entries across 2 versions & 1 rubygems