Skip to content

Commit

Permalink
Use Appraisal to test multiple versions of AMS
Browse files Browse the repository at this point in the history
closes #1
  • Loading branch information
Bajena committed Dec 30, 2018
1 parent 186af1e commit ffd7da6
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 2 deletions.
7 changes: 6 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ env:
global:
- CC_TEST_REPORTER_ID=1da1af59767d8c64ae960d5a0ac69089a0fa90e013aedb09e76843f104bec709
language: ruby
gemfile:
- gemfiles/ams_0.9.gemfile
- gemfiles/ams_0.10.0.rc4.gemfile
- gemfiles/ams_0.10.2.gemfile
- gemfiles/ams_0.10.8.gemfile
cache: bundler
rvm:
- 2.3.4
Expand All @@ -15,7 +20,7 @@ before_script:
- chmod +x ./cc-test-reporter
- ./cc-test-reporter before-build
script:
- bundle exec rake
- bundle exec appraisal rake spec
- git pull origin master:master
- undercover --compare master
after_script:
Expand Down
15 changes: 15 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
appraise "ams-0.9" do
gem "active_model_serializers", "0.9.7"
end

appraise "ams-0.10.0.rc4" do
gem "active_model_serializers", "0.10.0.rc4"
end

appraise "ams-0.10.2" do
gem "active_model_serializers", "0.10.2"
end

appraise "ams-0.10.8" do
gem "active_model_serializers", "0.10.8"
end
5 changes: 5 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ GEM
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
appraisal (2.2.0)
bundler
rake
thor (>= 0.14.0)
arel (9.0.0)
ast (2.4.0)
batch-loader (1.2.2)
Expand Down Expand Up @@ -153,6 +157,7 @@ PLATFORMS
DEPENDENCIES
activerecord
ams_lazy_relationships!
appraisal
bundler (~> 1.17)
db-query-matchers
pry
Expand Down
2 changes: 2 additions & 0 deletions ams_lazy_relationships.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ Gem::Specification.new do |spec|
spec.add_dependency "batch-loader", "=1.2.2"

spec.add_development_dependency "activerecord"
# A Ruby library for testing against different versions of dependencies
spec.add_development_dependency "appraisal"
spec.add_development_dependency "bundler", "~> 1.17"
# Rspec matchers for SQL query counts
spec.add_development_dependency "db-query-matchers"
Expand Down
7 changes: 6 additions & 1 deletion lib/ams_lazy_relationships/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,17 @@ def define_lazy_association(type, name, options, block)

def find_reflection(name)
# In 0.10.3 this private API has changed
if Gem::Version.new(ActiveModel::Serializer::VERSION) >= Gem::Version.new("0.10.3")
if supports_reflections_hash?
_reflections[name.to_sym]
else
_reflections.find { |r| r.name.to_sym == name.to_sym }
end
end

def supports_reflections_hash?
@supports_reflections_hash ||=
Gem::Version.new(ActiveModel::Serializer::VERSION) >= Gem::Version.new("0.10.3")
end
end

module Initializer
Expand Down
7 changes: 7 additions & 0 deletions spec/core/json_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
require "active_model_serializers"

RSpec.describe AmsLazyRelationships::Core do
next if Gem::Version.new(ActiveModel::Serializer::VERSION) < Gem::Version.new("0.10.0.rc1")

extend WithArModels

with_ar_models
Expand All @@ -22,6 +24,7 @@ class BaseTestSerializer < ActiveModel::Serializer
let(:includes) do
[]
end

let(:json) do
ActiveModelSerializers::Adapter::JsonApi.new(
serializer, include: includes
Expand Down Expand Up @@ -214,6 +217,10 @@ def initialize(object)
attr_reader :object

delegate :id, :blog_posts, to: :object

def self.model_name
@_model_name ||= User.model_name
end
end

let(:level0_record) do
Expand Down

0 comments on commit ffd7da6

Please sign in to comment.