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

Removes hard-coded 'ENV['RAILS_ENV']=='test' check from railtie.rb #114

Merged
merged 1 commit into from
Sep 24, 2022

Conversation

Qqwy
Copy link
Contributor

@Qqwy Qqwy commented Sep 24, 2022

The hard-coded check in https://github.com/metaskills/minitest-spec-rails/blob/master/lib/minitest-spec-rails/railtie.rb#L6 made it impossible to use specs in custom testing environments.

Instead of hard-coding this, it makes more sense to include the code whenever the gem is loaded. (i.e. using the groups in the Gemfile).

The hard-coded check in https://github.com/metaskills/minitest-spec-rails/blob/master/lib/minitest-spec-rails/railtie.rb#L6 made it impossible to use specs in custom testing environments. 

Instead of hard-coding this, it makes more sense to include the code whenever the gem is loaded. (i.e. using the groups in the Gemfile).
@metaskills
Copy link
Owner

Hmmm... I'm sure this was here for some reason. Wont removing it mean that we would load a bunch of test code in other envs like prod? Maybe it is doing that anyway?

@Qqwy
Copy link
Contributor Author

Qqwy commented Sep 24, 2022

Wont removing it mean that we would load a bunch of test code in other envs like prod? Maybe it is doing that anyway?

According to the readme, the recommended way to use minitest-spec-rails is

group :test do
  gem 'minitest-spec-rails'
end

which would result in the gem only being loaded in the test environment.

If you want to use it in another environment, such as in e.g. a specialized benchmarking environment, you can change it to

group :test, :benchmarking do
  gem 'minitest-spec-rails'
end

As far as I understand how Bundle and Rails work, this should be enough to ensure that the code is included only when the app runs in this particular environment.

@metaskills
Copy link
Owner

Oh yea, good point. I'll merge this in and cut a new version.

@metaskills metaskills merged commit ec3662f into metaskills:master Sep 24, 2022
@metaskills
Copy link
Owner

Now live on Rubygems v6.2.0. Thanks so much for taking the time to make a pull request. Cheers!

@Qqwy
Copy link
Contributor Author

Qqwy commented Sep 25, 2022

Thank you very much! Cheers! 💚

Qqwy added a commit to Qqwy/minitest-spec-rails that referenced this pull request Sep 25, 2022
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.

None yet

2 participants