shoulda-matchers v4.0.0 Release Notes

Release Date: 2019-02-22 // about 5 years ago
  • 🚀 This release mainly brings the gem up to date with modern versions of Ruby and 🚅 Rails and drops support for older, unsupported versions. The compatibility list is now:

    • 💎 Ruby: 2.6.0, 2.5.1, 2.4.4, 2.3.7
    • 🚅 Rails: 5.2.2, 5.1.6.1, 5.0.7, 4.2.10

    Backward-incompatible changes

    • ⬇️ Drop support for Rails 4.0 and 4.1 as well as Ruby 2.0, 2.1, and 2.2, since they've been end-of-lifed. The gem now supports Ruby 2.3+ and Rails 4.2+.

    • use_before_filter, use_after_filter, and use_around_filter are no longer usable when using shoulda-matchers under Rails 5.x, as the corresponding controller callbacks don't exist there. (#1054)

    🗄 Deprecations

    • define_enum_for: with is deprecated in favor of with_values. This is to prevent confusion with with_prefix and with_suffix, which are new. (#1077)

    🐛 Bug fixes

    • 🛠 Fix association matchers when used under Rails 5.x so that they make use of ActiveRecord::Base.connection.data_sources instead of ActiveRecord::Base.connection.tables, which was deprecated. (#933, #943, 61c3654)

    • 🛠 Fix the serialize matcher so that it works with Rails 5.x. (#913, #965, df04f87)

    • 🛠 Fix our custom mocking library Doublespeak, which is used by delegate_method, so that it does not produce a warning under Ruby 2.4. ([#1006], #1038, 8d7dcb8)

    • 🛠 Fix the permit matcher so that it uses the correct method signature to call the controller action with params in order to prevent a warning under Rails 5.x. (#867, #917, #964, #989, ce9624b)

    • Fix the define_enum_for matcher so that it once more allows string columns to be used as enum attributes. (#912, #1063, 5650aae)

    • Fix validate_uniqueness_of when used under Rails 4.2 so that when the attribute you're testing is a boolean column, it will no longer emit a warning. (#949, #1073)

    • Fix validate_inclusion_of so that if it fails, it will no longer blow up with the error "undefined method `attribute_setter' for nil:NilClass". (#904)

    • ➕ Add negative versions of all validation matchers (i.e. implement does_not_match? for them) to prevent them from blowing up with "undefined method `attribute_setter' for nil:NilClass". (#904)

    🔋 Features

    • Add required and optional qualifiers to belong_to and have_one matchers. (When using the belong_to matcher under Rails 5+, required is assumed unless overridden.) (#861, #870, #956, 3af3d9f)

    • Add without_validating_presence qualifier to belong_to to get around the fact that required is assumed, above. (#1153, #1154)

    • Add allow_nil qualifier to delegate_method. (#798, d49cfca)

    • Add allow_nil qualifier to validate_length_of. (#724)

    • ➕ Add a port option to the route matcher to allow testing a route that has a constraint on it such that only a specific port may be used to access that route. (#954, #1074, #1075)

    • Add with_prefix and with_suffix to define_enum_for to allow testing the enum macro with corresponding prefix and suffix options (Rails 5 only). (#961, #1077)

    • Add index_errors option to has_many (Rails 5 only). (#1089, 795ca68)

    👌 Improvements