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

Add require: false to Gemfile example #101

Merged
merged 1 commit into from
Nov 29, 2022

Conversation

r7kamura
Copy link
Contributor

RSpec has the ability to automatically load custom formatter that follows the naming conventions properly, so there is no need to have Bundler.require load it for you.

Adding this require: false makes it more profitable to have it loaded only when needed (e.g. only in CI if you use this formatter only in CI).

I don't think many people want to output JUnit format files locally, so it will cut down on unnecessary loading in many cases. Also, this README Gemfile example is probably close to the example used in a typical Rails app, so many Rails users will benefit from this.

This change also eliminates another problem. If you run require 'rspec/core' before the appropriate time, Kernel.#context will be defined and you will get a warning when you load irb. The following Issue provides more information on this issue.

Since rspec_junit_formatter executes require 'rspec/core' when loaded, it causes this problem when loaded with Bundler.require. This require: false also resolves this problem.

$ bin/rails c -e test
Loading test environment (Rails 7.0.4)
irb: warn: can't alias context from irb_context.
irb(main):001:0> exit

@sj26
Copy link
Owner

sj26 commented Nov 29, 2022

Nice idea, thanks!

@sj26 sj26 merged commit d20e820 into sj26:main Nov 29, 2022
@r7kamura r7kamura deleted the feature/require-false branch November 29, 2022 01:28
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 this pull request may close these issues.

2 participants