Skip to content

Commit 5a8928d

Browse files
committed
Don't provide system spec generator under Rails 5.1
1 parent 4ce336e commit 5a8928d

File tree

2 files changed

+21
-27
lines changed

2 files changed

+21
-27
lines changed

lib/generators/rspec/system/system_generator.rb

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
require 'generators/rspec'
22

3-
module Rspec
4-
module Generators
5-
# @private
6-
class SystemGenerator < Base
7-
class_option :system_specs, :type => :boolean, :default => true, :desc => "Generate system specs"
3+
if ::Rails::VERSION::STRING >= '5.1'
4+
module Rspec
5+
module Generators
6+
# @private
7+
class SystemGenerator < Base
8+
class_option :system_specs, :type => :boolean, :default => true, :desc => "Generate system specs"
89

9-
def generate_system_spec
10-
return unless options[:system_specs]
11-
raise "System Tests are available for Rails >= 5.1" if ::Rails::VERSION::STRING < '5.1'
10+
def generate_system_spec
11+
return unless options[:system_specs]
1212

13-
template template_name, File.join('spec/system', class_path, filename)
14-
end
13+
template template_name, File.join('spec/system', class_path, filename)
14+
end
1515

16-
def template_name
17-
'system_spec.rb'
18-
end
16+
def template_name
17+
'system_spec.rb'
18+
end
1919

20-
def filename
21-
"#{table_name}_spec.rb"
20+
def filename
21+
"#{table_name}_spec.rb"
22+
end
2223
end
2324
end
2425
end

spec/generators/rspec/system/system_generator_spec.rb

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,12 @@
22
require 'generators/rspec/system/system_generator'
33
require 'support/generators'
44

5-
RSpec.describe Rspec::Generators::SystemGenerator, :type => :generator do
6-
setup_default_destination
5+
if ::Rails::VERSION::STRING >= '5.1'
6+
RSpec.describe Rspec::Generators::SystemGenerator, :type => :generator do
7+
setup_default_destination
78

8-
describe "system specs" do
9-
subject(:system_spec) { file("spec/system/posts_spec.rb") }
10-
if ::Rails::VERSION::STRING < '5.1'
11-
describe "are not available" do
12-
it "raise error for user" do
13-
expect{ run_generator(%w(posts)) }
14-
.to raise_error(RuntimeError, "System Tests are available for Rails >= 5.1")
15-
end
16-
end
17-
else
9+
describe "system specs" do
10+
subject(:system_spec) { file("spec/system/posts_spec.rb") }
1811
describe "are generated independently from the command line" do
1912
before do
2013
run_generator %w(posts)

0 commit comments

Comments
 (0)