diff --git a/.github/workflows/specs.yml b/.github/workflows/specs.yml index 027881da..64d2f1ee 100644 --- a/.github/workflows/specs.yml +++ b/.github/workflows/specs.yml @@ -7,13 +7,13 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - ruby: ['2.7.x', '3.0.x', '3.1.x' ] + ruby: ['2.7.8', '3.0.6', '3.1.4' ] name: ${{ matrix.ruby }} steps: - uses: actions/checkout@v3 - name: Set up ruby - uses: actions/setup-ruby@v1 + uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} - name: Install dependencies diff --git a/Gemfile.lock b/Gemfile.lock index 08e1b7e1..5fd01ff1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - stoplight (3.0.1) + stoplight (3.0.2) redlock (~> 1.0) GEM diff --git a/lib/stoplight/light/runnable.rb b/lib/stoplight/light/runnable.rb index f878982b..32305832 100644 --- a/lib/stoplight/light/runnable.rb +++ b/lib/stoplight/light/runnable.rb @@ -52,7 +52,18 @@ def run_red fallback.call(nil) end + MISSING_BLOCK_ERROR = <<~ERROR + Oops! An error occurred while executing the `Stoplight#run` method. This happened because you + didn't pass a code block to the `Stoplight()` function. You can fix this issue this way: + + Stoplight('test-light') { ... }.run + + For more details and examples, please refer to the documentation https://github.com/bolshakov/stoplight/tree/release/v3.x + ERROR + def run_code(on_success, on_failure) + raise ArgumentError, MISSING_BLOCK_ERROR unless code + result = code.call failures = clear_failures on_success&.call(failures) diff --git a/lib/stoplight/version.rb b/lib/stoplight/version.rb index 0760b348..c2b19700 100644 --- a/lib/stoplight/version.rb +++ b/lib/stoplight/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Stoplight - VERSION = Gem::Version.new('3.0.1') + VERSION = Gem::Version.new('3.0.2') end diff --git a/spec/stoplight/light/runnable_spec.rb b/spec/stoplight/light/runnable_spec.rb index 96764fb9..ab2ead50 100644 --- a/spec/stoplight/light/runnable_spec.rb +++ b/spec/stoplight/light/runnable_spec.rb @@ -285,5 +285,13 @@ def random_string end end end + + context 'when the code block is missing' do + subject { Stoplight::Light.new(name) } + + it 'raises an ArgumentError error' do + expect { subject.run }.to raise_error(ArgumentError) + end + end end end diff --git a/stoplight.gemspec b/stoplight.gemspec index e3e33f6c..d230d664 100644 --- a/stoplight.gemspec +++ b/stoplight.gemspec @@ -31,7 +31,7 @@ Gem::Specification.new do |gem| gem.required_ruby_version = '>= 2.6' - gem.add_dependency 'redlock', "~> 1.0" + gem.add_dependency 'redlock', '~> 1.0' gem.add_development_dependency('benchmark-ips', '~> 2.3') gem.add_development_dependency('bugsnag', '~> 4.0')