diff --git a/.travis.yml b/.travis.yml index b4b8d009..b3603cff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,46 @@ language: ruby +sudo: false rvm: - - 1.9.3 - - 2.0.0 + # - 1.8.7 + # - ree + # - jruby-18mode + # - 1.9.2 + # - 1.9.3 - jruby-19mode + - 2.0.0 + - 2.1 + - 2.2 - rbx-2 -gemfile: - - Gemfile - - Gemfile.edge +install: bundle install --path=vendor/bundle --retry=3 --jobs=3 +cache: + directories: + - vendor/bundle +script: + - bundle exec rake ci +env: + # - "RAILS_VERSION=3.0" + # - "RAILS_VERSION=3.1" + # - "RAILS_VERSION=3.2" + - "RAILS_VERSION=4.0" + - "RAILS_VERSION=4.1" + - "RAILS_VERSION=4.2" + - "RAILS_VERSION=master" matrix: - allow_failures: - - gemfile: Gemfile.edge + exclude: + # - rvm: 1.8.7 + # - ree + # - jruby-18mode + # - rvm: 1.9.2 + - rvm: 1.9.3 + env: RAILS_VERSION=master + - rvm: jruby-19mode + env: RAILS_VERSION=master + - rvm: 2.0.0 + env: RAILS_VERSION=master + - rvm: 2.1 + env: RAILS_VERSION=master + - rvm: 2.2 + env: RAILS_VERSION=master + - rvm: rbx-2 + env: RAILS_VERSION=master + fast_finish: true diff --git a/Gemfile b/Gemfile index 5425c9eb..06e858e4 100644 --- a/Gemfile +++ b/Gemfile @@ -2,3 +2,32 @@ source 'https://rubygems.org' # Specify gem dependencies in active_model_serializers.gemspec gemspec + +version = ENV['RAILS_VERSION'] || '4.0' + +if version == 'master' + gem 'rack', github: 'rack/rack' + gem 'arel', github: 'rails/arel' + git 'https://github.com/rails/rails.git' do + gem 'railties' + gem 'activesupport' + gem 'activemodel' + gem 'actionpack' + gem 'activerecord', group: :test + # Rails 5 + gem 'actionview' + end +else + gem_version = "~> #{version}.0" + gem 'railties', gem_version + gem 'activesupport', gem_version + gem 'activemodel', gem_version + gem 'actionpack', gem_version + gem 'activerecord', gem_version, group: :test +end + +# https://github.com/bundler/bundler/blob/89a8778c19269561926cea172acdcda241d26d23/lib/bundler/dependency.rb#L30-L54 +@windows_platforms = [:mswin, :mingw, :x64_mingw] + +# Windows does not include zoneinfo files, so bundle the tzinfo-data gem +gem 'tzinfo-data', platforms: (@windows_platforms + [:jruby]) diff --git a/Gemfile.edge b/Gemfile.edge deleted file mode 100644 index d4e1c028..00000000 --- a/Gemfile.edge +++ /dev/null @@ -1,9 +0,0 @@ -source 'http://rubygems.org' - -gemspec - -gem 'rails', github: 'rails/rails' - -# Current dependencies of edge rails -gem 'journey', github: 'rails/journey' -gem 'activerecord-deprecated_finders' , github: 'rails/activerecord-deprecated_finders' diff --git a/Rakefile b/Rakefile index c9dc801b..a13ebb82 100644 --- a/Rakefile +++ b/Rakefile @@ -7,6 +7,7 @@ Rake::TestTask.new(:test) do |t| t.libs << 'lib' t.libs << 'test' t.pattern = 'test/**/*_test.rb' + t.ruby_opts = ['-r./test/test_helper.rb'] t.verbose = true end diff --git a/appveyor.yml b/appveyor.yml index 6190feab..17b387ff 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -4,8 +4,6 @@ skip_tags: true environment: matrix: - - ruby_version: "193" - - ruby_version: "193-x64" - ruby_version: "200" - ruby_version: "200-x64" - ruby_version: "21" diff --git a/test/test_helper.rb b/test/test_helper.rb index e36c3700..b7b3f2e9 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,13 +1,36 @@ require "rubygems" require "bundler/setup" +require 'rails' +require 'action_controller' +require 'action_controller/test_case' +require 'action_controller/railtie' +require 'active_support/json' + +gem 'minitest' +require 'minitest/autorun' +if defined?(Minitest::Test) + $minitest_version = 5 # rubocop:disable Style/GlobalVars + # Minitest 5 + # https://github.com/seattlerb/minitest/blob/e21fdda9d/lib/minitest/autorun.rb + # https://github.com/seattlerb/minitest/blob/e21fdda9d/lib/minitest.rb#L45-L59 +else + $minitest_version = 4 # rubocop:disable Style/GlobalVars + # Minitest 4 + # https://github.com/seattlerb/minitest/blob/644a52fd0/lib/minitest/autorun.rb + # https://github.com/seattlerb/minitest/blob/644a52fd0/lib/minitest/unit.rb#L768-L787 + # Ensure backward compatibility with Minitest 4 + Minitest = MiniTest unless defined?(Minitest) + Minitest::Test = MiniTest::Unit::TestCase + def Minitest.after_run(&block) + MiniTest::Unit.after_tests(&block) + end +end + + require "pry" require "active_model_serializers" -require "active_support/json" -require "minitest/autorun" - -require 'rails' module TestHelper Routes = ActionDispatch::Routing::RouteSet.new