From f7f7ef51fcd98f4009570f80414d9a47c54e069b Mon Sep 17 00:00:00 2001 From: Dominik Goltermann Date: Mon, 21 Feb 2022 15:53:19 +0100 Subject: [PATCH] Update ci to use newest ruby versions --- .circleci/config.yml | 23 ++++++++++++----------- .rubocop.yml | 2 +- Gemfile.lock | 3 ++- lib/definition/dsl.rb | 8 +++----- spec/integration/lambda_spec.rb | 8 +++----- spec/integration/value_object_spec.rb | 8 +++----- spec/lib/definition/types/lambda_spec.rb | 8 +++----- spec/lib/definition/types/type_spec.rb | 8 +++----- 8 files changed, 30 insertions(+), 38 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 3479ef6..312c3a5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -12,22 +12,25 @@ orbs: jobs: test: parameters: - image: + ruby_version: type: string docker: - - image: << parameters.image>> + - image: cimg/base:stable steps: + - ruby/install: + version: << parameters.ruby_version >> - checkout - run: rm Gemfile.lock - - run: export GEM=$(which gem); sudo $GEM update --system --no-document - run: gem install bundler - run: bundle install - ruby/rspec-test linting: docker: - - image: 'cimg/ruby:2.7' + - image: 'cimg/base:stable' steps: - checkout + - ruby/install: + version: "3.0" - ruby/install-deps - ruby/rubocop-check: format: progress @@ -42,11 +45,9 @@ workflows: - test: matrix: parameters: - image: - - "cimg/ruby:2.6" - - "cimg/ruby:2.7" - - "cimg/ruby:3.0" - - "cimg/ruby:3.1" - - "circleci/jruby:9.3.3-jdk11" - - "circleci/jruby:9.2.20-jdk11" + ruby_version: + - "2.6" + - "2.7" + - "3.0" + - "jruby-9.3.3.0" - linting diff --git a/.rubocop.yml b/.rubocop.yml index d946527..f54e28b 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -2,7 +2,7 @@ require: - rubocop-rspec AllCops: - TargetRubyVersion: 2.3 + TargetRubyVersion: 2.6 Metrics/LineLength: Max: 119 diff --git a/Gemfile.lock b/Gemfile.lock index 906be2c..64cc1a9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - definition (0.6.1) + definition (0.7.0) activesupport i18n @@ -109,6 +109,7 @@ GEM unicode-display_width (1.5.0) PLATFORMS + ruby x86_64-linux DEPENDENCIES diff --git a/lib/definition/dsl.rb b/lib/definition/dsl.rb index 0be3c2e..c3ff9fc 100644 --- a/lib/definition/dsl.rb +++ b/lib/definition/dsl.rb @@ -41,11 +41,9 @@ def CoercibleType(klass) # rubocop:disable Style/MethodName "a primitive that has a coercion function defined") end Types::Type.new(:type, klass) do |value| - begin - method(klass.name).call(value) - rescue ArgumentError - value - end + method(klass.name).call(value) + rescue ArgumentError + value end end diff --git a/spec/integration/lambda_spec.rb b/spec/integration/lambda_spec.rb index 6368a30..d763c96 100644 --- a/spec/integration/lambda_spec.rb +++ b/spec/integration/lambda_spec.rb @@ -5,11 +5,9 @@ describe "Definition.Lambda" do subject(:definition) do Definition.Lambda(:email) do |value| - begin - conform_with(value) if value =~ /\A([\w+\-].?)+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z/i - rescue NoMethodError - value - end + conform_with(value) if value =~ /\A([\w+\-].?)+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z/i + rescue NoMethodError + value end end diff --git a/spec/integration/value_object_spec.rb b/spec/integration/value_object_spec.rb index d1f3683..bc7f715 100644 --- a/spec/integration/value_object_spec.rb +++ b/spec/integration/value_object_spec.rb @@ -61,11 +61,9 @@ class FooValueObject < Definition::ValueObject end it "correctly nests the error hash" do - begin - test_value_object.new(foo: { bar: 2.0 }) - rescue Definition::InvalidValueObjectError => e - verify(format: :json) { e.conform_result.error_hash } - end + test_value_object.new(foo: { bar: 2.0 }) + rescue Definition::InvalidValueObjectError => e + verify(format: :json) { e.conform_result.error_hash } end end end diff --git a/spec/lib/definition/types/lambda_spec.rb b/spec/lib/definition/types/lambda_spec.rb index 296a0fe..ed50744 100644 --- a/spec/lib/definition/types/lambda_spec.rb +++ b/spec/lib/definition/types/lambda_spec.rb @@ -92,11 +92,9 @@ describe "when definition does coerce" do let(:test_lambda) do lambda do |value| - begin - conform_with(Float(value)) - rescue ArgumentError - value - end + conform_with(Float(value)) + rescue ArgumentError + value end end diff --git a/spec/lib/definition/types/type_spec.rb b/spec/lib/definition/types/type_spec.rb index 1baa207..b25d97f 100644 --- a/spec/lib/definition/types/type_spec.rb +++ b/spec/lib/definition/types/type_spec.rb @@ -39,11 +39,9 @@ context "with coercion lambda" do let(:definition) do described_class.new(:type, ::Integer) do |v| - begin - Integer(v) - rescue StandardError - v - end + Integer(v) + rescue StandardError + v end end