Skip to content

Commit bd018e3

Browse files
committed
Set request specs as the default for scaffolding
Running rake spec::controllers is removed from smoke tests because they are not generated anymore by default
1 parent 30d847f commit bd018e3

File tree

4 files changed

+13
-14
lines changed

4 files changed

+13
-14
lines changed

example_app_generator/generate_stuff.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ def using_source_path(path)
137137
'config.warnings = false'
138138
gsub_file '.rspec', '--warnings', ''
139139

140-
# Remove skips so we can test controller specs work
141-
gsub_file 'spec/controllers/gadgets_controller_spec.rb',
140+
# Remove skips so we can test that request specs work
141+
gsub_file 'spec/requests/gadgets_request_spec.rb',
142142
'skip("Add a hash of attributes valid for your model")',
143143
'{}'
144144

example_app_generator/run_specs.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
run('bin/rake --backtrace spec:requests') || abort
88
run('bin/rake --backtrace spec:models') || abort
99
run('bin/rake --backtrace spec:views') || abort
10-
run('bin/rake --backtrace spec:controllers') || abort
1110
run('bin/rake --backtrace spec:helpers') || abort
1211
run('bin/rake --backtrace spec:mailers') || abort
1312
run("bin/rake --backtrace stats") || abort

lib/generators/rspec/scaffold/scaffold_generator.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ class ScaffoldGenerator < Base
1616
class_option :singleton, type: :boolean, desc: "Supply to create a singleton controller"
1717
class_option :api, type: :boolean, desc: "Skip specs unnecessary for API-only apps"
1818

19-
class_option :request_specs, type: :boolean, default: false, desc: "Generate request specs"
20-
class_option :controller_specs, type: :boolean, default: true, desc: "Generate controller specs"
19+
class_option :request_specs, type: :boolean, default: true, desc: 'Generate request specs'
20+
class_option :controller_specs, type: :boolean, default: false, desc: 'Generate controller specs'
2121
class_option :view_specs, type: :boolean, default: true, desc: "Generate view specs"
2222
class_option :helper_specs, type: :boolean, default: true, desc: "Generate helper specs"
2323
class_option :routing_specs, type: :boolean, default: true, desc: "Generate routing specs"

spec/generators/rspec/scaffold/scaffold_generator_spec.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
describe 'standard request specs' do
99
subject { file('spec/requests/posts_request_spec.rb') }
1010

11-
describe 'with --request_specs' do
11+
describe 'with no options' do
1212
before { run_generator %w[posts --request_specs] }
1313
it { is_expected.to exist }
1414
it { is_expected.to contain("require 'rails_helper'") }
@@ -19,17 +19,17 @@
1919
it { is_expected.to contain(/"redirects to the \w+ list"/) }
2020
end
2121

22-
describe 'with no options' do
23-
before { run_generator %w[posts] }
22+
describe 'with --no-request_specs' do
23+
before { run_generator %w[posts --no-request_specs] }
2424
it { is_expected.not_to exist }
2525
end
2626
end
2727

2828
describe 'standard controller spec' do
2929
subject { file('spec/controllers/posts_controller_spec.rb') }
3030

31-
describe 'with no options' do
32-
before { run_generator %w[posts] }
31+
describe 'with --controller_specs' do
32+
before { run_generator %w[posts --controller_specs] }
3333
it { is_expected.to contain(/require 'rails_helper'/) }
3434
it { is_expected.to contain(/^RSpec.describe PostsController, #{type_metatag(:controller)}/) }
3535
it { is_expected.to contain(/GET #new/) }
@@ -47,13 +47,13 @@
4747
it { is_expected.to contain(/"redirects to the \w+ list"/) }
4848
end
4949

50-
describe 'with --no-controller_specs' do
51-
before { run_generator %w[posts --no-controller_specs] }
50+
describe 'with no option' do
51+
before { run_generator %w[posts] }
5252
it { is_expected.not_to exist }
5353
end
5454

5555
describe 'with --api' do
56-
before { run_generator %w[posts --api] }
56+
before { run_generator %w[posts --controller_specs --api] }
5757
it { is_expected.to contain(/require 'rails_helper'/) }
5858
it { is_expected.to contain(/^RSpec.describe PostsController, #{type_metatag(:controller)}/) }
5959
it { is_expected.not_to contain(/GET #new/) }
@@ -81,7 +81,7 @@
8181

8282
describe 'namespaced controller spec' do
8383
subject { file('spec/controllers/admin/posts_controller_spec.rb') }
84-
before { run_generator %w[admin/posts] }
84+
before { run_generator %w[admin/posts --controller_specs] }
8585
it { is_expected.to contain(/^RSpec.describe Admin::PostsController, #{type_metatag(:controller)}/) }
8686
end
8787

0 commit comments

Comments
 (0)