Skip to content
This repository
Browse code

Merge branch 'master' into stmt

  • Loading branch information...
commit 96a2d52f78b2e39f0858c21aafac97c1af2ab22a 2 parents be73d6d + f0580c3
Brian Lopez authored
1  .rbenv-version
... ... @@ -0,0 +1 @@
  1 +1.9.3
10 spec/em/em_spec.rb
@@ -8,14 +8,14 @@
8 8 it "should support async queries" do
9 9 results = []
10 10 EM.run do
11   - client1 = Mysql2::EM::Client.new
  11 + client1 = Mysql2::EM::Client.new DatabaseCredentials['root']
12 12 defer1 = client1.query "SELECT sleep(0.1) as first_query"
13 13 defer1.callback do |result|
14 14 results << result.first
15 15 EM.stop_event_loop
16 16 end
17 17
18   - client2 = Mysql2::EM::Client.new
  18 + client2 = Mysql2::EM::Client.new DatabaseCredentials['root']
19 19 defer2 = client2.query "SELECT sleep(0.025) second_query"
20 20 defer2.callback do |result|
21 21 results << result.first
@@ -29,7 +29,7 @@
29 29 it "should support queries in callbacks" do
30 30 results = []
31 31 EM.run do
32   - client = Mysql2::EM::Client.new
  32 + client = Mysql2::EM::Client.new DatabaseCredentials['root']
