Skip to content

Commit f0a3909

Browse files
authored
Merge pull request #301 from DanMegaGamer/fix-ci
Fix broken tests and add Github workflow CI
2 parents 23a27be + 3cd1ac5 commit f0a3909

6 files changed

Lines changed: 87 additions & 87 deletions

File tree

.github/workflows/ci.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# This workflow uses actions that are not certified by GitHub.
2+
# They are provided by a third-party and are governed by
3+
# separate terms of service, privacy policy, and support
4+
# documentation.
5+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7+
8+
name: rspec
9+
10+
on:
11+
push:
12+
branches: ["master"]
13+
pull_request:
14+
branches: ["master"]
15+
16+
permissions:
17+
contents: read
18+
19+
jobs:
20+
test:
21+
runs-on: ubuntu-latest
22+
strategy:
23+
matrix:
24+
ruby-version: ["2.6", "2.7", "3.0"]
25+
26+
steps:
27+
- uses: actions/checkout@v4
28+
- name: Set up Ruby
29+
uses: ruby/setup-ruby@v1
30+
# uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0
31+
with:
32+
ruby-version: ${{ matrix.ruby-version }}
33+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
34+
- name: Run tests
35+
run: bundle exec rspec

.travis.yml

Lines changed: 0 additions & 17 deletions
This file was deleted.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
capybara-screenshot gem
22
=======================
33

