diff --git a/.github/workflows/rubocop.yml b/.github/workflows/rubocop.yml index ec12e8a..9c2f63b 100644 --- a/.github/workflows/rubocop.yml +++ b/.github/workflows/rubocop.yml @@ -14,9 +14,9 @@ jobs: - uses: actions/checkout@v2 - name: Set up Ruby - uses: ruby/setup-ruby@e27aee156d42e38ff8a4c2fc97b125c4087cbcc7 + uses: ruby/setup-ruby@a2b2637a7c796d83d566fc82853156d4372b0f60 with: - ruby-version: 2.6.6 + ruby-version: 3.0.2 bundler-cache: true - name: Install gems diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8bdfb6c..c87a617 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -16,9 +16,9 @@ jobs: # Setup Ruby - this needs to match the version in the Gemfile - name: Set up Ruby - uses: ruby/setup-ruby@e27aee156d42e38ff8a4c2fc97b125c4087cbcc7 + uses: ruby/setup-ruby@a2b2637a7c796d83d566fc82853156d4372b0f60 with: - ruby-version: 2.6.6 + ruby-version: 3.0.2 bundler-cache: true # Setup code climate diff --git a/.ruby-version b/.ruby-version index f6ab44e..4efbd8f 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -ruby-2.6.6 +ruby-3.0.2 diff --git a/Dockerfile b/Dockerfile index c841982..027c968 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ruby:2.5-alpine +FROM ruby:3.0.2-alpine RUN apk update && apk upgrade && \ apk add --no-cache bash git openssh && \ @@ -10,7 +10,7 @@ RUN wget -P /usr/local/bin https://github.com/exercism/tooling-webserver/release WORKDIR /opt/test-runner COPY Gemfile Gemfile.lock ./ -RUN gem install bundler:2.1.4 && \ +RUN gem install bundler:2.2.29 && \ bundle config set without 'development test' && \ bundle install diff --git a/Gemfile b/Gemfile index aa01bab..76f9811 100644 --- a/Gemfile +++ b/Gemfile @@ -5,9 +5,11 @@ git_source(:github) do |repo_name| "https://github.com/#{repo_name}.git" end -gem 'mandate' +ruby '3.0.2' + +gem "mandate", "~> 1.0.0" gem 'rake' -gem 'json' +gem 'json', '~> 2.6.1' gem 'minitest', '~> 5.11.3' gem 'parser' diff --git a/Gemfile.lock b/Gemfile.lock index 12043eb..8b2d26c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,16 +1,16 @@ GEM remote: https://rubygems.org/ specs: - ast (2.4.1) + ast (2.4.2) coderay (1.1.3) docile (1.3.2) - json (2.2.0) - mandate (0.3.0) + json (2.6.1) + mandate (1.0.0) method_source (1.0.0) minitest (5.11.3) mocha (1.11.2) parallel (1.19.2) - parser (2.7.1.4) + parser (3.0.2.0) ast (~> 2.4.1) pry (0.13.1) coderay (~> 1.1) @@ -46,8 +46,8 @@ PLATFORMS ruby DEPENDENCIES - json - mandate + json (~> 2.6.1) + mandate (~> 1.0.0) minitest (~> 5.11.3) mocha parser @@ -59,5 +59,8 @@ DEPENDENCIES rubocop-performance simplecov (~> 0.17.0) +RUBY VERSION + ruby 3.0.2p107 + BUNDLED WITH - 2.1.4 + 2.2.29 diff --git a/README.md b/README.md index 716a40d..21f6040 100644 --- a/README.md +++ b/README.md @@ -17,10 +17,15 @@ For example: Before running the tests, first install the dependencies: ```bash +bundle config set --local with 'test' bundle install ``` -Then, run the following command to run the tests: +Then, in [test/test_helper.rb](test/test_helper.rb), +comment the "Production command" `system(…)` out +and uncomment either of the "Testing commands". + +Lastly, run the following command to run the tests: ```bash bundle exec rake test diff --git a/test/fixtures/pass_ruby_3_syntax/input/ruby_3_syntax.rb b/test/fixtures/pass_ruby_3_syntax/input/ruby_3_syntax.rb new file mode 100644 index 0000000..bc4f1fb --- /dev/null +++ b/test/fixtures/pass_ruby_3_syntax/input/ruby_3_syntax.rb @@ -0,0 +1,10 @@ +# See section "Other Notable New Features" +# in https://www.ruby-lang.org/en/news/2020/12/25/ruby-3-0-0-released/ +class Ruby3Syntax + def self.rightward_assign + 'is fun' => exercism + return exercism + end + + def self.endless_methods = 'are fun' +end diff --git a/test/fixtures/pass_ruby_3_syntax/input/ruby_3_syntax_test.rb b/test/fixtures/pass_ruby_3_syntax/input/ruby_3_syntax_test.rb new file mode 100644 index 0000000..507ad46 --- /dev/null +++ b/test/fixtures/pass_ruby_3_syntax/input/ruby_3_syntax_test.rb @@ -0,0 +1,14 @@ +require 'minitest/autorun' +require_relative 'ruby_3_syntax' + +# minimal set of: +# Common test data version: 1.6.0 42b9d45 +class Ruby3SyntaxTest < Minitest::Test + def test_rightward_assign + assert_equal Ruby3Syntax.rightward_assign, 'is fun' + end + + def test_endless_method_def + assert_equal Ruby3Syntax.endless_methods, 'are fun' + end +end diff --git a/test/test_helper.rb b/test/test_helper.rb index 85899c5..3b5195a 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -61,7 +61,7 @@ def run_test_runner(input_dir, output_dir) # exec("bin/run.sh two_fer #{input_dir} #{output_dir}") # system("bin/run.sh two_fer #{input_dir} #{output_dir}") - # Main command + # Production command system("bin/run.sh two_fer #{input_dir} #{output_dir}", out: "/dev/null", err: "/dev/null") end end diff --git a/test/test_runner_test.rb b/test/test_runner_test.rb index eaf058e..c868a68 100644 --- a/test/test_runner_test.rb +++ b/test/test_runner_test.rb @@ -29,6 +29,29 @@ def test_pass ) end + def test_pass_ruby_3 + assert_fixture( + :pass_ruby_3_syntax, + { + version: 2, + status: :pass, + message: nil, + tests: [ + { + name: "Rightward assign", + status: :pass, + test_code: %(assert_equal Ruby3Syntax.rightward_assign, 'is fun') + }, + { + name: "Endless method def", + status: :pass, + test_code: %(assert_equal Ruby3Syntax.endless_methods, 'are fun') + } + ] + } + ) + end + def test_fail assert_fixture( :fail, { @@ -108,7 +131,7 @@ def test_syntax_errors_in_tests ,'This is meant to be a syntax... ^ SYNTAX_ERRORS - assert_equal expected.strip, actual['message'] + assert_equal expected, actual['message'] assert_test_run_exited_cleanly end @@ -124,7 +147,7 @@ def test_syntax_errors_in_code end,A stray comma ^ SYNTAX_ERRORS - assert_equal expected.strip, actual['message'] + assert_equal expected, actual['message'] assert_test_run_exited_cleanly end