class ErrorsTest
Public Instance Methods
test_can_be_instantiated_with_no_args()
click to toggle source
# File activerecord/test/cases/errors_test.rb, line 6 def test_can_be_instantiated_with_no_args base = ActiveRecord::ActiveRecordError error_klasses = ObjectSpace.each_object(Class).select { |klass| klass < base } (error_klasses - [ActiveRecord::AmbiguousSourceReflectionForThroughAssociation]).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
test_delete()
click to toggle source
# File activemodel/test/cases/errors_test.rb, line 34 def test_delete errors = ActiveModel::Errors.new(self) errors[:foo] << "omg" errors.delete("foo") assert_empty errors[:foo] end
test_dup()
click to toggle source
# File activemodel/test/cases/errors_test.rb, line 48 def test_dup errors = ActiveModel::Errors.new(self) errors[:foo] << "bar" errors_dup = errors.dup errors_dup[:bar] << "omg" assert_not_same errors_dup.messages, errors.messages end
test_has_key?()
click to toggle source
# File activemodel/test/cases/errors_test.rb, line 56 def test_has_key? errors = ActiveModel::Errors.new(self) errors[:foo] << "omg" assert_equal true, errors.has_key?(:foo), "errors should have key :foo" assert_equal true, errors.has_key?("foo"), "errors should have key 'foo' as :foo" end
test_has_no_key()
click to toggle source
# File activemodel/test/cases/errors_test.rb, line 63 def test_has_no_key errors = ActiveModel::Errors.new(self) assert_equal false, errors.has_key?(:name), "errors should not have key :name" end
test_include?()
click to toggle source
# File activemodel/test/cases/errors_test.rb, line 41 def test_include? errors = ActiveModel::Errors.new(self) errors[:foo] << "omg" assert_includes errors, :foo, "errors should include :foo" assert_includes errors, "foo", "errors should include 'foo' as :foo" end
test_key?()
click to toggle source
# File activemodel/test/cases/errors_test.rb, line 68 def test_key? errors = ActiveModel::Errors.new(self) errors[:foo] << "omg" assert_equal true, errors.key?(:foo), "errors should have key :foo" assert_equal true, errors.key?("foo"), "errors should have key 'foo' as :foo" end
test_no_key()
click to toggle source
# File activemodel/test/cases/errors_test.rb, line 75 def test_no_key errors = ActiveModel::Errors.new(self) assert_equal false, errors.key?(:name), "errors should not have key :name" end