@@ -11,6 +11,15 @@ require 'rspec'
11
11
require 'rspec/core/rake_task'
12
12
require 'cucumber/rake/task'
13
13
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
+
14
23
desc "Run all examples"
15
24
RSpec ::Core ::RakeTask . new ( :spec ) do |t |
16
25
t . ruby_opts = %w[ -w ]
20
29
Cucumber ::Rake ::Task . new ( :cucumber ) do |t |
21
30
version = ENV . fetch ( "RAILS_VERSION" , "~> 4.2.0" )
22
31
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 "
26
35
end
27
36
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
+
28
47
t . cucumber_opts = cucumber_flag
29
48
end
30
49
@@ -58,7 +77,7 @@ namespace :generate do
58
77
59
78
desc "generate a bunch of stuff with generators"
60
79
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'"
62
81
end
63
82
end
64
83
90
109
91
110
desc "run a variety of specs against the generated app"
92
111
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"
94
113
end
95
114
96
115
namespace :smoke do
@@ -131,7 +150,7 @@ namespace :no_active_record do
131
150
132
151
desc "run a variety of specs against a non-ActiveRecord generated app"
133
152
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" ,
135
154
:app_dir => example_app_dir
136
155
end
137
156
@@ -180,8 +199,7 @@ namespace :no_active_record do
180
199
181
200
desc "generate a bunch of stuff with generators"
182
201
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
185
203
end
186
204
end
187
205
end
0 commit comments