Skip to content

Commit

Permalink
DRY-up test workflow.
Browse files Browse the repository at this point in the history
  • Loading branch information
dblock committed Apr 10, 2024
1 parent 71330b3 commit cb699f1
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 15 deletions.
30 changes: 15 additions & 15 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,27 @@ jobs:
fail-fast: false
matrix:
ruby: ['2.7', '3.0', '3.1', '3.2', '3.3']
gemfile: [rack_2_0, rack_3_0, rails_6_0, rails_6_1, rails_7_0, rails_7_1]
integration: [false]
gemfile: [Gemfile, gemfiles/rack_2_0.gemfile, gemfiles/rack_3_0.gemfile, gemfiles/rails_6_0.gemfile, gemfiles/rails_6_1.gemfile, gemfiles/rails_7_0.gemfile, gemfiles/rails_7_1.gemfile]
specs: ['spec --exclude-pattern=spec/integration/**/*_spec.rb']
include:
- ruby: '2.7'
integration: multi_json
gemfile: gemfiles/multi_json.gemfile
specs: 'spec/integration/multi_json'
- ruby: '2.7'
integration: multi_xml
gemfile: gemfiles/multi_xml.gemfile
specs: 'spec/integration/multi_xml'
- ruby: '2.7'
integration: rack_2_0
gemfile: gemfiles/rack_2_0.gemfile
specs: 'spec/integration/rack_2_0'
- ruby: '2.7'
integration: rack_3_0
gemfile: gemfiles/rack_3_0.gemfile
specs: 'spec/integration/rack_3_0'
- ruby: '3.3'
integration: no_dry_validation
gemfile: gemfiles/no_dry_validation.gemfile
specs: 'spec/integration/no_dry_validation'
runs-on: ubuntu-latest
env:
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.integration || matrix.gemfile }}.gemfile
BUNDLE_GEMFILE: ${{ github.workspace }}/${{ matrix.gemfile }}
steps:
- uses: actions/checkout@v4

Expand All @@ -49,13 +54,8 @@ jobs:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true

- name: Run tests
if: ${{ !matrix.integration }}
run: bundle exec rake spec

- name: Run integration tests (spec/integration/${{ matrix.integration }})
if: ${{ matrix.integration }}
run: bundle exec rspec spec/integration/${{ matrix.integration }}
- name: Run Tests (${{ matrix.specs }})
run: bundle exec rspec ${{ matrix.specs }}

- name: Coveralls
uses: coverallsapp/github-action@master
Expand Down
31 changes: 31 additions & 0 deletions spec/grape/declared_helpers_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# frozen_string_literal: true

describe Grape::API do
subject do
Class.new(Grape::API) do
helpers do
def declared(options = {})
puts "HERE"
_declared(params, { include_missing: false }.merge(options))
end
end
params do
requires :x, type: Integer
optional :y, type: Integer
end
get do
declared(params)
end
end
end

def app
subject
end

it 'works' do
get '/', x: 1
puts last_response.status
puts last_response.body
end
end

0 comments on commit cb699f1

Please sign in to comment.