Upgrading from Rails 4 to Rails 5.1. Have this running rspec test:
Failure/Error: let(:exception) {
ActiveRecord::RecordNotUnique.new("oops", Mysql2::Error) }
ArgumentError:
wrong number of arguments (given 2, expected 0..1)
It seems the syntax of ActiveRecord exceptions has changed in Rails 5? I don't think this was mentioned in any 'what is new in Rails 5' articles I read. Google found naught, nor a site with source code.
Using
bundle open rails
(assuming using bundler) shows source code locally. Moving up a directory, you will be in somewhere like~/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems
(if using rbenv).Searching this directory will find the definitions which will explain. Search example using Vim and Silver Searcher:
and from here we can see that in Rails 5.1 the method now no longer takes two arguments:
This technique of grepping the source can fix many problems like this.