Skip to content

Rails 5.1 compatibility #1790

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

Merged
merged 9 commits into from
Apr 9, 2017
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
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,20 @@ matrix:
env: RAILS_VERSION=master
- rvm: 2.2.2
env: RAILS_VERSION=5-0-stable
- rvm: 2.2.2
env: RAILS_VERSION=5.1.0.rc1
- rvm: 2.3.3
env: RAILS_VERSION=master
- rvm: 2.3.3
env: RAILS_VERSION=5-0-stable
- rvm: 2.3.3
env: RAILS_VERSION=5.1.0.rc1
- rvm: 2.4.0
env: RAILS_VERSION=master
- rvm: 2.4.0
env: RAILS_VERSION=5-0-stable
- rvm: 2.4.0
env: RAILS_VERSION=5.1.0.rc1
exclude:
# 3.0.x is not supported on MRI 2.0+
- rvm: 2.0.0
Expand Down
34 changes: 26 additions & 8 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ require 'rspec'
require 'rspec/core/rake_task'
require 'cucumber/rake/task'

def rails_template_command
require "rails"
if Rails.version.to_f >= 5.0
"app:template"
else
"rails:template"
end
end

desc "Run all examples"
RSpec::Core::RakeTask.new(:spec) do |t|
t.ruby_opts = %w[-w]
Expand All @@ -20,11 +29,21 @@ end
Cucumber::Rake::Task.new(:cucumber) do |t|
version = ENV.fetch("RAILS_VERSION", "~> 4.2.0")
cucumber_flag = "--tags ~@rails_post_5"
p version
if /(^| )5(\.|-)0/ === version || version == "master"
cucumber_flag = "--tags ~@rails_pre_5"
tags = []
if version.to_f >= 5.1
tags << "~@rails_pre_5.1"
end

if version.to_f >= 5.0
tags << "~@rails_pre_5"
end

if tags.empty?
tags << "~@rails_post_5"
end

cucumber_flag = tags.map { |tag| "--tag #{tag}" }

t.cucumber_opts = cucumber_flag
end

Expand Down Expand Up @@ -58,7 +77,7 @@ namespace :generate do

desc "generate a bunch of stuff with generators"
task :stuff do
in_example_app "bin/rake rails:template LOCATION='../../example_app_generator/generate_stuff.rb'"
in_example_app "bin/rake #{rails_template_command} LOCATION='../../example_app_generator/generate_stuff.rb'"
end
end

Expand Down Expand Up @@ -90,7 +109,7 @@ end

desc "run a variety of specs against the generated app"
task :smoke do
in_example_app "LOCATION='../../example_app_generator/run_specs.rb' bin/rake rails:template --backtrace"
in_example_app "LOCATION='../../example_app_generator/run_specs.rb' bin/rake #{rails_template_command} --backtrace"
end

namespace :smoke do
Expand Down Expand Up @@ -131,7 +150,7 @@ namespace :no_active_record do

desc "run a variety of specs against a non-ActiveRecord generated app"
task :smoke do
in_example_app "LOCATION='../../example_app_generator/run_specs.rb' bin/rake rails:template --backtrace",
in_example_app "LOCATION='../../example_app_generator/run_specs.rb' bin/rake #{rails_template_command} --backtrace",
:app_dir => example_app_dir
end

Expand Down Expand Up @@ -180,8 +199,7 @@ namespace :no_active_record do

desc "generate a bunch of stuff with generators"
task :stuff do
in_example_app "bin/rake rails:template LOCATION='../../example_app_generator/generate_stuff.rb'",
:app_dir => example_app_dir
in_example_app "bin/rake #{rails_template_command} LOCATION='../../example_app_generator/generate_stuff.rb'", :app_dir => example_app_dir
end
end
end
Expand Down
Loading