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

False positives in rspec change blocks #44

Closed
Goltergaul opened this issue Oct 24, 2024 · 7 comments
Closed

False positives in rspec change blocks #44

Goltergaul opened this issue Oct 24, 2024 · 7 comments

Comments

@Goltergaul
Copy link

rubocop-sequel thinks that rspec change expectations are database migrations:

e.g:

spec/app/repositories/run_session/strategy/mongo_db/hard_delete_spec.rb:67:41: C: Sequel/IrreversibleMigration: Avoid using document_count inside a change block. Use up & down blocks instead.
    it { expect { subject }.to change { document_count(user_id) }.by(-1) }

spec/app/repositories/sport_activity/wrappers/plausibility_spec.rb:225:60: C: Sequel/IrreversibleMigration: Avoid using find inside a change block. Use up & down blocks instead.
        expect { subject }.not_to(change { described_class.find(id: sport_activity.id).plausible })
@Goltergaul
Copy link
Author

Goltergaul commented Oct 24, 2024

https://github.com/rubocop/rubocop-sequel/blob/master/lib/rubocop/cop/sequel/irreversible_migration.rb#L33 this should probably check further that the block is actually part of a sequel migration

@cyberdelia
Copy link
Collaborator

You may also configure rubocop to only run sequel cops on migrations related code, it will also speed up your checks overall.

@Goltergaul
Copy link
Author

I know but I don't really want to need to add custom config for such things. Should ideally just work out of the box

@AlasdairWallaceMackie
Copy link
Contributor

I'll work on a fix for this, sorry about that!

@Goltergaul
Copy link
Author

Goltergaul commented Oct 24, 2024

no problem at all, just wanted to bring it to your attention :) Thanks for looking into it!

@cyberdelia
Copy link
Collaborator

I believe this was fixed in 0.3.6.

@Goltergaul
Copy link
Author

Thank you @cyberdelia

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

No branches or pull requests

3 participants