Skip to content

Commit 65ea1e4

Browse files
author
David Revelo
committed
Fix broken specs
1 parent 5eef207 commit 65ea1e4

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

lib/generators/rspec/controller/controller_generator.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ class ControllerGenerator < Base
1212
class_option :routing_specs, :type => :boolean, :default => false, :desc => "Generate routing specs"
1313

1414
def generate_controller_spec
15-
return if actions.empty?
1615
return unless options[:controller_specs]
1716

1817
template 'controller_spec.rb',
@@ -33,6 +32,7 @@ def generate_view_specs
3332
end
3433

3534
def generate_routing_spec
35+
return if actions.empty?
3636
return unless options[:routing_specs]
3737

3838
template 'routing_spec.rb',

spec/generators/rspec/controller/controller_generator_spec.rb

Lines changed: 11 additions & 11 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
@@ -95,18 +95,18 @@
9595
subject { file('spec/routing/posts_routing_spec.rb') }
9696

9797
describe 'with no flag' do
98-
before { run_generator %w(posts seek and destroy) }
99-
98+
before do
99+
run_generator %w(posts seek and destroy)
100+
end
100101
it { is_expected.not_to exist }
101102
end
102103

103104
describe 'with --routing-specs flag' do
104105
describe 'without action parameter' do
105-
before { run_generator %w(posts --routing-specs) }
106-
107-
it { is_expected.to contain(/require 'rails_helper'/) }
108-
it { is_expected.to contain(/^RSpec.describe 'PostsController', #{type_metatag(:routing)}/) }
109-
it { is_expected.to contain(/describe 'routing'/) }
106+
before do
107+
run_generator %w(posts --routing-specs)
108+
end
109+
it { is_expected.not_to exist }
110110
end
111111

112112
describe 'with action parameter' do
@@ -115,15 +115,15 @@
115115
it { is_expected.to contain(/require 'rails_helper'/) }
116116
it { is_expected.to contain(/^RSpec.describe 'PostsController', #{type_metatag(:routing)}/) }
117117
it { is_expected.to contain(/describe 'routing'/) }
118-
``
119118
it { is_expected.to contain(/it 'routes to #seek'/) }
120119
it { is_expected.to contain(/expect\(:get => "\/posts\/seek"\).to route_to\("posts#seek"\)/) }
121120
end
122121
end
123122

124123
describe 'with --no-routing-specs flag' do
125-
before { run_generator %w(posts seek and destroy --no-routing_specs) }
126-
124+
before do
125+
run_generator %w(posts seek and destroy --no-routing_specs)
126+
end
127127
it { is_expected.not_to exist }
128128
end
129129
end

0 commit comments

Comments
 (0)