Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Appraisal to test different versions of AMS #6

Merged
merged 4 commits into from
Dec 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .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 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
2 changes: 2 additions & 0 deletions gemfiles/.bundle/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
BUNDLE_RETRY: "1"
7 changes: 7 additions & 0 deletions gemfiles/ams_0.10.0.rc4.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "active_model_serializers", "0.10.0.rc4"

gemspec path: "../"
7 changes: 7 additions & 0 deletions gemfiles/ams_0.10.2.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "active_model_serializers", "0.10.2"

gemspec path: "../"
7 changes: 7 additions & 0 deletions gemfiles/ams_0.10.8.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "active_model_serializers", "0.10.8"

gemspec path: "../"
7 changes: 7 additions & 0 deletions gemfiles/ams_0.9.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "active_model_serializers", "0.9.7"

gemspec path: "../"
16 changes: 15 additions & 1 deletion 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,8 +24,16 @@ class BaseTestSerializer < ActiveModel::Serializer
let(:includes) do
[]
end

let(:adapter_class) do
version = Gem::Version.new(ActiveModel::Serializer::VERSION)
return "ActiveModelSerializers::Adapter::JsonApi".constantize if version >= Gem::Version.new("0.10.2")
return "ActiveModel::Serializer::Adapter::JsonApi".constantize# if version >= Gem::Version.new("0.10.0.rc1")
end


let(:json) do
ActiveModelSerializers::Adapter::JsonApi.new(
adapter_class.new(
serializer, include: includes
).as_json
end
Expand Down Expand Up @@ -214,6 +224,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