Skip to content

Commit 0946544

Browse files
authored
Ruby 3.2 fix: remove File.exists? usage (#243)
* CI: add Ruby 3.0, 3.1, and 3.2 to the test matrix * CI: update actions to latest released versions * CI: use ruby/setup-ruby action to install gems This provides caching between builds, so should speed up the build. * Resolve File.exists? deprecation * Resolve Fixnum deprecation * Resolve syntax error: invalid yield
1 parent 55e5f2a commit 0946544

File tree

7 files changed

+15
-16
lines changed

7 files changed

+15
-16
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,14 @@ jobs:
1717
runs-on: ubuntu-latest
1818
strategy:
1919
matrix:
20-
ruby: [2.4, 2.5, 2.6, 2.7, jruby]
20+
ruby: [2.4, 2.5, 2.6, 2.7, "3.0", 3.1, 3.2, jruby]
2121
fail-fast: false
2222
steps:
23-
- uses: actions/checkout@v2.0.0
23+
- uses: actions/checkout@v3
2424
with:
2525
fetch-depth: 1
26-
- uses: ruby/setup-ruby@master
26+
- uses: ruby/setup-ruby@v1
2727
with:
2828
ruby-version: ${{ matrix.ruby }}
29-
- run: bundle install --jobs 4 --retry 3
30-
name: Install Ruby deps
29+
bundler-cache: true
3130
- run: bundle exec rake

features/steps/automatic_feature_generation.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class AutomaticFeatureGeneration < Spinach::FeatureSteps
2020
Then 'I a feature should exist named "features/steps/cheezburger_can_i_has.rb"' do
2121
in_current_dir do
2222
@file = 'features/steps/cheezburger_can_i_has.rb'
23-
File.exists?(@file).must_equal true
23+
File.exist?(@file).must_equal true
2424
end
2525
end
2626

lib/spinach/cli.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def feature_files
5656

5757
@args.each do |arg|
5858
if arg.match(/\.feature/)
59-
if File.exists? arg.gsub(/:\d*/, '')
59+
if File.exist? arg.gsub(/:\d*/, '')
6060
files_to_run << arg
6161
else
6262
fail! "#{arg} could not be found"

test/spinach/cli_test.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -276,14 +276,14 @@
276276
describe 'the feature really exists' do
277277
it 'runs the feature' do
278278
cli = Spinach::Cli.new(['features/some_feature.feature'])
279-
File.stubs(:exists?).returns(true)
279+
File.stubs(:exist?).returns(true)
280280
cli.feature_files.must_equal ['features/some_feature.feature']
281281
end
282282
end
283283

284284
it 'it fails if the feature does not exist' do
285285
cli = Spinach::Cli.new(['features/some_feature.feature'])
286-
File.stubs(:exists?).returns(false)
286+
File.stubs(:exist?).returns(false)
287287
cli.expects(:fail!).with('features/some_feature.feature could not be found')
288288

289289
cli.feature_files
@@ -293,7 +293,7 @@
293293
describe 'when a particular feature list is passed with line' do
294294
it 'returns the feature with the line number' do
295295
cli = Spinach::Cli.new(['features/some_feature.feature:10'])
296-
File.stubs(:exists?).returns(true)
296+
File.stubs(:exist?).returns(true)
297297

298298
cli.feature_files.must_equal ['features/some_feature.feature:10']
299299
end
@@ -302,7 +302,7 @@
302302
describe "when a particular feature list is passed with multiple lines" do
303303
it "returns the feature with the line numbers" do
304304
cli = Spinach::Cli.new(['features/some_feature.feature:10:20'])
305-
File.stubs(:exists?).returns(true)
305+
File.stubs(:exist?).returns(true)
306306

307307
cli.feature_files.must_equal ["features/some_feature.feature:10:20"]
308308
end
@@ -337,7 +337,7 @@
337337
Dir.expects(:glob).with('path/to/features/**/*.feature')
338338
.returns(['several features'])
339339

340-
File.stubs(:exists?).returns(true)
340+
File.stubs(:exist?).returns(true)
341341

342342
cli.feature_files.must_equal ['several features', 'some_feature.feature']
343343
end

test/spinach/dsl_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def before_each
157157
end
158158

159159
@feature.new.step_location_for('I say goodbye').first.must_include '/dsl_test.rb'
160-
@feature.new.step_location_for('I say goodbye').last.must_be_kind_of Fixnum
160+
@feature.new.step_location_for('I say goodbye').last.must_be_kind_of Integer
161161
end
162162
end
163163
end

test/spinach/generators/feature_generator_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ module Spinach::Generators
7171
in_current_dir do
7272
subject.store
7373
File.directory?("features/steps/").must_equal true
74-
File.exists?("features/steps/cheezburger_can_i_has.rb").must_equal true
74+
File.exist?("features/steps/cheezburger_can_i_has.rb").must_equal true
7575
File.read("features/steps/cheezburger_can_i_has.rb").strip.must_equal(
7676
subject.generate.strip
7777
)

test/spinach/reporter_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ module Spinach
8989

9090
it "binds a callback around every scenario" do
9191
@reporter.expects(:around_scenario_run)
92-
Spinach.hooks.run_around_scenario(anything) do
93-
yield
92+
Spinach.hooks.run_around_scenario(anything) do |&block|
93+
block.call
9494
end
9595
end
9696

0 commit comments

Comments
 (0)