Skip to content

Commit

Permalink
Implicit dependency on RuboCop RSpec
Browse files Browse the repository at this point in the history
It is extracted from RuboCop RSpec, but needs to rely on rubocop-rspec_rails from RuboCop RSpec, and RuboCop RSpec Rails also needs to rely on rubocop-rspec. This makes them interdependent, and if you explicitly specify a dependency, you are stuck in an infinite loop.

```
❯ bundle install
Your bundle requires gems that depend on each other, creating an infinite loop. Please remove either gem 'rubocop-rspec' or gem 'rubocop-rspec_rails' and try again.
```

Therefore, this PR changes the dependency to be implicit. The next major version update of RuboCop RSpec will remove the dependency on rubocop-rspec_rails, so we will change the dependency to be explicit at that point.
  • Loading branch information
ydah committed Mar 28, 2024
1 parent 9a4c2a7 commit fa457e7
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ jobs:
- uses: actions/checkout@v4
- name: Use latest RuboCop RSpec from `master`
run: |
sed -e '/rubocop-rspec/d' -i Gemfile
echo "gem 'rubocop-rspec', github: 'rubocop/rubocop-rspec'" > Gemfile.local
- uses: ruby/setup-ruby@v1
with:
Expand All @@ -102,7 +103,7 @@ jobs:
- uses: actions/checkout@v4
- name: Use latest RSpec 4 from `4-0-dev` branch
run: |
sed -e '/rspec/d' -i Gemfile
sed -e "/^gem 'rspec/d" -i Gemfile
cat << EOF > Gemfile.local
gem 'rspec', github: 'rspec/rspec-metagem', branch: '4-0-dev'
gem 'rspec-core', github: 'rspec/rspec-core', branch: '4-0-dev'
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Master (Unreleased)

- Implicit dependency on RuboCop RSpec. Note that if you use rubocop-rspec_rails, you must also explicitly add rubocop-rspec to the Gemfile, because you are changing to an implicit dependency on RuboCop RSpec. ([@ydah])

## 2.28.0 (2024-03-28)

- Extracted from `rubocop-rspec` into a separate repository. ([@ydah])
Expand Down
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,8 @@ gem 'rubocop-rake', '~> 0.6'
gem 'simplecov', '>= 0.19'
gem 'yard'

# TODO: Move to gemspec when RuboCop RSpec v3 is released.
gem 'rubocop-rspec', '~> 2.27'

local_gemfile = 'Gemfile.local'
eval_gemfile(local_gemfile) if File.exist?(local_gemfile)
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@

## Installation

Just install the `rubocop-rspec_rails` gem
**This gem implicitly depends on the `rubocop-rspec` gem, so you should install it first.**
Just install the `rubocop-rspec` and `rubocop-rspec_rails` gem

```bash
gem install rubocop-rspec_rails
gem install rubocop-rspec rubocop-rspec_rails
```

or if you use bundler put this in your `Gemfile`

```ruby
gem 'rubocop-rspec', require: false
gem 'rubocop-rspec_rails', require: false
```

Expand Down
8 changes: 5 additions & 3 deletions docs/modules/ROOT/pages/installation.adoc
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
= Installation

Just install the `rubocop-rspec_rails` gem
*This gem implicitly depends on the `rubocop-rspec` gem, so you should install it first.*
Just install the `rubocop-rspec` and `rubocop-rspec_rails` gem

[source,bash]
----
gem install rubocop-rspec_rails
gem install rubocop-rspec rubocop-rspec_rails
----

or if you use bundler put this in your `Gemfile`

[source,ruby]
----
gem 'rubocop-rspec_rails'
gem 'rubocop-rspec', require: false
gem 'rubocop-rspec_rails', require: false
----
1 change: 0 additions & 1 deletion rubocop-rspec_rails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,4 @@ Gem::Specification.new do |spec|
}

spec.add_runtime_dependency 'rubocop', '~> 1.40'
spec.add_runtime_dependency 'rubocop-rspec', '~> 2.27'
end

0 comments on commit fa457e7

Please sign in to comment.