From 3235c857c986fa5177039e7190e77965989621f7 Mon Sep 17 00:00:00 2001 From: Damian Galarza Date: Fri, 4 Mar 2016 16:06:52 -0500 Subject: [PATCH] Test against Rails 5 Heavily inspired by derekprior's work on testing Clearance against Rails 5. This will pave the way to releasing HighVoltage 3.0 which removes caching support but provides Rails 5 support. --- Appraisals | 6 +++ Gemfile | 7 +-- Gemfile.lock | 76 ++++++++++++++++---------------- gemfiles/rails4.0.gemfile | 3 +- gemfiles/rails4.1.gemfile | 3 +- gemfiles/rails4.2.gemfile | 3 +- gemfiles/rails50.gemfile | 10 +++++ high_voltage.gemspec | 1 - spec/spec_helper.rb | 9 ++++ spec/support/http_method_shim.rb | 15 +++++++ 10 files changed, 88 insertions(+), 45 deletions(-) create mode 100644 gemfiles/rails50.gemfile create mode 100644 spec/support/http_method_shim.rb diff --git a/Appraisals b/Appraisals index fc15fd3..e20bbf5 100644 --- a/Appraisals +++ b/Appraisals @@ -5,3 +5,9 @@ rails_versions.each do |rails_version| gem 'rails', rails_version end end + +appraise "rails50" do + gem "rails", "~> 5.0.0.beta3" + gem "rspec-rails", "3.5.0.beta1" + gem "rails-controller-testing" +end diff --git a/Gemfile b/Gemfile index 50b2609..836cfe7 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,6 @@ -source "http://rubygems.org" - -gem 'appraisal' +source "https://rubygems.org" gemspec + +gem "appraisal" +gem "rspec-rails", "~> 3.2" diff --git a/Gemfile.lock b/Gemfile.lock index 4a622cc..fea313f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -4,22 +4,22 @@ PATH high_voltage (2.4.0) GEM - remote: http://rubygems.org/ + remote: https://rubygems.org/ specs: - actionpack (4.2.0) - actionview (= 4.2.0) - activesupport (= 4.2.0) - rack (~> 1.6.0) + actionpack (4.2.5.2) + actionview (= 4.2.5.2) + activesupport (= 4.2.5.2) + rack (~> 1.6) rack-test (~> 0.6.2) rails-dom-testing (~> 1.0, >= 1.0.5) - rails-html-sanitizer (~> 1.0, >= 1.0.1) - actionview (4.2.0) - activesupport (= 4.2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (4.2.5.2) + activesupport (= 4.2.5.2) builder (~> 3.1) erubis (~> 2.7.0) rails-dom-testing (~> 1.0, >= 1.0.5) - rails-html-sanitizer (~> 1.0, >= 1.0.1) - activesupport (4.2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + activesupport (4.2.5.2) i18n (~> 0.7) json (~> 1.7, >= 1.7.7) minitest (~> 5.1) @@ -34,55 +34,55 @@ GEM diff-lcs (1.2.5) erubis (2.7.0) i18n (0.7.0) - json (1.8.2) - loofah (2.0.1) + json (1.8.3) + loofah (2.0.3) nokogiri (>= 1.5.9) method_source (0.8.2) - mini_portile (0.6.2) - minitest (5.5.1) - nokogiri (1.6.6.2) - mini_portile (~> 0.6.0) + mini_portile2 (2.0.0) + minitest (5.8.4) + nokogiri (1.6.7.2) + mini_portile2 (~> 2.0.0.rc2) pry (0.10.1) coderay (~> 1.1.0) method_source (~> 0.8.1) slop (~> 3.4) - rack (1.6.0) + rack (1.6.4) rack-test (0.6.3) rack (>= 1.0) rails-deprecated_sanitizer (1.0.3) activesupport (>= 4.2.0.alpha) - rails-dom-testing (1.0.5) + rails-dom-testing (1.0.7) activesupport (>= 4.2.0.beta, < 5.0) nokogiri (~> 1.6.0) rails-deprecated_sanitizer (>= 1.0.1) - rails-html-sanitizer (1.0.1) + rails-html-sanitizer (1.0.3) loofah (~> 2.0) - railties (4.2.0) - actionpack (= 4.2.0) - activesupport (= 4.2.0) + railties (4.2.5.2) + actionpack (= 4.2.5.2) + activesupport (= 4.2.5.2) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) - rake (10.4.2) - rspec-core (3.2.1) - rspec-support (~> 3.2.0) - rspec-expectations (3.2.0) + rake (10.5.0) + rspec-core (3.4.3) + rspec-support (~> 3.4.0) + rspec-expectations (3.4.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.2.0) - rspec-mocks (3.2.1) + rspec-support (~> 3.4.0) + rspec-mocks (3.4.1) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.2.0) - rspec-rails (3.2.1) + rspec-support (~> 3.4.0) + rspec-rails (3.4.2) actionpack (>= 3.0, < 4.3) activesupport (>= 3.0, < 4.3) railties (>= 3.0, < 4.3) - rspec-core (~> 3.2.0) - rspec-expectations (~> 3.2.0) - rspec-mocks (~> 3.2.0) - rspec-support (~> 3.2.0) - rspec-support (3.2.2) + rspec-core (~> 3.4.0) + rspec-expectations (~> 3.4.0) + rspec-mocks (~> 3.4.0) + rspec-support (~> 3.4.0) + rspec-support (3.4.1) slop (3.6.0) thor (0.19.1) - thread_safe (0.3.4) + thread_safe (0.3.5) tzinfo (1.2.2) thread_safe (~> 0.1) @@ -94,7 +94,7 @@ DEPENDENCIES appraisal high_voltage! pry - rspec-rails (~> 3.2.0) + rspec-rails (~> 3.2) BUNDLED WITH - 1.10.0 + 1.11.2 diff --git a/gemfiles/rails4.0.gemfile b/gemfiles/rails4.0.gemfile index 2d86db6..c41c499 100644 --- a/gemfiles/rails4.0.gemfile +++ b/gemfiles/rails4.0.gemfile @@ -1,8 +1,9 @@ # This file was generated by Appraisal -source "http://rubygems.org" +source "https://rubygems.org" gem "appraisal" +gem "rspec-rails", "~> 3.2" gem "rails", "~> 4.0.0" gemspec :path => "../" diff --git a/gemfiles/rails4.1.gemfile b/gemfiles/rails4.1.gemfile index 074e6b1..67aa42f 100644 --- a/gemfiles/rails4.1.gemfile +++ b/gemfiles/rails4.1.gemfile @@ -1,8 +1,9 @@ # This file was generated by Appraisal -source "http://rubygems.org" +source "https://rubygems.org" gem "appraisal" +gem "rspec-rails", "~> 3.2" gem "rails", "~> 4.1.0" gemspec :path => "../" diff --git a/gemfiles/rails4.2.gemfile b/gemfiles/rails4.2.gemfile index 1a44b39..3e85bb3 100644 --- a/gemfiles/rails4.2.gemfile +++ b/gemfiles/rails4.2.gemfile @@ -1,8 +1,9 @@ # This file was generated by Appraisal -source "http://rubygems.org" +source "https://rubygems.org" gem "appraisal" +gem "rspec-rails", "~> 3.2" gem "rails", "~> 4.2.0" gemspec :path => "../" diff --git a/gemfiles/rails50.gemfile b/gemfiles/rails50.gemfile new file mode 100644 index 0000000..ed7a0f5 --- /dev/null +++ b/gemfiles/rails50.gemfile @@ -0,0 +1,10 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "appraisal" +gem "rspec-rails", "3.5.0.beta1" +gem "rails", "~> 5.0.0.beta3" +gem "rails-controller-testing" + +gemspec :path => "../" diff --git a/high_voltage.gemspec b/high_voltage.gemspec index f6cb798..5cced99 100644 --- a/high_voltage.gemspec +++ b/high_voltage.gemspec @@ -18,5 +18,4 @@ Gem::Specification.new do |s| s.add_development_dependency("activesupport", ">= 3.1.0") s.add_development_dependency("pry") - s.add_development_dependency("rspec-rails", "~> 3.2.0") end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 721590a..f10855a 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -28,4 +28,13 @@ config.include RSpec::Matchers config.mock_with :rspec config.order = "random" + + if Rails::VERSION::MAJOR >= 5 + require "rails-controller-testing" + + config.include( + Rails::Controller::Testing::TemplateAssertions, + type: :controller, + ) + end end diff --git a/spec/support/http_method_shim.rb b/spec/support/http_method_shim.rb new file mode 100644 index 0000000..97dc98f --- /dev/null +++ b/spec/support/http_method_shim.rb @@ -0,0 +1,15 @@ +# Rails 5 deprecates calling HTTP action methods with positional arguments +# in favor of keyword arguments. However, the keyword argument form is only +# supported in Rails 5+. Since we support back to 4, we need some sort of shim +# to avoid super noisy deprecations when running tests. +module HTTPMethodShim + def get(path, params = nil, headers = nil) + super(path, params: params, headers: headers) + end +end + +if Rails::VERSION::MAJOR >= 5 + RSpec.configure do |config| + config.include HTTPMethodShim, type: :controller + end +end