Upgraded Rails and RSpec
[monkeycharger.git] / vendor / rails / activesupport / test / test_test.rb
blobeecbd31f98389ec5c664836181c5de4cbb9a49cf
1 require File.dirname(__FILE__) + '/abstract_unit'
2 require 'active_support/test_case'
3 class AssertDifferenceTest < Test::Unit::TestCase
4   def setup
5     @object = Class.new do
6       attr_accessor :num 
7       def increment
8         self.num += 1
9       end
11       def decrement
12         self.num -= 1
13       end
14     end.new    
15     @object.num = 0
16   end
18   if lambda { }.respond_to?(:binding)
19     def test_assert_no_difference
20       assert_no_difference '@object.num' do
21         # ...
22       end
23     end
25     def test_assert_difference
26       assert_difference '@object.num', +1 do
27         @object.increment
28       end
29     end
31     def test_assert_difference_with_implicit_difference
32       assert_difference '@object.num' do
33         @object.increment
34       end
35     end
37     def test_arbitrary_expression
38       assert_difference '@object.num + 1', +2 do
39         @object.increment
40         @object.increment
41       end
42     end
44     def test_negative_differences
45       assert_difference '@object.num', -1 do
46         @object.decrement
47       end
48     end
50     def test_expression_is_evaluated_in_the_appropriate_scope
51       local_scope = 'foo'
52       silence_warnings do
53         assert_difference('local_scope; @object.num') { @object.increment }
54       end
55     end
57     def test_array_of_expressions
58       assert_difference [ '@object.num', '@object.num + 1' ], +1 do
59         @object.increment
60       end
61     end
62   else
63     def default_test; end
64   end
65 end
67 # These should always pass
68 class NotTestingThingsTest < Test::Unit::TestCase
69   include ActiveSupport::Testing::Default
70 end
72 class AlsoDoingNothingTest < ActiveSupport::TestCase
73 end