Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' into stmt

  • Loading branch information...
commit 96a2d52f78b2e39f0858c21aafac97c1af2ab22a 2 parents be73d6d + f0580c3
@brianmario authored
View
1  .rbenv-version
@@ -0,0 +1 @@
+1.9.3
View
10 spec/em/em_spec.rb
@@ -8,14 +8,14 @@
it "should support async queries" do
results = []
EM.run do
- client1 = Mysql2::EM::Client.new
+ client1 = Mysql2::EM::Client.new DatabaseCredentials['root']
defer1 = client1.query "SELECT sleep(0.1) as first_query"
defer1.callback do |result|
results << result.first
EM.stop_event_loop
end
- client2 = Mysql2::EM::Client.new
+ client2 = Mysql2::EM::Client.new DatabaseCredentials['root']
defer2 = client2.query "SELECT sleep(0.025) second_query"
defer2.callback do |result|
results << result.first
@@ -29,7 +29,7 @@
it "should support queries in callbacks" do
results = []
EM.run do
- client = Mysql2::EM::Client.new
+ client = Mysql2::EM::Client.new DatabaseCredentials['root']
defer1 = client.query "SELECT sleep(0.025) as first_query"
defer1.callback do |result|
results << result.first
@@ -48,7 +48,7 @@
it "should not swallow exceptions raised in callbacks" do
lambda {
EM.run do
- client = Mysql2::EM::Client.new
+ client = Mysql2::EM::Client.new DatabaseCredentials['root']
defer = client.query "SELECT sleep(0.1) as first_query"
defer.callback do |result|
raise 'some error'
@@ -63,7 +63,7 @@
end
context 'when an exception is raised by the client' do
- let(:client) { Mysql2::EM::Client.new }
+ let(:client) { Mysql2::EM::Client.new DatabaseCredentials['root'] }
let(:error) { StandardError.new('some error') }
before { client.stub(:async_result).and_raise(error) }
View
20 spec/mysql2/client_spec.rb
@@ -3,7 +3,7 @@
describe Mysql2::Client do
before(:each) do
- @client = Mysql2::Client.new
+ @client = Mysql2::Client.new DatabaseCredentials['root']
end
if defined? Encoding
@@ -161,7 +161,7 @@ def connect *args
end
it "should timeout if we wait longer than :read_timeout" do
- client = Mysql2::Client.new(:read_timeout => 1)
+ client = Mysql2::Client.new(DatabaseCredentials['root'].merge(:read_timeout => 1))
lambda {
client.query("SELECT sleep(2)")
}.should raise_error(Mysql2::Error)
@@ -220,7 +220,7 @@ def connect *args
end
it "should handle Timeouts without leaving the connection hanging if reconnect is true" do
- client = Mysql2::Client.new(:reconnect => true)
+ client = Mysql2::Client.new(DatabaseCredentials['root'].merge(:reconnect => true))
begin
Timeout.timeout(1) do
client.query("SELECT sleep(2)")
@@ -236,11 +236,7 @@ def connect *args
it "threaded queries should be supported" do
threads, results = [], {}
connect = lambda{
- Mysql2::Client.new(
- :host => DatabaseCredentials['root']['host'],
- :username => DatabaseCredentials["root"]["username"],
- :password => DatabaseCredentials["root"]["password"]
- )
+ Mysql2::Client.new(DatabaseCredentials['root'])
}
Timeout.timeout(0.7) do
5.times {
@@ -285,7 +281,7 @@ def connect *args
context "Multiple results sets" do
before(:each) do
- @multi_client = Mysql2::Client.new( :flags => Mysql2::Client::MULTI_STATEMENTS)
+ @multi_client = Mysql2::Client.new(DatabaseCredentials['root'].merge(:flags => Mysql2::Client::MULTI_STATEMENTS))
end
it "returns multiple result sets" do
@@ -412,7 +408,7 @@ def connect *args
Encoding.default_internal = nil
@client.info[:version].encoding.should eql(Encoding.find('utf-8'))
- client2 = Mysql2::Client.new :encoding => 'ascii'
+ client2 = Mysql2::Client.new(DatabaseCredentials['root'].merge(:encoding => 'ascii'))
client2.info[:version].encoding.should eql(Encoding.find('us-ascii'))
end
@@ -451,7 +447,7 @@ def connect *args
Encoding.default_internal = nil
@client.server_info[:version].encoding.should eql(Encoding.find('utf-8'))
- client2 = Mysql2::Client.new :encoding => 'ascii'
+ client2 = Mysql2::Client.new(DatabaseCredentials['root'].merge(:encoding => 'ascii'))
client2.server_info[:version].encoding.should eql(Encoding.find('us-ascii'))
end
@@ -470,7 +466,7 @@ def connect *args
}.should raise_error(Mysql2::Error)
lambda {
- good_client = Mysql2::Client.new
+ good_client = Mysql2::Client.new DatabaseCredentials['root']
}.should_not raise_error(Mysql2::Error)
end
View
4 spec/mysql2/error_spec.rb
@@ -3,14 +3,14 @@
describe Mysql2::Error do
before(:each) do
- @client = Mysql2::Client.new :encoding => "utf8"
+ @client = Mysql2::Client.new(DatabaseCredentials['root'].merge(:encoding => "utf8"))
begin
@client.query("HAHAHA")
rescue Mysql2::Error => e
@error = e
end
- @client2 = Mysql2::Client.new :encoding => "big5"
+ @client2 = Mysql2::Client.new(DatabaseCredentials['root'].merge(:encoding => "big5"))
begin
@client2.query("HAHAHA")
rescue Mysql2::Error => e
View
6 spec/mysql2/result_spec.rb
@@ -307,7 +307,7 @@
result = @client.query("SELECT * FROM mysql2_test ORDER BY id DESC LIMIT 1").first
result['enum_test'].encoding.should eql(Encoding.find('utf-8'))
- client2 = Mysql2::Client.new :encoding => 'ascii'
+ client2 = Mysql2::Client.new(DatabaseCredentials['root'].merge(:encoding => 'ascii'))
client2.query "USE test"
result = client2.query("SELECT * FROM mysql2_test ORDER BY id DESC LIMIT 1").first
result['enum_test'].encoding.should eql(Encoding.find('us-ascii'))
@@ -336,7 +336,7 @@
result = @client.query("SELECT * FROM mysql2_test ORDER BY id DESC LIMIT 1").first
result['set_test'].encoding.should eql(Encoding.find('utf-8'))
- client2 = Mysql2::Client.new :encoding => 'ascii'
+ client2 = Mysql2::Client.new(DatabaseCredentials['root'].merge(:encoding => 'ascii'))
client2.query "USE test"
result = client2.query("SELECT * FROM mysql2_test ORDER BY id DESC LIMIT 1").first
result['set_test'].encoding.should eql(Encoding.find('us-ascii'))
@@ -418,7 +418,7 @@
result = @client.query("SELECT * FROM mysql2_test ORDER BY id DESC LIMIT 1").first
result[field].encoding.should eql(Encoding.find('utf-8'))
- client2 = Mysql2::Client.new :encoding => 'ascii'
+ client2 = Mysql2::Client.new(DatabaseCredentials['root'].merge(:encoding => 'ascii'))
client2.query "USE test"
result = client2.query("SELECT * FROM mysql2_test ORDER BY id DESC LIMIT 1").first
result[field].encoding.should eql(Encoding.find('us-ascii'))
View
8 tasks/rspec.rake
@@ -17,8 +17,10 @@ end
file 'spec/configuration.yml' => 'spec/configuration.yml.example' do |task|
CLEAN.exclude task.name
- cp task.prerequisites.first, task.name
- sh "sed -i 's/LOCALUSERNAME/#{ENV['USER']}/' #{task.name}"
+ src_path = File.expand_path("../../#{task.prerequisites.first}", __FILE__)
+ dst_path = File.expand_path("../../#{task.name}", __FILE__)
+ cp src_path, dst_path
+ sh "sed -i 's/LOCALUSERNAME/#{ENV['USER']}/' #{dst_path}"
end
-task :spec => :'spec/configuration.yml'
+Rake::Task[:spec].prerequisites << :'spec/configuration.yml'
Please sign in to comment.
Something went wrong with that request. Please try again.