Skip to content

Commit

Permalink
Refactor this test to check for a closed connection.
Browse files Browse the repository at this point in the history
  • Loading branch information
loe committed Jun 16, 2011
1 parent e2b16dc commit 27fe0da
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions spec/mysql2/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -177,18 +177,17 @@ def connect *args
}.should raise_error(Mysql2::Error)
end

it "should handle Timeouts without leaving the connection hanging if reconnect is true" do
client = Mysql2::Client.new(:reconnect => true)
it "should close the connection when an exception is raised" do
begin
Timeout.timeout(1) do
client.query("SELECT sleep(2)")
@client.query("SELECT sleep(2)")
end
rescue Timeout::Error
end

lambda {
client.query("SELECT 1")
}.should_not raise_error(Mysql2::Error)
@client.query("SELECT 1")
}.should raise_error(Mysql2::Error, 'closed MySQL connection')
end

it "threaded queries should be supported" do
Expand Down

0 comments on commit 27fe0da

Please sign in to comment.