Skip to content

Commit 5eef207

Browse files
author
David Revelo
committed
Address comments
1 parent a3273ec commit 5eef207

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

lib/generators/rspec/controller/controller_generator.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ class ControllerGenerator < Base
77
argument :actions, :type => :array, :default => [], :banner => "action action"
88

99
class_option :template_engine, :desc => "Template engine to generate view files"
10-
class_option :controller_specs, :type => :boolean, :default => true, :desc => "Generate controller specs"
11-
class_option :view_specs, :type => :boolean, :default => true, :desc => "Generate view specs"
12-
class_option :routing_specs, :type => :boolean, :default => false, :desc => "Generate routing specs"
10+
class_option :controller_specs, :type => :boolean, :default => true, :desc => "Generate controller specs"
11+
class_option :view_specs, :type => :boolean, :default => true, :desc => "Generate view specs"
12+
class_option :routing_specs, :type => :boolean, :default => false, :desc => "Generate routing specs"
1313

1414
def generate_controller_spec
15+
return if actions.empty?
1516
return unless options[:controller_specs]
1617

1718
template 'controller_spec.rb',

lib/generators/rspec/controller/templates/routing_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require 'rails_helper'
22

33
<% module_namespacing do -%>
4-
RSpec.describe <%= class_name %>Controller, <%= type_metatag(:routing) %> do
4+
RSpec.describe '<%= class_name %>Controller', <%= type_metatag(:routing) %> do
55
describe 'routing' do
66
<% for action in actions -%>
77
it 'routes to #<%= action %>' do

spec/generators/rspec/controller/controller_generator_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
describe 'the spec' do
1616
it { is_expected.to exist }
1717
it { is_expected.to contain(/require 'rails_helper'/) }
18-
it { is_expected.to contain(/^RSpec.describe PostsController, #{type_metatag(:controller)}/) }
18+
it { is_expected.to contain(/^RSpec.describe 'PostsController', #{type_metatag(:controller)}/) }
1919
end
2020
end
2121
describe 'skipped with a flag' do
@@ -105,15 +105,15 @@
105105
before { run_generator %w(posts --routing-specs) }
106106

107107
it { is_expected.to contain(/require 'rails_helper'/) }
108-
it { is_expected.to contain(/^RSpec.describe PostsController, #{type_metatag(:routing)}/) }
108+
it { is_expected.to contain(/^RSpec.describe 'PostsController', #{type_metatag(:routing)}/) }
109109
it { is_expected.to contain(/describe 'routing'/) }
110110
end
111111

112112
describe 'with action parameter' do
113113
before { run_generator %w(posts seek --routing-specs) }
114114

115115
it { is_expected.to contain(/require 'rails_helper'/) }
116-
it { is_expected.to contain(/^RSpec.describe PostsController, #{type_metatag(:routing)}/) }
116+
it { is_expected.to contain(/^RSpec.describe 'PostsController', #{type_metatag(:routing)}/) }
117117
it { is_expected.to contain(/describe 'routing'/) }
118118
``
119119
it { is_expected.to contain(/it 'routes to #seek'/) }

0 commit comments

Comments
 (0)