Skip to content

Commit 858ba95

Browse files
authored
Merge pull request #1322 from rubocop/use-edge-rspec-for-development
Add an RSpec 4 pre-release CI job
2 parents c8a11ce + a004d11 commit 858ba95

File tree

7 files changed

+56
-26
lines changed

7 files changed

+56
-26
lines changed

.github/workflows/main.yml

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,53 @@ jobs:
3232
task:
3333
- internal_investigation
3434
- spec
35-
rubocop_version:
36-
- gem
37-
include:
38-
- rubocop_version: edge
39-
ruby: 2.7
40-
task: internal_investigation
41-
- rubocop_version: edge
42-
ruby: 2.7
43-
task: spec
44-
name: ${{ matrix.task }}, Ruby ${{ matrix.ruby }} (${{ matrix.rubocop_version }})
35+
name: ${{ matrix.task }}, Ruby ${{ matrix.ruby }} (gem)
36+
steps:
37+
- uses: actions/checkout@v2
38+
- uses: ruby/setup-ruby@v1
39+
with:
40+
ruby-version: "${{ matrix.ruby }}"
41+
bundler-cache: true
42+
- run: bundle exec rake ${{ matrix.task }}
43+
44+
edge-rubocop:
45+
runs-on: ubuntu-latest
46+
strategy:
47+
matrix:
48+
ruby:
49+
- 2.7
50+
task:
51+
- internal_investigation
52+
- spec
53+
name: ${{ matrix.task }} Ruby ${{ matrix.ruby }} (edge)
4554
steps:
4655
- uses: actions/checkout@v2
4756
- name: Use latest RuboCop from `master`
4857
run: |
4958
echo "gem 'rubocop', github: 'rubocop-hq/rubocop'" > Gemfile.local
50-
if: matrix.rubocop_version == 'edge'
5159
- uses: ruby/setup-ruby@v1
5260
with:
5361
ruby-version: "${{ matrix.ruby }}"
5462
bundler-cache: true
5563
- run: bundle exec rake ${{ matrix.task }}
64+
65+
rspec4:
66+
runs-on: ubuntu-latest
67+
name: RSpec 4
68+
steps:
69+
- uses: actions/checkout@v2
70+
- name: Use latest RSpec 4 from `4-0-dev` branch
71+
run: |
72+
sed -e '/rspec/d' -i Gemfile
73+
cat << EOF > Gemfile.local
74+
gem 'rspec', github: 'rspec/rspec', branch: '4-0-dev'
75+
gem 'rspec-core', github: 'rspec/rspec-core', branch: '4-0-dev'
76+
gem 'rspec-expectations', github: 'rspec/rspec-expectations', branch: '4-0-dev'
77+
gem 'rspec-mocks', github: 'rspec/rspec-mocks', branch: '4-0-dev'
78+
gem 'rspec-support', github: 'rspec/rspec-support', branch: '4-0-dev'
79+
EOF
80+
- uses: ruby/setup-ruby@v1
81+
with:
82+
ruby-version: 2.7
83+
bundler-cache: true
84+
- run: bundle exec rake spec

.rspec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
--require spec_helper
2-
--color
32
--format documentation

Gemfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ source 'https://rubygems.org'
44

55
gemspec
66

7+
gem 'rack'
8+
gem 'rake'
9+
gem 'rspec', '~> 3.11'
10+
gem 'rubocop-performance', '~> 1.7'
11+
gem 'rubocop-rake', '~> 0.6'
12+
gem 'yard'
13+
714
local_gemfile = 'Gemfile.local'
815

916
if File.exist?(local_gemfile)

rubocop-rspec.gemspec

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,4 @@ Gem::Specification.new do |spec|
3838
}
3939

4040
spec.add_runtime_dependency 'rubocop', '~> 1.31'
41-
42-
spec.add_development_dependency 'rack'
43-
spec.add_development_dependency 'rake'
44-
spec.add_development_dependency 'rspec', '>= 3.4'
45-
spec.add_development_dependency 'rubocop-performance', '~> 1.7'
46-
spec.add_development_dependency 'rubocop-rake', '~> 0.6'
47-
spec.add_development_dependency 'yard'
4841
end

spec/rubocop/cli/autocorrect_spec.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# frozen_string_literal: true
22

3-
RSpec.describe 'RuboCop::CLI --autocorrect', :isolated_environment do # rubocop:disable RSpec/DescribeClass
3+
RSpec.describe 'RuboCop::CLI --autocorrect' do # rubocop:disable RSpec/DescribeClass
44
subject(:cli) { RuboCop::CLI.new }
55

6+
include_context 'isolated environment'
7+
68
include_context 'when cli spec behavior'
79

810
context 'when corrects `RSpec/Capybara/CurrentPathExpectation` with ' \

spec/smoke_tests/weird_rspec_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
end
8787

8888
it_behaves_like :something
89-
it_should_behave_like :something
89+
it_should_behave_like :something if RSpec::Core::Version::STRING < '4.0'
9090

9191
it_behaves_like :something do
9292
let(:foo) { 'bar' }

spec/spec_helper.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,7 @@ module SpecHelper
2424
config.order = :random
2525

2626
# Run focused tests with `fdescribe`, `fit`, `:focus` etc.
27-
config.filter_run focus: true
28-
config.run_all_when_everything_filtered = true
29-
30-
# Forbid RSpec from monkey patching any of our objects
31-
config.disable_monkey_patching!
27+
config.filter_run_when_matching :focus
3228

3329
# We should address configuration warnings when we upgrade
3430
config.raise_errors_for_deprecations!
@@ -38,6 +34,10 @@ module SpecHelper
3834
config.raise_on_warning = true
3935

4036
config.include(ExpectOffense)
37+
38+
config.include_context 'with default RSpec/Language config', :config
39+
config.include_context 'config', :config
40+
config.include_context 'smoke test', type: :cop_spec
4141
end
4242

4343
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))

0 commit comments

Comments
 (0)