spec/lib/gqli/introspection_spec.rb in gqli-0.2.0 vs spec/lib/gqli/introspection_spec.rb in gqli-0.3.0
- old
+ new
@@ -52,36 +52,55 @@
}
}
}
expect(subject.valid?(query)).to be_truthy
+
+ validation = subject.validate(query)
+ expect(validation.valid?).to be_truthy
+ expect(validation.errors).to be_empty
end
it 'wrong node returns false' do
query = dsl.query {
foo
}
expect(subject.valid?(query)).to be_falsey
+
+ validation = subject.validate(query)
+ expect(validation.valid?).to be_falsey
+ expect(validation.errors).not_to be_empty
+ expect(validation.errors.map(&:to_s)).to include("Node type not found for 'foo'")
end
it 'object node that doesnt have proper values returns false' do
query = dsl.query {
catCollection
}
expect(subject.valid?(query)).to be_falsey
+
+ validation = subject.validate(query)
+ expect(validation.valid?).to be_falsey
+ expect(validation.errors).not_to be_empty
+ expect(validation.errors.map(&:to_s)).to include("Invalid object for node 'catCollection'")
end
it 'object list node that doesnt have proper values returns false' do
query = dsl.query {
catCollection {
items
}
}
expect(subject.valid?(query)).to be_falsey
+
+ validation = subject.validate(query)
+ expect(validation.valid?).to be_falsey
+ expect(validation.errors).not_to be_empty
+ expect(validation.errors.map(&:to_s)).to include("Invalid object for node 'items'")
end
it 'type matching on invalid type returns false' do
query = dsl.query {
catCollection {
@@ -94,10 +113,15 @@
}
}
}
expect(subject.valid?(query)).to be_falsey
+
+ validation = subject.validate(query)
+ expect(validation.valid?).to be_falsey
+ expect(validation.errors).not_to be_empty
+ expect(validation.errors.map(&:to_s)).to include("Match type 'InvalidType' invalid")
end
it 'invalid arguments return false' do
query = dsl.query {
catCollection(invalidParam: 1) {
@@ -106,10 +130,15 @@
}
}
}
expect(subject.valid?(query)).to be_falsey
+
+ validation = subject.validate(query)
+ expect(validation.valid?).to be_falsey
+ expect(validation.errors).not_to be_empty
+ expect(validation.errors.map(&:to_s)).to include("Invalid argument 'invalidParam'")
end
it 'invalid argument type returns false' do
query = dsl.query {
catCollection(limit: 'foo') {
@@ -118,8 +147,13 @@
}
}
}
expect(subject.valid?(query)).to be_falsey
+
+ validation = subject.validate(query)
+ expect(validation.valid?).to be_falsey
+ expect(validation.errors).not_to be_empty
+ expect(validation.errors.map(&:to_s)).to include("Value is 'String, Enum or ID', but should be 'Int' for 'limit'")
end
end
end