diff options
author | Joshua Peek <josh@joshpeek.com> | 2009-10-07 09:24:51 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2009-10-07 09:24:51 -0500 |
commit | ff56f3d5e1c69b923625f20a80f25c2eee3bbb35 (patch) | |
tree | c9c05a6dfa6c6a85a397fa167a16d1371dfc1014 /activemodel/test | |
parent | 4df96338ede62da8ae8c188de5454b4b6b186ff8 (diff) | |
download | rails-ff56f3d5e1c69b923625f20a80f25c2eee3bbb35.tar.gz rails-ff56f3d5e1c69b923625f20a80f25c2eee3bbb35.tar.bz2 rails-ff56f3d5e1c69b923625f20a80f25c2eee3bbb35.zip |
Rewrite ActiveModel::Lint as a simple TU mixin
Diffstat (limited to 'activemodel/test')
-rw-r--r-- | activemodel/test/cases/lint_test.rb | 40 |
1 files changed, 8 insertions, 32 deletions
diff --git a/activemodel/test/cases/lint_test.rb b/activemodel/test/cases/lint_test.rb index ed576a91e2..da7d2112dc 100644 --- a/activemodel/test/cases/lint_test.rb +++ b/activemodel/test/cases/lint_test.rb @@ -1,15 +1,17 @@ require "cases/helper" -class TestLint < ActiveModel::TestCase - class CompliantObject +class LintTest < ActiveModel::TestCase + include ActiveModel::Lint::Tests + + class CompliantModel 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 @@ -17,34 +19,8 @@ class TestLint < ActiveModel::TestCase 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/) + def setup + @model = CompliantModel.new end end |