Skip to content

Commit

Permalink
Replace Mocha#stubs with assert_called_with
Browse files Browse the repository at this point in the history
A correct, but not obvious use of `ActiveSupport::Testing::MethodCallAssertions`, which might also have been part of rails#33337 or rails#33391.
  • Loading branch information
utilum committed Jul 22, 2018
1 parent a94d6ae commit d899375
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions activerecord/test/cases/adapters/mysql2/active_schema_test.rb
Expand Up @@ -157,14 +157,19 @@ def test_remove_timestamps
end

def test_indexes_in_create
ActiveRecord::Base.connection.stubs(:data_source_exists?).with(:temp).returns(false)
assert_called_with(
ActiveRecord::Base.connection,
:data_source_exists?,
[:temp],
returns: false
) do
expected = "CREATE TEMPORARY TABLE `temp` ( INDEX `index_temp_on_zip` (`zip`)) AS SELECT id, name, zip FROM a_really_complicated_query"
actual = ActiveRecord::Base.connection.create_table(:temp, temporary: true, as: "SELECT id, name, zip FROM a_really_complicated_query") do |t|
t.index :zip
end

expected = "CREATE TEMPORARY TABLE `temp` ( INDEX `index_temp_on_zip` (`zip`)) AS SELECT id, name, zip FROM a_really_complicated_query"
actual = ActiveRecord::Base.connection.create_table(:temp, temporary: true, as: "SELECT id, name, zip FROM a_really_complicated_query") do |t|
t.index :zip
assert_equal expected, actual
end

assert_equal expected, actual
end

private
Expand Down

0 comments on commit d899375

Please sign in to comment.