Skip to content

Commit

Permalink
Correctly detect Rails version when using only parts of the framework
Browse files Browse the repository at this point in the history
Follow up rubocop/rubocop#11289.

This commit fixes the following failed tests.

```console
% bundle exec rake
(snip)

Failures:

  1) RuboCop::Config#target_rails_version when TargetRailsVersion is not set and gems.locked exists uses
     the single digit Rails version in gems.locked
     Failure/Error: expect(configuration.target_rails_version).to eq 4.1

       expected: 4.1
            got: 5.0

       (compared using ==)
     # ./spec/rubocop/config_spec.rb:88:in `block (6 levels) in <top (required)>'

  2) RuboCop::Config#target_rails_version when TargetRailsVersion is not set and gems.locked exists uses
     the multi digit Rails version in gems.locked
     Failure/Error: expect(configuration.target_rails_version).to eq 400.33

       expected: 400.33
            got: 5.0

       (compared using ==)
     # ./spec/rubocop/config_spec.rb:122:in `block (6 levels) in <top (required)>'

  3) RuboCop::Config#target_rails_version when TargetRailsVersion is not set and Gemfile.lock exists uses
     the multi digit Rails version in Gemfile.lock
     Failure/Error: expect(configuration.target_rails_version).to eq 400.33

       expected: 400.33
            got: 5.0

       (compared using ==)
     # ./spec/rubocop/config_spec.rb:122:in `block (6 levels) in <top (required)>'

  4) RuboCop::Config#target_rails_version when TargetRailsVersion is not set and Gemfile.lock exists uses
     the single digit Rails version in Gemfile.lock
     Failure/Error: expect(configuration.target_rails_version).to eq 4.1

       expected: 4.1
            got: 5.0

       (compared using ==)
     # ./spec/rubocop/config_spec.rb:88:in `block (6 levels) in <top (required)>'

Finished in 0.05343 seconds (files took 1.28 seconds to load)
11 examples, 4 failures

Failed examples:

rspec './spec/rubocop/config_spec.rb[1:1:2:3:1]' # RuboCop::Config#target_rails_version when TargetRailsVersion
is not set and gems.locked exists uses the single digit Rails version in gems.locked
rspec './spec/rubocop/config_spec.rb[1:1:2:3:2]' # RuboCop::Config#target_rails_version when TargetRailsVersion
is not set and gems.locked exists uses the multi digit Rails version in gems.locked
rspec './spec/rubocop/config_spec.rb[1:1:2:2:2]' # RuboCop::Config#target_rails_version when TargetRailsVersion
is not set and Gemfile.lock exists uses the multi digit Rails version in Gemfile.lock
rspec './spec/rubocop/config_spec.rb[1:1:2:2:1]' # RuboCop::Config#target_rails_version when TargetRailsVersion
is not set and Gemfile.lock exists uses the single digit Rails version in Gemfile.lock
```
  • Loading branch information
koic committed Dec 18, 2022
1 parent b9f852b commit b930670
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions spec/rubocop/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
bundler (>= 1.3.0, < 2.0)
railties (= 4.1.0)
sprockets-rails (~> 2.0)
railties (4.1.0)
PLATFORMS
ruby
Expand Down Expand Up @@ -108,6 +109,7 @@
bundler (>= 1.3.0, < 2.0)
railties (= 4.1.0)
sprockets-rails (~> 2.0)
railties (400.33.22)
PLATFORMS
ruby
Expand Down

0 comments on commit b930670

Please sign in to comment.