'Convert RSpec 2 "to have().errors_on" matcher to RSpec 3
In my Gemfile
gem 'rspec-rails', '~> 3.3'
I figured out, that the errors_on matcher moved to another gem: https://github.com/rspec/rspec-collection_matchers
I'm positive that there must a way to achieve the same within RSpec 3.
How can I convert the RSpec 2 have().errors_on matcher to RSpec 3?
expect {
click_button(I18n.t('helpers.submit.accounting.update'))
}.to have(4).errors_on(:share_ksk, :central_office, :limit_value, :fix_disagio)
I tried:
expect {
click_button(I18n.t('helpers.submit.accounting.update'))
}.to have_validation_error(I18n.t('accounting.two_digits_after_decimal_point')).on(
:share_ksk,
:central_office,
:limit_value,
:fix_disagio)
regarding https://github.com/rspec/rspec-rails/issues/1033
but I get an RSpec error:
undefined method `on' for #<RSpec::Matchers::BuiltIn::Has:0x00000005913368>
Solution 1:[1]
Solution 1:
As you already know you can use rspec-collection_matchers gem.
Solution 2: You can monkey patch errors_on onto ::ActiveModel::Validations as done here
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Vishal Jain |
