Skip to content

Commit 988395e

Browse files
committed
Move scenario filtering to Cucumber hooks
Otherwise, running `cucumber` won't filter scenarios, only `rake cucumber` will.
1 parent b1aab4f commit 988395e

File tree

2 files changed

+23
-22
lines changed

2 files changed

+23
-22
lines changed

Rakefile

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,28 +22,7 @@ RSpec::Core::RakeTask.new(:spec) do |t|
2222
t.rspec_opts = %w[--color]
2323
end
2424

25-
Cucumber::Rake::Task.new(:cucumber) do |t|
26-
string_version = ENV.fetch("RAILS_VERSION", "~> 6.0.0")
27-
version =
28-
if string_version == "master" || string_version.nil?
29-
Float::INFINITY
30-
else
31-
string_version[/\d[\.-]\d/].tr('-', '.')
32-
end
33-
tags = []
34-
35-
if version.to_f >= 6.0
36-
tags << "'not @rails_pre_6'"
37-
end
38-
39-
if version.to_f < 6.0
40-
tags << "'not @rails_post_6'"
41-
end
42-
43-
cucumber_flag = tags.map { |tag| "--tag #{tag}" }
44-
45-
t.cucumber_opts = cucumber_flag
46-
end
25+
Cucumber::Rake::Task.new(:cucumber)
4726

4827
namespace :generate do
4928
desc "generate a fresh app with rspec installed"

features/support/rails_versions.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
def rails_version
2+
string_version = ENV.fetch("RAILS_VERSION", "~> 6.0.0")
3+
if string_version == "master" || string_version.nil?
4+
Float::INFINITY
5+
else
6+
string_version[/\d[\.-]\d/].tr('-', '.')
7+
end
8+
end
9+
10+
Before "@rails_pre_6" do |scenario|
11+
if rails_version.to_f >= 6.0
12+
warn "Skipping scenario #{scenario.name} on Rails v#{rails_version}"
13+
skip_this_scenario
14+
end
15+
end
16+
17+
Before "@rails_post_6" do |scenario|
18+
if rails_version.to_f < 6.0
19+
warn "Skipping scenario #{scenario.name} on Rails v#{rails_version}"
20+
skip_this_scenario
21+
end
22+
end

0 commit comments

Comments
 (0)