Comments (3)
I actually got this working. It might be helpful to include a little bit extra in the README.md to help others, I'm happy to raise a PR if it would help?
Add the following to spec_helper.rb
require 'rspec/graphql_matchers'
include RSpec::GraphqlMatchers::TypesHelper
I also included in the config config.expose_dsl_globally = true
Then my test file became:
describe Types::JourneyType do
subject { described_class }
it { is_expected.to have_field(:arrivalDateTime) }
it { is_expected.to have_field(:startDateTime) }
it { is_expected.to have_field(:duration) }
end
from rspec-graphql_matchers.
@mathewtrivett first of all, sorry for taking soooooooo long to reply. Things have been crazy and notifications got lost.
So, I'm not sure why it didn't work for you in the first place. Looking at the error message, it looks like it has nothing to do with the gem. It just says a constant was not found. JourneyType
is a constant as any other, and if your spec file can't find it... 💥
From your proposed solution I guess your constant is not defined at the root of the module namespace, but under Types
. In that case, what solved your issue was using the fully qualified constant name Types::JourneyType
.
The module RSpec::GraphqlMatchers::TypesHelper
is actually deprecated. I invite you to remove it and try running the specs again. It was a helper created for much older versions of the graphql gem (before the class / module interface for defining types was introduced), and it has been kept on the codebase for compatibility reasons only. I guess it's safe to remove it on the next release...
from rspec-graphql_matchers.
Try to remove
require 'rspec/graphql_matchers'
include RSpec::GraphqlMatchers::TypesHelper
from your spec_helper.rb and make sure you've got --require rails_helper
in your .rspec
instead of --require spec_helper
.
HTH
Tobi
from rspec-graphql_matchers.
Related Issues (20)
- Unable to `include RSpec::GraphqlMatchers::TypesHelper` HOT 4
- add has_metadata matcher on object type HOT 1
- add support for `with_deprecation_reason` HOT 2
- Type specs fail after graphql-ruby changed behavior of Type classes HOT 3
- Specs fail with "types" syntax HOT 1
- Cannot use with new version of graphql gem HOT 1
- Problem with `.have_field` and `.of_type` HOT 3
- expected Types::ClassName to respond to `has_a_field?` HOT 2
- Supporting version 1.9 ? HOT 1
- Convert :field_name to 'fieldName' automaticallly HOT 1
- Test resolution with property HOT 2
- Version 1.2 missing support for snake_case field names HOT 2
- Proposition: add a matcher chain for :method on field definition HOT 1
- undefined method `failure_message_when_negated'
- Test GraphQL::Schema::Enum HOT 1
- .Legacy `.to_graphql` objects are deprecated and will be removed in GraphQL-Ruby 2.0. HOT 1
- Support graphql 2.0 HOT 5
- A suggestion split FE types and BE types expectations HOT 1
- add a description matcher on the field HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rspec-graphql_matchers.