rails/rails — pull request #13731 by BartlomiejSkwira (2014-01-16 15:07:46+00:00)
Title: 7538 undefined method reverse bug

This is a diff pull request to bug https://github.com/rails/rails/issues/7538#issuecomment-31633609

Problem:
I want to test the `to_sql` method with binds nil or [], but I can't seem to mock the arel parameter correctly, here is an excerpt:
```
def test_to_sql_should_not_raise_exception_for_nil_binds_param
class_mock = MiniTest::Mock.new
class_mock.expect(:name, MiniTest::Mock, [])
statement_mock = MiniTest::Mock.new
statement_mock.expect(:to_matcher, nil, [])
statement_mock.expect(:class, class_mock, [])
arel_mock = MiniTest::Mock.new
arel_mock.expect(:ast, statement_mock, [])
@connection.to_sql(arel_mock)
end
```
Launching the test produces:
```
1) Error:
DatabaseStatementsTest#test_to_sql_should_not_raise_exception_for_nil_binds_param:
MockExpectationError: No more expects available for :class: []
/home/vagrant/.rvm/gems/ruby-2.0.0-p353/gems/arel-5.0.0/lib/arel/visitors/visitor.rb:24:in `rescue in visit'
```