Skip to content

Commit a6f63a3

Browse files
authored
Merge pull request #45 from duffn/duffn/test-more-combinations
Add multiple versions of Rails and Ruby to tests
2 parents 857af06 + 6006174 commit a6f63a3

File tree

13 files changed

+221
-41
lines changed

13 files changed

+221
-41
lines changed

.github/workflows/test.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,27 @@ jobs:
66
env:
77
RAILS_ENV: test
88
DATABASE_URL: postgres://test:[email protected]:5432/grape_on_rails_test
9+
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile.file }}.gemfile
10+
continue-on-error: ${{ matrix.gemfile.experimental }}
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
ruby:
15+
- "2.7"
16+
- "3.0"
17+
- "3.1"
18+
- "3.2"
19+
gemfile:
20+
- { file: rails_6, experimental: false }
21+
- { file: rails_6_1, experimental: false }
22+
- { file: rails_7, experimental: false }
23+
- { file: rails_edge, experimental: true }
924
steps:
1025
- uses: actions/checkout@v3
1126
- name: Set up Ruby
1227
uses: ruby/setup-ruby@v1
1328
with:
14-
ruby-version: "3.1.2"
29+
ruby-version: ${{ matrix.ruby }}
1530
bundler-cache: true
1631
- name: Setup Firefox
1732
uses: browser-actions/setup-firefox@latest

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,7 @@
2929

