diff options
author | Franky W <frankywahl@users.noreply.github.com> | 2014-11-07 18:27:18 -0800 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-02-20 21:23:36 -0200 |
commit | b1d263505770f6dafe6c77fa33cf595f192441ba (patch) | |
tree | c3e8001025bfae01afa9787c45e443cf59473b54 /activerecord/test/cases/scoping/named_scoping_test.rb | |
parent | 787bbb8fbab0fe2ef2822d403078b72106365627 (diff) | |
download | rails-b1d263505770f6dafe6c77fa33cf595f192441ba.tar.gz rails-b1d263505770f6dafe6c77fa33cf595f192441ba.tar.bz2 rails-b1d263505770f6dafe6c77fa33cf595f192441ba.zip |
Error message testing fix
The testing of error messages have been implemented wrongly a few times.
This is an attempt to fix it.
For example, some of these test should have failed with the new code.
The reason they are not failling with the new string is the fact they
were not being tested beforehand.
Diffstat (limited to 'activerecord/test/cases/scoping/named_scoping_test.rb')
-rw-r--r-- | activerecord/test/cases/scoping/named_scoping_test.rb | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/activerecord/test/cases/scoping/named_scoping_test.rb b/activerecord/test/cases/scoping/named_scoping_test.rb index 8cd94ebcc2..e4cc533517 100644 --- a/activerecord/test/cases/scoping/named_scoping_test.rb +++ b/activerecord/test/cases/scoping/named_scoping_test.rb @@ -317,13 +317,15 @@ class NamedScopingTest < ActiveRecord::TestCase ] conflicts.each do |name| - assert_raises(ArgumentError, "scope `#{name}` should not be allowed") do + e = assert_raises(ArgumentError, "scope `#{name}` should not be allowed") do klass.class_eval { scope name, ->{ where(approved: true) } } end + assert_match(/You tried to define a scope named \"#{name}\" on the model/, e.message) - assert_raises(ArgumentError, "scope `#{name}` should not be allowed") do + e = assert_raises(ArgumentError, "scope `#{name}` should not be allowed") do subklass.class_eval { scope name, ->{ where(approved: true) } } end + assert_match(/You tried to define a scope named \"#{name}\" on the model/, e.message) end non_conflicts.each do |name| |