Skip to content

Commit

Permalink
Merge pull request #6704 from amatsuda/lambda_respond_to_binding
Browse files Browse the repository at this point in the history
Proc always respond_to :binding
  • Loading branch information
José Valim committed Jun 11, 2012
2 parents 04a7426 + fa2af42 commit 5304ae1
Showing 1 changed file with 39 additions and 43 deletions.
82 changes: 39 additions & 43 deletions activesupport/test/test_test.rb
Expand Up @@ -15,68 +15,64 @@ def decrement
@object.num = 0 @object.num = 0
end end


if lambda { }.respond_to?(:binding) def test_assert_no_difference
def test_assert_no_difference assert_no_difference '@object.num' do
assert_no_difference '@object.num' do # ...
# ...
end
end end
end


def test_assert_difference def test_assert_difference
assert_difference '@object.num', +1 do assert_difference '@object.num', +1 do
@object.increment @object.increment
end
end end
end


def test_assert_difference_with_implicit_difference def test_assert_difference_with_implicit_difference
assert_difference '@object.num' do assert_difference '@object.num' do
@object.increment @object.increment
end
end end
end


def test_arbitrary_expression def test_arbitrary_expression
assert_difference '@object.num + 1', +2 do assert_difference '@object.num + 1', +2 do
@object.increment @object.increment
@object.increment @object.increment
end
end end
end


def test_negative_differences def test_negative_differences
assert_difference '@object.num', -1 do assert_difference '@object.num', -1 do
@object.decrement @object.decrement
end
end end
end


def test_expression_is_evaluated_in_the_appropriate_scope def test_expression_is_evaluated_in_the_appropriate_scope
silence_warnings do silence_warnings do
local_scope = local_scope = 'foo' local_scope = local_scope = 'foo'
assert_difference('local_scope; @object.num') { @object.increment } assert_difference('local_scope; @object.num') { @object.increment }
end
end end
end


def test_array_of_expressions def test_array_of_expressions
assert_difference [ '@object.num', '@object.num + 1' ], +1 do assert_difference [ '@object.num', '@object.num + 1' ], +1 do
@object.increment @object.increment
end
end end
end


def test_array_of_expressions_identify_failure def test_array_of_expressions_identify_failure
assert_raises(MiniTest::Assertion) do assert_raises(MiniTest::Assertion) do
assert_difference ['@object.num', '1 + 1'] do assert_difference ['@object.num', '1 + 1'] do
@object.increment @object.increment
end
end end
end end
end


def test_array_of_expressions_identify_failure_when_message_provided def test_array_of_expressions_identify_failure_when_message_provided
assert_raises(MiniTest::Assertion) do assert_raises(MiniTest::Assertion) do
assert_difference ['@object.num', '1 + 1'], 1, 'something went wrong' do assert_difference ['@object.num', '1 + 1'], 1, 'something went wrong' do
@object.increment @object.increment
end
end end
end end
else
def default_test; end
end end
end end


Expand Down

0 comments on commit 5304ae1

Please sign in to comment.