aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/test_test.rb47
1 files changed, 31 insertions, 16 deletions
diff --git a/activesupport/test/test_test.rb b/activesupport/test/test_test.rb
index 63a44e9379..d8a02b5497 100644
--- a/activesupport/test/test_test.rb
+++ b/activesupport/test/test_test.rb
@@ -3,32 +3,47 @@ require File.dirname(__FILE__) + '/abstract_unit'
class AssertDifferenceTest < Test::Unit::TestCase
def setup
- @object = Class.new { attr_accessor :num }.new
+ @object = Class.new do
+ attr_accessor :num
+ def increment
+ self.num += 1
+ end
+
+ def decrement
+ self.num -= 1
+ end
+ end.new
+ @object.num = 0
end
def test_assert_no_difference
- @object.num = 0
-
- assert_no_difference @object, :num do
+ assert_no_difference '@object.num' do
# ...
end
-
end
+
def test_assert_difference
- @object.num = 0
-
-
- assert_difference @object, :num, +1 do
- @object.num = 1
+ assert_difference '@object.num', +1 do
+ @object.increment
end
-
end
- def test_methods_available
-
- assert self.respond_to?(:assert_difference)
- assert self.respond_to?(:assert_no_difference)
-
+ def test_assert_difference_with_implicit_difference
+ assert_difference '@object.num' do
+ @object.increment
+ end
end
+ def test_arbitrary_expression
+ assert_difference '@object.num + 1', +2 do
+ @object.increment
+ @object.increment
+ end
+ end
+
+ def test_negative_differences
+ assert_difference '@object.num', -1 do
+ @object.decrement
+ end
+ end
end