thoughtbot / shoulda-matchers

Simple one-liner tests for common Rails functionality
https://matchers.shoulda.io
MIT License
3.51k stars 912 forks source link

have_one with dependent is no longer working from 4.4.0 #1331

Closed prrrnd closed 4 years ago

prrrnd commented 4 years ago

Using dependent on a have_one matcher doesn't seem to work on 4.4.0, but worked on 4.3.0.

RSpec.describe Person, type: :model do
  it { should have_one(:contract).dependent(:destroy) }
end
$ rspec
Randomized with seed 30332

  1) Person 
     Failure/Error: it { should have_one(:contract).dependent(:destroy) }

     NoMethodError:
       undefined method `dependent' for #<RSpec::Matchers::BuiltIn::Has:0x0000564a1e04f5d8>
Volosh1n commented 4 years ago

Same with have_many:

Failure/Error: it { is_expected.to have_many(:products).dependent(:destroy) }

      NoMethodError:
        undefined method `dependent' for #<RSpec::Matchers::BuiltIn::Has:0x000055e2152c1710>
vsppedro commented 4 years ago

Thank you for creating this issue.

There is already a PR to solve this problem.

Soon, we will have a new release with this fix.

mcmire commented 4 years ago

Fixed in v4.4.1!