Skip to content

Commit 23c891e

Browse files
author
Sam Phippen
authored
Merge pull request #1790 from rspec/rails-5.1-compat
Rails 5.1 compatibility
2 parents e80be2c + 915e2c3 commit 23c891e

File tree

13 files changed

+650
-16
lines changed

13 files changed

+650
-16
lines changed

.travis.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,20 @@ matrix:
6060
env: RAILS_VERSION=master
6161
- rvm: 2.2.2
6262
env: RAILS_VERSION=5-0-stable
63+
- rvm: 2.2.2
64+
env: RAILS_VERSION=5.1.0.rc1
6365
- rvm: 2.3.3
6466
env: RAILS_VERSION=master
6567
- rvm: 2.3.3
6668
env: RAILS_VERSION=5-0-stable
69+
- rvm: 2.3.3
70+
env: RAILS_VERSION=5.1.0.rc1
6771
- rvm: 2.4.0
6872
env: RAILS_VERSION=master
6973
- rvm: 2.4.0
7074
env: RAILS_VERSION=5-0-stable
75+
- rvm: 2.4.0
76+
env: RAILS_VERSION=5.1.0.rc1
7177
exclude:
7278
# 3.0.x is not supported on MRI 2.0+
7379
- rvm: 2.0.0

Rakefile

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@ require 'rspec'
1111
require 'rspec/core/rake_task'
1212
require 'cucumber/rake/task'
1313

14+
def rails_template_command
15+
require "rails"
16+
if Rails.version.to_f >= 5.0
17+
"app:template"
18+
else
19+
"rails:template"
20+
end
21+
end
22+
1423
desc "Run all examples"
1524
RSpec::Core::RakeTask.new(:spec) do |t|
1625
t.ruby_opts = %w[-w]
@@ -20,11 +29,21 @@ end
2029
Cucumber::Rake::Task.new(:cucumber) do |t|
2130
version = ENV.fetch("RAILS_VERSION", "~> 4.2.0")
2231
cucumber_flag = "--tags ~@rails_post_5"
23-
p version
24-
if /(^| )5(\.|-)0/ === version || version == "master"
25-
cucumber_flag = "--tags ~@rails_pre_5"
32+
tags = []
33+
if version.to_f >= 5.1
34+
tags << "~@rails_pre_5.1"
2635
end
2736

37+
if version.to_f >= 5.0
38+
tags << "~@rails_pre_5"
39+
end
40+
41+
if tags.empty?
42+
tags << "~@rails_post_5"
43+
end
44+
45+
cucumber_flag = tags.map { |tag| "--tag #{tag}" }
46+
2847
t.cucumber_opts = cucumber_flag
2948
end
3049

@@ -58,7 +77,7 @@ namespace :generate do
5877

5978
desc "generate a bunch of stuff with generators"
6079
task :stuff do
61-
in_example_app "bin/rake rails:template LOCATION='../../example_app_generator/generate_stuff.rb'"
80+
in_example_app "bin/rake #{rails_template_command} LOCATION='../../example_app_generator/generate_stuff.rb'"
6281
end
6382
end
6483

@@ -90,7 +109,7 @@ end
90109

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

96115
namespace :smoke do
@@ -131,7 +150,7 @@ namespace :no_active_record do
131150

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

@@ -180,8 +199,7 @@ namespace :no_active_record do
180199

181200
desc "generate a bunch of stuff with generators"
182201
task :stuff do
183-
in_example_app "bin/rake rails:template LOCATION='../../example_app_generator/generate_stuff.rb'",
184-
:app_dir => example_app_dir
202+
in_example_app "bin/rake #{rails_template_command} LOCATION='../../example_app_generator/generate_stuff.rb'", :app_dir => example_app_dir
185203
end
186204
end
187205
end

0 commit comments

Comments
 (0)