4-
[![Build Status](https://travis-ci.org/mattheworiordan/capybara-screenshot.svg)](https://travis-ci.org/mattheworiordan/capybara-screenshot)
4+
[![Build Status](https://github.com/mattheworiordan/capybara-screenshot/actions/workflows/ci.yml/badge.svg)](https://github.com/mattheworiordan/capybara-screenshot/actions/workflows/ci.yml)
55
[![Code Climate](https://d3s6mut3hikguw.cloudfront.net/github/mattheworiordan/capybara-screenshot.svg)](https://codeclimate.com/github/mattheworiordan/capybara-screenshot)
66
[![Gem Version](https://badge.fury.io/rb/capybara-screenshot.svg)](http://badge.fury.io/rb/capybara-screenshot)
77

@@ -319,7 +319,7 @@ Please raise an issue at [https://github.com/mattheworiordan/capybara-screenshot
319319

320320
#### Contributions
321321

322-
Contributions are welcome. Please fork this gem and then submit a pull request. New features must include test coverage and must pass on all versions of the testing frameworks supported. Run `appraisal` to set up the your Gems. then `appraisal "rake travis:ci"` locally to test your changes against all versions of testing framework gems supported.
322+
Contributions are welcome. Please fork this gem and then submit a pull request. New features must include test coverage and must pass on all versions of the testing frameworks supported. Run `appraisal` to set up the your Gems. then `appraisal "rspec"` locally to test your changes against all versions of testing framework gems supported.
323323

324324
#### Rubygems
325325

Rakefile

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,6 @@
1-
require 'rubygems'
2-
require 'bundler/setup'
1+
require "rubygems"
2+
require "bundler/setup"
33

44
Bundler::GemHelper.install_tasks
55

6-
require 'rspec/core/rake_task'
7-
8-
rspec_rake_task = RSpec::Core::RakeTask.new(:spec)
9-
10-
task default: [:spec]
11-
12-
def target_gem
13-
gem_file = ENV['BUNDLE_GEMFILE'] || ''
14-
targets = %w(cucumber spinach rspec)
15-
16-
target = gem_file.match(/(#{targets.join('|')})/)
17-
if target && targets.include?(target[1])
18-
target[1].to_sym
19-
else
20-
[]
21-
end
22-
end
23-
24-
namespace :travis do
25-
task :ci => target_gem do
26-
Rake::Task['spec'].invoke
27-
end
28-
29-
task :cucumber do
30-
rspec_rake_task.pattern = 'spec/cucumber'
31-
end
32-
33-
task :spinach do
34-
rspec_rake_task.pattern = 'spec/spinach'
35-
end
36-
37-
task :rspec do
38-
rspec_rake_task.pattern = 'spec/rspec'
39-
end
40-
end
6+
require "rspec/core/rake_task"

spec/feature/minitest_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def run_failing_case(code)
2828

2929
it 'saves a screenshot on failure' do
3030
run_failing_case <<-RUBY
31-
class TestFailure < MiniTest::Unit::TestCase
31+
class TestFailure < Minitest::Test
3232
include Capybara::DSL
3333
3434
def test_failure
@@ -43,7 +43,7 @@ def test_failure
4343

4444
it 'saves a screenshot for the correct session for failures using_session' do
4545
run_failing_case <<-RUBY
46-
class TestFailure < Minitest::Unit::TestCase
46+
class TestFailure < Minitest::Test
4747
include Capybara::DSL
4848
4949
def test_failure
@@ -64,7 +64,7 @@ def test_failure
6464
create_screenshot_for_pruning
6565
configure_prune_strategy :last_run
6666
run_failing_case <<-RUBY
67-
class TestFailure < Minitest::Unit::TestCase
67+
class TestFailure < Minitest::Test
6868
include Capybara::DSL
6969
7070
def test_failure

spec/unit/s3_saver_spec.rb

Lines changed: 44 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,11 @@
135135
expect(File).to receive(:open).with(html_path).and_yield(html_file)
136136

137137
expect(s3_client).to receive(:put_object).with(
138-
bucket: bucket_name,
139-
key: 'bar.html',
140-
body: html_file
138+
{
139+
bucket: bucket_name,
140+
key: "bar.html",
141+
body: html_file
142+
}
141143
)
142144

143145
expect(s3_saver).to receive(:determine_bucket_host).and_call_original
@@ -155,9 +157,11 @@
155157
expect(File).to receive(:open).with(screenshot_path).and_yield(screenshot_file)
156158

157159
expect(s3_client).to receive(:put_object).with(
158-
bucket: bucket_name,
159-
key: 'bim.jpg',
160-
body: screenshot_file
160+
{
161+
bucket: bucket_name,
162+
key: "bim.jpg",
163+
body: screenshot_file
164+
}
161165
)
162166

163167
s3_saver.save
@@ -177,10 +181,12 @@
177181
expect(File).to receive(:open).with(html_path).and_yield(html_file)
178182

179183
expect(s3_client).to receive(:put_object).with(
180-
bucket: bucket_name,
181-
key: 'bar.html',
182-
body: html_file,
183-
acl: 'public-read'
184+
{
185+
bucket: bucket_name,
186+
key: "bar.html",
187+
body: html_file,
188+
acl: "public-read"
189+
}
184190
)
185191

186192
s3_saver.save
@@ -196,10 +202,12 @@
196202
expect(File).to receive(:open).with(screenshot_path).and_yield(screenshot_file)
197203

198204
expect(s3_client).to receive(:put_object).with(
199-
bucket: bucket_name,
200-
key: 'bim.jpg',
201-
body: screenshot_file,
202-
acl: 'public-read'
205+
{
206+
bucket: bucket_name,
207+
key: "bim.jpg",
208+
body: screenshot_file,
209+
acl: "public-read"
210+
}
203211
)
204212

205213
s3_saver.save
@@ -217,9 +225,11 @@
217225
expect(File).to receive(:open).with(html_path).and_yield(html_file)
218226

219227
expect(s3_client).to receive(:put_object).with(
220-
bucket: bucket_name,
221-
key: 'some/path/bar.html',
222-
body: html_file
228+
{
229+
bucket: bucket_name,
230+
key: "some/path/bar.html",
231+
body: html_file
232+
}
223233
)
224234

225235
s3_saver_with_key_prefix.save
@@ -235,9 +245,11 @@
235245
expect(File).to receive(:open).with(screenshot_path).and_yield(screenshot_file)
236246

237247
expect(s3_client).to receive(:put_object).with(
238-
bucket: bucket_name,
239-
key: 'some/path/bim.jpg',
240-
body: screenshot_file
248+
{
249+
bucket: bucket_name,
250+
key: "some/path/bim.jpg",
251+
body: screenshot_file
252+
}
241253
)
242254

243255
s3_saver_with_key_prefix.save
@@ -256,10 +268,12 @@
256268
expect(File).to receive(:open).with(html_path).and_yield(html_file)
257269

258270
expect(s3_client).to receive(:put_object).with(
259-
bucket: bucket_name,
260-
key: 'some/path/bar.html',
261-
body: html_file,
262-
acl: 'public-read'
271+
{
272+
bucket: bucket_name,
273+
key: "some/path/bar.html",
274+
body: html_file,
275+
acl: "public-read"
276+
}
263277
)
264278

265279
s3_saver_with_key_prefix.save
@@ -275,10 +289,12 @@
275289
expect(File).to receive(:open).with(screenshot_path).and_yield(screenshot_file)
276290

277291
expect(s3_client).to receive(:put_object).with(
278-
bucket: bucket_name,
279-
key: 'some/path/bim.jpg',
280-
body: screenshot_file,
281-
acl: 'public-read'
292+
{
293+
bucket: bucket_name,
294+
key: "some/path/bim.jpg",
295+
body: screenshot_file,
296+
acl: "public-read"
297+
}
282298
)
283299

284300
s3_saver_with_key_prefix.save

0 commit comments

Comments
 (0)