3030
# Ignore master key for decrypting credentials and more.
3131
/config/master.key
32+
33+
# Appraisal gem
34+
.bundle
35+
/gemfiles/*.lock

Appraisals

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# frozen_string_literal: true
2+
3+
appraise 'rails-6' do
4+
gem 'rails', '~> 6.0'
5+
end
6+
7+
appraise 'rails-6-1' do
8+
gem 'rails', '~> 6.1'
9+
end
10+
11+
appraise 'rails-7' do
12+
gem 'rails', '~> 7.0'
13+
end
14+
15+
appraise 'rails-edge' do
16+
gem 'rails', github: 'rails/rails'
17+
end

Gemfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
source 'https://rubygems.org'
22
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
33

4-
ruby '3.1.2'
5-
64
# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
75
gem 'rails', '~> 7.0.3'
86

@@ -48,14 +46,16 @@ gem 'bootsnap', require: false
4846
# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
4947
# gem "image_processing", "~> 1.2"
5048

51-
gem 'grape', '~> 1.6', '>= 1.6.2'
49+
gem 'grape', '~> 1.7'
5250

5351
group :development, :test do
5452
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
5553
gem 'debug', platforms: %i[mri mingw x64_mingw]
5654
end
5755

5856
group :development do
57+
gem 'appraisal'
58+
5959
# Use console on exceptions pages [https://github.com/rails/web-console]
6060
gem 'web-console'
6161

Gemfile.lock

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ GEM
6868
tzinfo (~> 2.0)
6969
addressable (2.8.0)
7070
public_suffix (>= 2.0.2, < 5.0)
71+
appraisal (2.4.1)
72+
bundler
73+
rake
74+
thor (>= 0.14.0)
7175
ast (2.4.2)
7276
bindex (0.8.1)
7377
bootsnap (1.12.0)
@@ -90,28 +94,24 @@ GEM
9094
reline (>= 0.2.7)
9195
diff-lcs (1.5.0)
9296
digest (3.1.0)
93-
dry-configurable (0.15.0)
97+
dry-core (1.0.0)
9498
concurrent-ruby (~> 1.0)
95-
dry-core (~> 0.6)
96-
dry-container (0.9.0)
99+
zeitwerk (~> 2.6)
100+
dry-inflector (1.0.0)
101+
dry-logic (1.5.0)
97102
concurrent-ruby (~> 1.0)
98-
dry-configurable (~> 0.13, >= 0.13.0)
99-
dry-core (0.7.1)
103+
dry-core (~> 1.0, < 2)
104+
zeitwerk (~> 2.6)
105+
dry-types (1.7.1)
100106
concurrent-ruby (~> 1.0)
101-
dry-inflector (0.2.1)
102-
dry-logic (1.2.0)
103-
concurrent-ruby (~> 1.0)
104-
dry-core (~> 0.5, >= 0.5)
105-
dry-types (1.5.1)
106-
concurrent-ruby (~> 1.0)
107-
dry-container (~> 0.3)
108-
dry-core (~> 0.5, >= 0.5)
109-
dry-inflector (~> 0.1, >= 0.1.2)
110-
dry-logic (~> 1.0, >= 1.0.2)
107+
dry-core (~> 1.0)
108+
dry-inflector (~> 1.0)
109+
dry-logic (~> 1.4)
110+
zeitwerk (~> 2.6)
111111
erubi (1.10.0)
112112
globalid (1.0.1)
113113
activesupport (>= 5.0)
114-
grape (1.6.2)
114+
grape (1.7.0)
115115
activesupport
116116
builder
117117
dry-types (>= 1.1)
@@ -140,7 +140,7 @@ GEM
140140
mini_mime (1.1.2)
141141
minitest (5.17.0)
142142
msgpack (1.5.2)
143-
mustermann (1.1.1)
143+
mustermann (3.0.0)
144144
ruby2_keywords (~> 0.0.1)
145145
mustermann-grape (1.0.2)
146146
mustermann (>= 1.0.0)
@@ -159,6 +159,8 @@ GEM
159159
net-protocol
160160
timeout
161161
nio4r (2.5.8)
162+
nokogiri (1.13.10-arm64-darwin)
163+
racc (~> 1.4)
162164
nokogiri (1.13.10-x86_64-darwin)
163165
racc (~> 1.4)
164166
nokogiri (1.13.10-x86_64-linux)
@@ -285,14 +287,16 @@ GEM
285287
zeitwerk (2.6.0)
286288

287289
PLATFORMS
290+
arm64-darwin-21
288291
x86_64-darwin-20
289292
x86_64-linux
290293

291294
DEPENDENCIES
295+
appraisal
292296
bootsnap
293297
capybara
294298
debug
295-
grape (~> 1.6, >= 1.6.2)
299+
grape (~> 1.7)
296300
importmap-rails
297301
jbuilder
298302
pg (~> 1.1)
@@ -309,8 +313,5 @@ DEPENDENCIES
309313
web-console
310314
webdrivers
311315

312-
RUBY VERSION
313-
ruby 3.1.2p20
314-
315316
BUNDLED WITH
316317
2.3.16

README.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
1-
Grape on Rails
2-
==============
1+
# Grape on Rails
32

43
[![Test](https://github.com/ruby-grape/grape-on-rails/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/ruby-grape/grape-on-rails/actions/workflows/test.yml)
4+
[![Rubocop](https://github.com/ruby-grape/grape-on-rails/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/ruby-grape/grape-on-rails/actions/workflows/test.yml)
55
[![Code Climate](https://codeclimate.com/github/ruby-grape/grape-on-rails.svg)](https://codeclimate.com/github/ruby-grape/grape-on-rails)
66

77
A [Grape](http://github.com/ruby-grape/grape) API mounted on Rails.
88

9-
* [ping](app/api/acme/ping.rb): a hello world `GET` API
10-
* [post](app/api/acme/post.rb): post JSON data
11-
* [raise](app/api/acme/raise.rb): raise an error, Rails handling exceptions
12-
* [protected](app/api/acme/protected.rb): API protected with rudimentary Basic Authentication
13-
* [headers](app/api/acme/headers.rb): demonstrates header handling
9+
- [ping](app/api/acme/ping.rb): a hello world `GET` API
10+
- [post](app/api/acme/post.rb): post JSON data
11+
- [raise](app/api/acme/raise.rb): raise an error, Rails handling exceptions
12+
- [protected](app/api/acme/protected.rb): API protected with rudimentary Basic Authentication
13+
- [headers](app/api/acme/headers.rb): demonstrates header handling
1414

15-
Run
16-
---
15+
## Run
1716

1817
```
1918
bundle install
2019
rails s
2120
```
2221

2322
Try http://localhost:3000/api/ping or http://localhost:3000/api/protected/ping with _username_ and _password_.
24-

app/models/application_record.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
class ApplicationRecord < ActiveRecord::Base
2-
primary_abstract_class
2+
if Gem::Version.new(Rails.version) >= Gem::Version.new('7.0')
3+
primary_abstract_class
4+
else
5+
self.abstract_class = true
6+
end
37
end

config/application.rb

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,16 @@
88

99
module GrapeOnRails
1010
class Application < Rails::Application
11-
# Initialize configuration defaults for originally generated Rails version.
12-
config.load_defaults 7.0
13-
11+
# Since we're testing against multiple versions, initialize configuration defaults
12+
# based upon the version we're using.
13+
rails_version = Gem::Version.new(Rails.version)
14+
if rails_version >= Gem::Version.new('7.0')
15+
config.load_defaults 7.0
16+
elsif rails_version >= Gem::Version.new('6.1')
17+
config.load_defaults 6.1
18+
else
19+
config.load_defaults 6.0
20+
end
1421
# Configuration for the application, engines, and railties goes here.
1522
#
1623
# These settings can be overridden in specific environments using the files

gemfiles/rails_6.gemfile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# This file was generated by Appraisal
2+
3+
source 'https://rubygems.org'
4+
5+
gem 'bootsnap', require: false
6+
gem 'grape', '~> 1.7'
7+
gem 'importmap-rails'
8+
gem 'jbuilder'
9+
gem 'pg', '~> 1.1'
10+
gem 'puma', '~> 5.0'
11+
gem 'rails', '~> 6.0'
12+
gem 'sprockets-rails'
13+
gem 'stimulus-rails'
14+
gem 'turbo-rails'
15+
gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]
16+
17+
group :development, :test do
18+
gem 'debug', platforms: %i[mri mingw x64_mingw]
19+
end
20+
21+
group :development do
22+
gem 'appraisal'
23+
gem 'web-console'
24+
end
25+
26+
group :test do
27+
gem 'capybara'
28+
gem 'rspec'
29+
gem 'rspec-rails'
30+
gem 'rubocop'
31+
gem 'selenium-webdriver'
32+
gem 'webdrivers'
33+
end

gemfiles/rails_6_1.gemfile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# This file was generated by Appraisal
2+
3+
source 'https://rubygems.org'
4+
5+
gem 'bootsnap', require: false
6+
gem 'grape', '~> 1.7'
7+
gem 'importmap-rails'
8+
gem 'jbuilder'
9+
gem 'pg', '~> 1.1'
10+
gem 'puma', '~> 5.0'
11+
gem 'rails', '~> 6.1'
12+
gem 'sprockets-rails'
13+
gem 'stimulus-rails'
14+
gem 'turbo-rails'
15+
gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]
16+
17+
group :development, :test do
18+
gem 'debug', platforms: %i[mri mingw x64_mingw]
19+
end
20+
21+
group :development do
22+
gem 'appraisal'
23+
gem 'web-console'
24+
end
25+
26+
group :test do
27+
gem 'capybara'
28+
gem 'rspec'
29+
gem 'rspec-rails'
30+
gem 'rubocop'
31+
gem 'selenium-webdriver'
32+
gem 'webdrivers'
33+
end

0 commit comments

Comments
 (0)