33 33 defer1 = client.query "SELECT sleep(0.025) as first_query"
34 34 defer1.callback do |result|
35 35 results << result.first
@@ -48,7 +48,7 @@
48 48 it "should not swallow exceptions raised in callbacks" do
49 49 lambda {
50 50 EM.run do
51   - client = Mysql2::EM::Client.new
  51 + client = Mysql2::EM::Client.new DatabaseCredentials['root']
52 52 defer = client.query "SELECT sleep(0.1) as first_query"
53 53 defer.callback do |result|
54 54 raise 'some error'
@@ -63,7 +63,7 @@
63 63 end
64 64
65 65 context 'when an exception is raised by the client' do
66   - let(:client) { Mysql2::EM::Client.new }
  66 + let(:client) { Mysql2::EM::Client.new DatabaseCredentials['root'] }
67 67 let(:error) { StandardError.new('some error') }
68 68 before { client.stub(:async_result).and_raise(error) }
69 69
20 spec/mysql2/client_spec.rb
@@ -3,7 +3,7 @@
3 3
4 4 describe Mysql2::Client do
5 5 before(:each) do
6   - @client = Mysql2::Client.new
  6 + @client = Mysql2::Client.new DatabaseCredentials['root']
7 7 end
8 8
9 9 if defined? Encoding
@@ -161,7 +161,7 @@ def connect *args
161 161 end
162 162
163 163 it "should timeout if we wait longer than :read_timeout" do
164   - client = Mysql2::Client.new(:read_timeout => 1)
  164 + client = Mysql2::Client.new(DatabaseCredentials['root'].merge(:read_timeout => 1))
165 165 lambda {
166 166 client.query("SELECT sleep(2)")
167 167 }.should raise_error(Mysql2::Error)
@@ -220,7 +220,7 @@ def connect *args
220 220 end
221 221
222 222 it "should handle Timeouts without leaving the connection hanging if reconnect is true" do
223   - client = Mysql2::Client.new(:reconnect => true)
  223 + client = Mysql2::Client.new(DatabaseCredentials['root'].merge(:reconnect => true))
224 224 begin
225 225 Timeout.timeout(1) do
226 226 client.query("SELECT sleep(2)")
@@ -236,11 +236,7 @@ def connect *args
236 236 it "threaded queries should be supported" do
237 237 threads, results = [], {}
238 238 connect = lambda{
239   - Mysql2::Client.new(
240   - :host => DatabaseCredentials['root']['host'],
241   - :username => DatabaseCredentials["root"]["username"],
242   - :password => DatabaseCredentials["root"]["password"]
243   - )
  239 + Mysql2::Client.new(DatabaseCredentials['root'])
244 240 }
245 241 Timeout.timeout(0.7) do
246 242 5.times {
@@ -285,7 +281,7 @@ def connect *args
285 281
286 282 context "Multiple results sets" do
287 283 before(:each) do
288   - @multi_client = Mysql2::Client.new( :flags => Mysql2::Client::MULTI_STATEMENTS)
  284 + @multi_client = Mysql2::Client.new(DatabaseCredentials['root'].merge(:flags => Mysql2::Client::MULTI_STATEMENTS))
289 285 end
290 286
291 287 it "returns multiple result sets" do
@@ -412,7 +408,7 @@ def connect *args
412 408 Encoding.default_internal = nil
413 409 @client.info[:version].encoding.should eql(Encoding.find('utf-8'))
414 410
415   - client2 = Mysql2::Client.new :encoding => 'ascii'
  411 + client2 = Mysql2::Client.new(DatabaseCredentials['root'].merge(:encoding => 'ascii'))
416 412 client2.info[:version].encoding.should eql(Encoding.find('us-ascii'))
417 413 end
418 414
@@ -451,7 +447,7 @@ def connect *args
451 447 Encoding.default_internal = nil
452 448 @client.server_info[:version].encoding.should eql(Encoding.find('utf-8'))
453 449
454   - client2 = Mysql2::Client.new :encoding => 'ascii'
  450 + client2 = Mysql2::Client.new(DatabaseCredentials['root'].merge(:encoding => 'ascii'))
455 451 client2.server_info[:version].encoding.should eql(Encoding.find('us-ascii'))
456 452 end
457 453
@@ -470,7 +466,7 @@ def connect *args
470 466 }.should raise_error(Mysql2::Error)
471 467
472 468 lambda {
473   - good_client = Mysql2::Client.new
  469 + good_client = Mysql2::Client.new DatabaseCredentials['root']
474 470 }.should_not raise_error(Mysql2::Error)
475 471 end
476 472
4 spec/mysql2/error_spec.rb
@@ -3,14 +3,14 @@
3 3
4 4 describe Mysql2::Error do
5 5 before(:each) do
6   - @client = Mysql2::Client.new :encoding => "utf8"
  6 + @client = Mysql2::Client.new(DatabaseCredentials['root'].merge(:encoding => "utf8"))
7 7 begin
8 8 @client.query("HAHAHA")
9 9 rescue Mysql2::Error => e
10 10 @error = e
11 11 end
12 12
13   - @client2 = Mysql2::Client.new :encoding => "big5"
  13 + @client2 = Mysql2::Client.new(DatabaseCredentials['root'].merge(:encoding => "big5"))
14 14 begin
15 15 @client2.query("HAHAHA")
16 16 rescue Mysql2::Error => e
6 spec/mysql2/result_spec.rb
@@ -307,7 +307,7 @@
307 307 result = @client.query("SELECT * FROM mysql2_test ORDER BY id DESC LIMIT 1").first
308 308 result['enum_test'].encoding.should eql(Encoding.find('utf-8'))
309 309
310   - client2 = Mysql2::Client.new :encoding => 'ascii'
  310 + client2 = Mysql2::Client.new(DatabaseCredentials['root'].merge(:encoding => 'ascii'))
311 311 client2.query "USE test"
312 312 result = client2.query("SELECT * FROM mysql2_test ORDER BY id DESC LIMIT 1").first
313 313 result['enum_test'].encoding.should eql(Encoding.find('us-ascii'))
@@ -336,7 +336,7 @@
336 336 result = @client.query("SELECT * FROM mysql2_test ORDER BY id DESC LIMIT 1").first
337 337 result['set_test'].encoding.should eql(Encoding.find('utf-8'))
338 338
339   - client2 = Mysql2::Client.new :encoding => 'ascii'
  339 + client2 = Mysql2::Client.new(DatabaseCredentials['root'].merge(:encoding => 'ascii'))
340 340 client2.query "USE test"
341 341 result = client2.query("SELECT * FROM mysql2_test ORDER BY id DESC LIMIT 1").first
342 342 result['set_test'].encoding.should eql(Encoding.find('us-ascii'))
@@ -418,7 +418,7 @@
418 418 result = @client.query("SELECT * FROM mysql2_test ORDER BY id DESC LIMIT 1").first
419 419 result[field].encoding.should eql(Encoding.find('utf-8'))
420 420
421   - client2 = Mysql2::Client.new :encoding => 'ascii'
  421 + client2 = Mysql2::Client.new(DatabaseCredentials['root'].merge(:encoding => 'ascii'))
422 422 client2.query "USE test"
423 423 result = client2.query("SELECT * FROM mysql2_test ORDER BY id DESC LIMIT 1").first
424 424 result[field].encoding.should eql(Encoding.find('us-ascii'))
8 tasks/rspec.rake
@@ -17,8 +17,10 @@ end
17 17
18 18 file 'spec/configuration.yml' => 'spec/configuration.yml.example' do |task|
19 19 CLEAN.exclude task.name
20   - cp task.prerequisites.first, task.name
21   - sh "sed -i 's/LOCALUSERNAME/#{ENV['USER']}/' #{task.name}"
  20 + src_path = File.expand_path("../../#{task.prerequisites.first}", __FILE__)
  21 + dst_path = File.expand_path("../../#{task.name}", __FILE__)
  22 + cp src_path, dst_path
  23 + sh "sed -i 's/LOCALUSERNAME/#{ENV['USER']}/' #{dst_path}"
22 24 end
23 25
24   -task :spec => :'spec/configuration.yml'
  26 +Rake::Task[:spec].prerequisites << :'spec/configuration.yml'

0 comments on commit 96a2d52

Please sign in to comment.
Something went wrong with that request. Please try again.