Skip to content

Commit 1886646

Browse files
authored
Merge pull request #69 from code4lib/rails_6_too
Test under both ActiveRecord 5.2 and 6.0
2 parents 190d2c1 + 4813d7f commit 1886646

File tree

11 files changed

+95
-8
lines changed

11 files changed

+95
-8
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@
55

66
# Exclude Gemfile.lock (best practice for gems)
77
Gemfile.lock
8+
9+
# Exclude appraisal .locks. per appraisal readme advice
10+
/gemfiles/*.lock

.travis.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
language: ruby
2-
rvm:
3-
- 2.2.10
4-
- 2.5.5
5-
- 2.6.3
62
matrix:
73
allow_failures:
84
- rvm: jruby-9.2.8.0
5+
gemfile: gemfiles/rails_60.gemfile
6+
include:
7+
- rvm: 2.2.10
8+
gemfile: gemfiles/rails_52.gemfile
9+
- rvm: 2.5.5
10+
gemfile: gemfiles/rails_52.gemfile
11+
- rvm: 2.5.5
12+
gemfile: gemfiles/rails_60.gemfile
13+
- rvm: 2.6.3
14+
gemfile: gemfiles/rails_60.gemfile
15+
- rvm: jruby-9.2.8.0
16+
gemfile: gemfiles/rails_60.gemfile
17+
918
script: bundle exec rake test

Appraisals

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# https://github.com/thoughtbot/appraisal
2+
3+
appraise "rails-52" do
4+
gem 'activerecord', '~> 5.2.0'
5+
end
6+
7+
appraise "rails-60" do
8+
gem 'activerecord', '~> 6.0.0'
9+
end

Gemfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ gemspec
55
gem 'jruby-openssl', :platform => :jruby
66

77
group :test do
8-
gem 'activerecord', '~> 5.2.0'
98
gem 'activerecord-jdbcsqlite3-adapter', :platform => [:jruby]
109
gem 'libxml-ruby', :platform => [:ruby, :mswin]
1110
gem 'rake'

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,19 @@ Tests are with Test::Unit, in a somewhat archaic/legacy style. Test setup especi
9494

9595
There are also convenience tasks to run subsets of tests.
9696

97+
We use [appraisal](https://github.com/thoughtbot/appraisal) to test ActiveRecord-related functionality under multiple versions of ActiveRecord. While the above commands will test with latest ActiveRecord (allowed in our .gemspec development dependency), you can test under a particular version defined in the [Appraisals](./Appraisals) file like so:
98+
99+
$ bundle exec appraisal rails-52 rake test
100+
$ bundle exec appraisal rails-60 rake test
101+
102+
If you run into trouble with appraisal's gemfiles getting out of date and bundler complaining,
103+
try:
104+
105+
$ bundle exec appraisal clean
106+
$ appraisal generate
107+
108+
That may make changes to appraisal gemfiles that you should commit to repo.
109+
97110
License
98111
-------
99112

gemfiles/rails_52.gemfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# This file was generated by Appraisal
2+
3+
source "http://rubygems.org"
4+
5+
gem "jruby-openssl", platform: :jruby
6+
gem "activerecord", "~> 5.2.0"
7+
8+
group :test do
9+
gem "activerecord-jdbcsqlite3-adapter", platform: [:jruby]
10+
gem "libxml-ruby", platform: [:ruby, :mswin]
11+
gem "rake"
12+
gem "yard"
13+
gem "redcarpet", platform: :ruby
14+
gem "kramdown", platform: :jruby
15+
gem "test-unit"
16+
gem "sqlite3", ">= 1.4.0", "< 2.0", platform: [:ruby, :mswin]
17+
end
18+
19+
gemspec path: "../"

gemfiles/rails_60.gemfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# This file was generated by Appraisal
2+
3+
source "http://rubygems.org"
4+
5+
gem "jruby-openssl", platform: :jruby
6+
gem "activerecord", "~> 6.0.0"
7+
8+
group :test do
9+
gem "activerecord-jdbcsqlite3-adapter", platform: [:jruby]
10+
gem "libxml-ruby", platform: [:ruby, :mswin]
11+
gem "rake"
12+
gem "yard"
13+
gem "redcarpet", platform: :ruby
14+
gem "kramdown", platform: :jruby
15+
gem "test-unit"
16+
gem "sqlite3", ">= 1.4.0", "< 2.0", platform: [:ruby, :mswin]
17+
end
18+
19+
gemspec path: "../"

lib/oai/provider.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@
137137
# It takes one required paramater, the class name of the AR class to wrap,
138138
# and optional hash of options.
139139
#
140+
# As of `oai` gem 1.0.0, Rails 5.2.x and Rails 6.0.x are supported.
141+
# Please check the .travis.yml file at root of repo to see what versions of ruby/rails
142+
# are being tested, in case this is out of date.
143+
#
140144
# Valid options include:
141145
#
142146
# * `timestamp_field` - Specifies the model field to use as the update

ruby-oai.gemspec

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ Gem::Specification.new do |s|
1515
s.add_dependency('faraday')
1616
s.add_dependency('faraday_middleware')
1717

18+
s.add_development_dependency "activerecord", ">= 5.2.0", "< 6.1"
19+
s.add_development_dependency "appraisal"
20+
21+
1822
s.files = %w(README.md Rakefile) +
1923
Dir.glob("{bin,test,lib}/**/*") +
2024
Dir.glob("examples/**/*.rb")

test/activerecord_provider/config/connection.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@
1313
ActiveRecord::Base.establish_connection :adapter => "sqlite3",
1414
:database => ":memory:"
1515

16-
ActiveRecord::MigrationContext.new(File.join(File.dirname(__FILE__), '..', 'database')).migrate
17-
16+
if ActiveRecord.version < Gem::Version.new("6.0.0")
17+
ActiveRecord::MigrationContext.new(
18+
File.join(File.dirname(__FILE__), '..', 'database')
19+
).migrate
20+
else
21+
ActiveRecord::MigrationContext.new(
22+
File.join(File.dirname(__FILE__), '..', 'database'),
23+
ActiveRecord::Base.connection.schema_migration
24+
).migrate
25+
end
1826

0 commit comments

Comments
 (0)