Giter Site home page Giter Site logo

Comments (3)

mathewtrivett avatar mathewtrivett commented on August 24, 2024 2

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.

khamusa avatar khamusa commented on August 24, 2024

@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.

tobmatth avatar tobmatth commented on August 24, 2024

@mathewtrivett

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.