Permalink
Browse files

Stub with Minitest instead of Mocha

Step 4 in #33162
  • Loading branch information...
utilum committed Jul 10, 2018
1 parent 05bef14 commit 837d6031783c2fcf7920320d386f2ea7211f8cb1
@@ -128,10 +128,10 @@ def test_insert_fixtures_set_raises_an_error_when_max_allowed_packet_is_smaller_
]
}
conn.stubs(:max_allowed_packet).returns(packet_size - mysql_margin)
error = assert_raises(ActiveRecord::ActiveRecordError) { conn.insert_fixtures_set(fixtures) }
assert_match(/Fixtures set is too large #{packet_size}\./, error.message)
conn.stub(:max_allowed_packet, packet_size - mysql_margin) do
error = assert_raises(ActiveRecord::ActiveRecordError) { conn.insert_fixtures_set(fixtures) }
assert_match(/Fixtures set is too large #{packet_size}\./, error.message)
end
end
def test_insert_fixture_set_when_max_allowed_packet_is_bigger_than_fixtures_set_size
@@ -143,10 +143,10 @@ def test_insert_fixture_set_when_max_allowed_packet_is_bigger_than_fixtures_set_
]
}
conn.stubs(:max_allowed_packet).returns(packet_size)
assert_difference "TrafficLight.count" do
conn.insert_fixtures_set(fixtures)
conn.stub(:max_allowed_packet, packet_size) do
assert_difference "TrafficLight.count" do
conn.insert_fixtures_set(fixtures)
end
end
end
@@ -164,12 +164,13 @@ def test_insert_fixtures_set_split_the_total_sql_into_two_chunks_smaller_than_ma
]
}
conn.stubs(:max_allowed_packet).returns(packet_size)
conn.stub(:max_allowed_packet, packet_size) do
conn.insert_fixtures_set(fixtures)
conn.insert_fixtures_set(fixtures)
assert_equal 2, subscriber.events.size
assert_operator subscriber.events.first.bytesize, :<, packet_size
assert_operator subscriber.events.second.bytesize, :<, packet_size
assert_equal 2, subscriber.events.size
assert_operator subscriber.events.first.bytesize, :<, packet_size
assert_operator subscriber.events.second.bytesize, :<, packet_size
end
ensure
ActiveSupport::Notifications.unsubscribe(subscription)
end
@@ -188,10 +189,10 @@ def test_insert_fixtures_set_concat_total_sql_into_a_single_packet_smaller_than_
]
}
conn.stubs(:max_allowed_packet).returns(packet_size)
assert_difference ["TrafficLight.count", "Comment.count"], +1 do
conn.insert_fixtures_set(fixtures)
conn.stub(:max_allowed_packet, packet_size) do
assert_difference ["TrafficLight.count", "Comment.count"], +1 do
conn.insert_fixtures_set(fixtures)
end
end
assert_equal 1, subscriber.events.size
ensure
@@ -297,29 +297,33 @@ def test_schema_dump_oid_type
def test_schema_dump_includes_extensions
connection = ActiveRecord::Base.connection
connection.stubs(:extensions).returns(["hstore"])
output = perform_schema_dump
assert_match "# These are extensions that must be enabled", output
assert_match %r{enable_extension "hstore"}, output
connection.stubs(:extensions).returns([])
output = perform_schema_dump
assert_no_match "# These are extensions that must be enabled", output
assert_no_match %r{enable_extension}, output
connection.stub(:extensions, ["hstore"]) do
output = perform_schema_dump
assert_match "# These are extensions that must be enabled", output
assert_match %r{enable_extension "hstore"}, output
end
connection.stub(:extensions, []) do
output = perform_schema_dump
assert_no_match "# These are extensions that must be enabled", output
assert_no_match %r{enable_extension}, output
end
end
def test_schema_dump_includes_extensions_in_alphabetic_order
connection = ActiveRecord::Base.connection
connection.stubs(:extensions).returns(["hstore", "uuid-ossp", "xml2"])
output = perform_schema_dump
enabled_extensions = output.scan(%r{enable_extension "(.+)"}).flatten
assert_equal ["hstore", "uuid-ossp", "xml2"], enabled_extensions
connection.stub(:extensions, ["hstore", "uuid-ossp", "xml2"]) do
output = perform_schema_dump
enabled_extensions = output.scan(%r{enable_extension "(.+)"}).flatten
assert_equal ["hstore", "uuid-ossp", "xml2"], enabled_extensions
end
connection.stubs(:extensions).returns(["uuid-ossp", "xml2", "hstore"])
output = perform_schema_dump
enabled_extensions = output.scan(%r{enable_extension "(.+)"}).flatten
assert_equal ["hstore", "uuid-ossp", "xml2"], enabled_extensions
connection.stub(:extensions, ["uuid-ossp", "xml2", "hstore"]) do
output = perform_schema_dump
enabled_extensions = output.scan(%r{enable_extension "(.+)"}).flatten
assert_equal ["hstore", "uuid-ossp", "xml2"], enabled_extensions
end
end
end
Oops, something went wrong.

0 comments on commit 837d603

Please sign in to comment.