Shoulda-matchers: validate_presence_of fails on Rails 6

Created on 20 Jan 2019  路  7Comments  路  Source: thoughtbot/shoulda-matchers

validate_presence_of relies on the constant ActiveModel::SecurePassword::InstanceMethodsOnActivation

which has been removed in Rails 6 https://github.com/rails/rails/commit/08dde0f355e0450bc2cb7e0b4b95a0ec18d1a870#diff-a6f9af64a6d420eb1103e16c0a0a8f04L66

馃洡 Rails 6

Most helpful comment

It would be really nice to have this fixed with new version of rails around the corner.

As a temporary workaround (as I did not need the password matchers) I used:

# spec/rails_helper.rb - add to bottom
class ActiveModel::SecurePassword::InstanceMethodsOnActivation; end;

All 7 comments

Found the same.

Looks like the third check could also return false when it should return true because the attribute can be assigned by the user now instead of always being password.

https://github.com/thoughtbot/shoulda-matchers/blob/f951455f0f66ebc09a80bb20089b1b253c2ac0fb/lib/shoulda/matchers/active_model/validate_presence_of_matcher.rb#L149-L153

It would be really nice to have this fixed with new version of rails around the corner.

As a temporary workaround (as I did not need the password matchers) I used:

# spec/rails_helper.rb - add to bottom
class ActiveModel::SecurePassword::InstanceMethodsOnActivation; end;

@yagudaev We plan on including support for Rails 6 in the next immediate version, so this is included in the list of upcoming changes.

@yagudaev thanks for the workaround!

This is fixed now! ^

@mcmire can we get a new release now that Rails 6.0.0.rc1 is out? :) I just ran my test suite with the latest master on Rails 6 and it worked great 馃憤

Was this page helpful?
0 / 5 - 0 ratings