sj26 / rspec_junit_formatter

RSpec results that your CI can read
http://rubygems.org/gems/rspec_junit_formatter
MIT License
302 stars 122 forks source link

Add `require: false` to Gemfile example #101

Closed r7kamura closed 1 year ago

r7kamura commented 1 year ago

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 commented 1 year ago

Nice idea, thanks!