aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorPavel Pravosud <pavel@pravosud.com>2015-09-05 17:48:15 -0700
committerPavel Pravosud <pavel@pravosud.com>2015-09-07 00:04:31 -0700
commit4ff626cac901b41f86646dab1939d2a95b2d26bd (patch)
treed9c19561cf94aa088a41ec45381ada3adf6f30c2 /activerecord/test
parentf443ae670de9ce9bcb8c00adde08405d2cfd70db (diff)
downloadrails-4ff626cac901b41f86646dab1939d2a95b2d26bd.tar.gz
rails-4ff626cac901b41f86646dab1939d2a95b2d26bd.tar.bz2
rails-4ff626cac901b41f86646dab1939d2a95b2d26bd.zip
Make ActiveRecordException descendants args optional
This change allows to instantiate all ActiveRecordError descendant execption classes without arguments, which might be useful in testing and is far less surprising than mandatory arguments.
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/errors_test.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/activerecord/test/cases/errors_test.rb b/activerecord/test/cases/errors_test.rb
new file mode 100644
index 0000000000..0711a372f2
--- /dev/null
+++ b/activerecord/test/cases/errors_test.rb
@@ -0,0 +1,16 @@
+require_relative "../cases/helper"
+
+class ErrorsTest < ActiveRecord::TestCase
+ def test_can_be_instantiated_with_no_args
+ base = ActiveRecord::ActiveRecordError
+ error_klasses = ObjectSpace.each_object(Class).select { |klass| klass < base }
+
+ error_klasses.each do |error_klass|
+ begin
+ error_klass.new.inspect
+ rescue ArgumentError
+ raise "Instance of #{error_klass} can't be initialized with no arguments"
+ end
+ end
+ end
+end