diff options
author | Yehuda Katz <wycats@gmail.com> | 2009-08-29 01:49:18 -0500 |
---|---|---|
committer | Yehuda Katz <wycats@gmail.com> | 2009-08-29 01:49:18 -0500 |
commit | dbf20c2dbb5d1f2640517c468aa7c269d93414b9 (patch) | |
tree | 79fdbbd46f2a2c7ccf1601fbacf781cae387a739 /activemodel/test | |
parent | 353157ccd9960c806a6f17537dcbeddd2d1d17c8 (diff) | |
download | rails-dbf20c2dbb5d1f2640517c468aa7c269d93414b9.tar.gz rails-dbf20c2dbb5d1f2640517c468aa7c269d93414b9.tar.bz2 rails-dbf20c2dbb5d1f2640517c468aa7c269d93414b9.zip |
Initial AMo Lint implementation
Diffstat (limited to 'activemodel/test')
-rw-r--r-- | activemodel/test/cases/lint_test.rb | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/activemodel/test/cases/lint_test.rb b/activemodel/test/cases/lint_test.rb new file mode 100644 index 0000000000..165c353045 --- /dev/null +++ b/activemodel/test/cases/lint_test.rb @@ -0,0 +1,50 @@ +require "cases/helper" + +class TestLint < Test::Unit::TestCase + class CompliantObject + def to_model + self + end + + def valid?() true end + def new_record?() true end + def destroyed?() true end + + def errors + obj = Object.new + def obj.[](key) [] end + def obj.full_messages() [] end + obj + end + end + + def assert_output(object, failures, errors, *test_names) + ActiveModel::Lint.test(object, 3, output = StringIO.new) + regex = %r{#{failures} failures, #{errors} errors} + assert_match regex, output.string + + test_names.each do |test_name| + assert_match test_name, output.string + end + end + + def test_valid + assert_output(CompliantObject.new, 0, 0, /test_valid/) + end + + def test_new_record + assert_output(CompliantObject.new, 0, 0, /test_new_record?/) + end + + def test_destroyed + assert_output(CompliantObject.new, 0, 0, /test_destroyed/) + end + + def test_errors_aref + assert_output(CompliantObject.new, 0, 0, /test_errors_aref/) + end + + def test_errors_full_messages + assert_output(CompliantObject.new, 0, 0, /test_errors_aref/) + end +end
\ No newline at end of file |