From 2f8841d697fa0ce9af16746b55e29aa776009c4a Mon Sep 17 00:00:00 2001 From: Paulo DAlberti Date: Sat, 6 Mar 2021 14:08:03 +0900 Subject: [PATCH 1/2] remove all views on destroy controller --- lib/generators/rspec/controller/controller_generator.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/generators/rspec/controller/controller_generator.rb b/lib/generators/rspec/controller/controller_generator.rb index c03ae83184..4111a9aabb 100644 --- a/lib/generators/rspec/controller/controller_generator.rb +++ b/lib/generators/rspec/controller/controller_generator.rb @@ -27,7 +27,7 @@ def generate_controller_spec end def generate_view_specs - return if actions.empty? + return if actions.empty? && behavior == :invoke return unless options[:view_specs] && options[:template_engine] empty_directory File.join("spec", "views", file_path) From 710e997e8265005f661cc531a25243896f2d7c4f Mon Sep 17 00:00:00 2001 From: Paulo DAlberti Date: Mon, 8 Mar 2021 13:14:45 +0900 Subject: [PATCH 2/2] added test --- .../generators/rspec/controller/controller_generator_spec.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spec/generators/rspec/controller/controller_generator_spec.rb b/spec/generators/rspec/controller/controller_generator_spec.rb index 4143af50fe..3885194abf 100644 --- a/spec/generators/rspec/controller/controller_generator_spec.rb +++ b/spec/generators/rspec/controller/controller_generator_spec.rb @@ -115,6 +115,11 @@ end end end + + describe 'are removed' do + subject { run_generator %w[posts], behavior: :revoke } + it { is_expected.to match('remove spec/views/posts') } + end end describe 'routing spec' do