Sha256: 33abefc71467fa92ba2be249bb61f5f73f18a5b142859eff31a04f099516bb10

Contents?: true

Size: 722 Bytes

Versions: 6

Compression:

Stored size: 722 Bytes

Contents

# encoding: UTF-8
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper.rb')
require 'mysql2/em'

describe Mysql2::EM::Client do
  it "should support async queries" do
    results = []
    EM.run do
      client1 = Mysql2::EM::Client.new
      defer1 = client1.query "SELECT sleep(0.05) as first_query"
      defer1.callback do |result|
        results << result.first
        EM.stop_event_loop
      end

      client2 = Mysql2::EM::Client.new
      defer2 = client2.query "SELECT sleep(0.025) second_query"
      defer2.callback do |result|
        results << result.first
      end
    end
    
    results[0].keys.should include("second_query")
    results[1].keys.should include("first_query")
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mysql2-0.1.8 spec/em/em_spec.rb
mysql2-0.1.7 spec/em/em_spec.rb
mysql2-0.1.6 spec/em/em_spec.rb
mysql2-0.1.5 spec/em/em_spec.rb
mysql2-0.1.4 spec/em/em_spec.rb
mysql2-0.1.3 spec/em/em_spec.rb