Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove all spec views on destroy controller #2475

Merged
merged 2 commits into from Mar 9, 2021
Merged

Conversation

Naokimi
Copy link
Contributor

@Naokimi Naokimi commented Mar 6, 2021

Actions:

  1. rails g controller Authors index show
  2. rails d controller Authors

Current
ON GENERATE
Rails generates controller and view files
Rspec generates controller and view files
ON DESTROY
Rails destroys controller and view files
Rspec destroys only controller

Proposal
ON DESTROY
Rails destroys controller and view files
Rspec destroys controller and view files

@pirj
Copy link
Member

pirj commented Mar 6, 2021

Awesome! Can you please add specs for this change?

@Naokimi
Copy link
Contributor Author

Naokimi commented Mar 6, 2021

run_generator %w[posts], behavior: :revoke isn't working and I can't figure out why (it apparently doesn't run, but it also doesn't raise any errors)
they use it for rails: https://github.com/rails/rails/blob/main/railties/test/generators/task_generator_test.rb#L23

EDIT:
sample test:

    describe 'are destroyed' do
      before do
        run_generator %w[posts index]
        run_generator %w[posts], behavior: :revoke
      end
      describe 'index.html.erb' do
        subject { file('spec/views/posts/index.html.erb_spec.rb') }
        it { is_expected.not_to exist }
      end
    end

EDIT2:
The second generator in the before block from the sample test doesn't run. Still haven't figured out why

@Naokimi
Copy link
Contributor Author

Naokimi commented Mar 8, 2021

@pirj found a workaround, ready to be reviewed again

@benoittgt
Copy link
Member

Hello @Naokimi and thanks for you PR.

Tested locally and it is looks good to me.

Capture d’écran 2021-03-08 à 21 13 43

@JonRowe
Copy link
Member

JonRowe commented Mar 8, 2021

Do we have this problem with other generators? Do we want to ensure we're consistent?

@Naokimi
Copy link
Contributor Author

Naokimi commented Mar 9, 2021

seems like other generators work as intended
just controller one had a guard clause that would block expected behaviour

@JonRowe JonRowe merged commit 887fc5f into rspec:main Mar 9, 2021
JonRowe added a commit that referenced this pull request Mar 9, 2021
remove all spec views on destroy controller
JonRowe added a commit that referenced this pull request Mar 9, 2021
This was referenced Mar 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants