Skip to content

Commit e25f8dd

Browse files
Update Ruby to 3.0.2 (#48)
* Update gems & GH Actions to Ruby 3.0.2 See https://hub.docker.com/_/ruby?tab=tags&page=1&name=3.0 and https://github.com/ruby/setup-ruby/blob/v1.84.0/README.md * Expand testing instructions * Improve wording * Repair failing tests after json update Either json 2.6.1 or File.write seems to append an additional \n at the end of the parsed results.json. Thus, both assertion argument need to be treated the same now. * Set Ruby version also in Gemfile * Test Ruby3's probably popular syntax elements See https://www.ruby-lang.org/en/news/2020/12/25/ruby-3-0-0-released/, but excluding: - "in is changed …" because that's behaviour - "Find pattern …" because it's "experimental" - "Hash#except …" because the test runner doesn't care from where the student's code loads this method. * Bump setup-ruby to v1.85.0 * Bump mandate to 1.0.0
1 parent 9345867 commit e25f8dd

File tree

11 files changed

+77
-20
lines changed

11 files changed

+77
-20
lines changed

.github/workflows/rubocop.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ jobs:
1414
- uses: actions/checkout@v2
1515

1616
- name: Set up Ruby
17-
uses: ruby/setup-ruby@e27aee156d42e38ff8a4c2fc97b125c4087cbcc7
17+
uses: ruby/setup-ruby@a2b2637a7c796d83d566fc82853156d4372b0f60
1818
with:
19-
ruby-version: 2.6.6
19+
ruby-version: 3.0.2
2020
bundler-cache: true
2121

2222
- name: Install gems

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ jobs:
1616

1717
# Setup Ruby - this needs to match the version in the Gemfile
1818
- name: Set up Ruby
19-
uses: ruby/setup-ruby@e27aee156d42e38ff8a4c2fc97b125c4087cbcc7
19+
uses: ruby/setup-ruby@a2b2637a7c796d83d566fc82853156d4372b0f60
2020
with:
21-
ruby-version: 2.6.6
21+
ruby-version: 3.0.2
2222
bundler-cache: true
2323

2424
# Setup code climate

.ruby-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ruby-2.6.6
1+
ruby-3.0.2

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ruby:2.5-alpine
1+
FROM ruby:3.0.2-alpine
22

33
RUN apk update && apk upgrade && \
44
apk add --no-cache bash git openssh && \
@@ -10,7 +10,7 @@ RUN wget -P /usr/local/bin https://github.com/exercism/tooling-webserver/release
1010
WORKDIR /opt/test-runner
1111

1212
COPY Gemfile Gemfile.lock ./
13-
RUN gem install bundler:2.1.4 && \
13+
RUN gem install bundler:2.2.29 && \
1414
bundle config set without 'development test' && \
1515
bundle install
1616

Gemfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ git_source(:github) do |repo_name|
55
"https://github.com/#{repo_name}.git"
66
end
77

8-
gem 'mandate'
8+
ruby '3.0.2'
9+
10+
gem "mandate", "~> 1.0.0"
911
gem 'rake'
10-
gem 'json'
12+
gem 'json', '~> 2.6.1'
1113
gem 'minitest', '~> 5.11.3'
1214

1315
gem 'parser'

Gemfile.lock

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4-
ast (2.4.1)
4+
ast (2.4.2)
55
coderay (1.1.3)
66
docile (1.3.2)
7-
json (2.2.0)
8-
mandate (0.3.0)
7+
json (2.6.1)
8+
mandate (1.0.0)
99
method_source (1.0.0)
1010
minitest (5.11.3)
1111
mocha (1.11.2)
1212
parallel (1.19.2)
13-
parser (2.7.1.4)
13+
parser (3.0.2.0)
1414
ast (~> 2.4.1)
1515
pry (0.13.1)
1616
coderay (~> 1.1)
@@ -46,8 +46,8 @@ PLATFORMS
4646
ruby
4747

4848
DEPENDENCIES
49-
json
50-
mandate
49+
json (~> 2.6.1)
50+
mandate (~> 1.0.0)
5151
minitest (~> 5.11.3)
5252
mocha
5353
parser
@@ -59,5 +59,8 @@ DEPENDENCIES
5959
rubocop-performance
6060
simplecov (~> 0.17.0)
6161

62+
RUBY VERSION
63+
ruby 3.0.2p107
64+
6265
BUNDLED WITH
63-
2.1.4
66+
2.2.29

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,15 @@ For example:
1717
Before running the tests, first install the dependencies:
1818

1919
```bash
20+
bundle config set --local with 'test'
2021
bundle install
2122
```
2223

23-
Then, run the following command to run the tests:
24+
Then, in [test/test_helper.rb](test/test_helper.rb),
25+
comment the "Production command" `system(…)` out
26+
and uncomment either of the "Testing commands".
27+
28+
Lastly, run the following command to run the tests:
2429

2530
```bash
2631
bundle exec rake test
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# See section "Other Notable New Features"
2+
# in https://www.ruby-lang.org/en/news/2020/12/25/ruby-3-0-0-released/
3+
class Ruby3Syntax
4+
def self.rightward_assign
5+
'is fun' => exercism
6+
return exercism
7+
end
8+
9+
def self.endless_methods = 'are fun'
10+
end
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
require 'minitest/autorun'
2+
require_relative 'ruby_3_syntax'
3+
4+
# minimal set of:
5+
# Common test data version: 1.6.0 42b9d45
6+
class Ruby3SyntaxTest < Minitest::Test
7+
def test_rightward_assign
8+
assert_equal Ruby3Syntax.rightward_assign, 'is fun'
9+
end
10+
11+
def test_endless_method_def
12+
assert_equal Ruby3Syntax.endless_methods, 'are fun'
13+
end
14+
end

test/test_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def run_test_runner(input_dir, output_dir)
6161
# exec("bin/run.sh two_fer #{input_dir} #{output_dir}")
6262
# system("bin/run.sh two_fer #{input_dir} #{output_dir}")
6363

64-
# Main command
64+
# Production command
6565
system("bin/run.sh two_fer #{input_dir} #{output_dir}", out: "/dev/null", err: "/dev/null")
6666
end
6767
end

0 commit comments

Comments
 (0)