Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

`gem "graphiti_spec_helpers", require: "graphiti_spec_helpers/rspec” doesn't have rspec loaded #18

Open
jasonfb opened this issue Apr 6, 2022 · 0 comments · May be fixed by #19
Open

Comments

@jasonfb
Copy link

jasonfb commented Apr 6, 2022

when including graphiti this way, there is no require 'rspec' at the top of the file https://github.com/graphiti-api/graphiti_spec_helpers/blob/master/lib/graphiti_spec_helpers/rspec.rb

as a result this doesn't work in the rails app:

gem "graphiti_spec_helpers", require: "graphiti_spec_helpers/rspec"

cc: @jasonkarns

jasonkarns added a commit to jasonkarns/graphiti_spec_helpers that referenced this issue Oct 26, 2022
The rspec matchers depend on rspec-core already being loaded (or being autoloaded).

However, apps that leverage Bundlers `require:` option for specifying the entrypoint file to be loaded by Bundle.require will not necessarily have autoloading configured at that point (if ever). This ensures that should the rspec.rb file be loaded prior to rspec, it will properly require rspec/core so that the RSpec references actually work.

And the end result is that users don't need to explicitly `require 'graphiti_spec_helpers'` in a spec-helper at all, but may instead simply adjust their Gemfile:
```
group :test do
    gem "graphiti_spec_helpers", require: "graphiti_spec_helpers/rspec"
end
```

fixes graphiti-api#18
@jasonkarns jasonkarns linked a pull request Oct 26, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant