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

ActiveSupport::StringInquirer does a regexp check instead of direct match #1091

Closed
wants to merge 1 commit into from
Closed

ActiveSupport::StringInquirer does a regexp check instead of direct match #1091

wants to merge 1 commit into from

Conversation

itsmeduncan
Copy link
Contributor

This adds the convenience of allowing developers to continue to use the simple boolean check on multiple environments. We use parallel_spec which creates test[1..4], breaking our .test? assumptions. This fixes that issue by doing a regexp check on the string.

RAILS_ENV=test
Rails.env.test? #=> true
RAILS_ENV=test1
Rails.env.test? #=> true

@tomafro
Copy link
Contributor

tomafro commented May 16, 2011

I would expect StringInquirer to return true only when given a full match. While the example you've provided almost makes sense to me (as the range of environments is likely to be limited), there are many other uses for it other than environment checking. To get the behaviour you want, to me Rails.env.starts_with?("test") is both more explicit and more correct.

@josevalim
Copy link
Contributor

I agree with @tomafro. It may make sense for Rails.env, but that would totally break all other use cases for StringInquirier.

@josevalim josevalim closed this May 16, 2011
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

3 participants