Phil Pirozhkov
Phil Pirozhkov
There is a slight problem with the existing `have_enqueued_sidekiq_job` matcher, specifically that it's prone to the [incidental state error](https://rspec.rubystyle.guide/#incidental-state), unlike `rspec-rails`'s [Active Job-oriented `have_enqueued_job`](https://relishapp.com/rspec/rspec-rails/v/4-0/docs/job-specs/job-spec) that is a block syntax matcher....
If puzzles me what the type of the object is when I read something like: ```ruby user = find_user return if user.blank? ``` or ```ruby results = find_matches suggest(results) if...
1. https://rails.rubystyle.guide/#define-model-class-migrations claims that > or cause serious data corruption Can you think of a use case when an old migration could cause a serious data corruption? Yes, it will...
There's a number of methods that have modern counterparts, recommend using the new ones instead.
Only use `before` and `let`, when there's a compelling benefit, don't use them as the default way to write specs. https://reddit.com/r/ruby/comments/73nrhk/ama_the_authors_of_effective_testing_with_rspec_3/dnsyanp/ An example I can think of: ```ruby # bad...
Don't overuse hooks, prefer explicitness. Helper methods are more explicit and even provide more flexibility An example off the top of my head: ```ruby # bad let(:article) { Article.new }...
In addition to `verify_partial_doubles` the above option may come handy to verify that you are stubbing an existing constant. ``` # When this is set to true, an error will...
Taken from Effective Testing with RSpec book. There's a matching [`RSpec/UnspecifiedException`](https://github.com/rubocop-hq/rubocop-rspec/blob/cc158decc3df402751e463843fb82ad718a58955/lib/rubocop/cop/rspec/unspecified_exception.rb#L6) cop in RuboCop-RSpec. [Example problem](https://github.com/rspec/rspec-mocks/pull/550) with it. The negated form has the opposite problem, and the exception should **not**...
Metadata is very useful and is able to include shared contexts, include group/example-specific helpers and hooks.
It's strange that the guide is missing that.