Sha256: 5203324f42a00d9f58fb5a1e6f54ba656e9186f6af2f16c0d69d290f8ca34424
Contents?: true
Size: 1.12 KB
Versions: 1
Compression:
Stored size: 1.12 KB
Contents
require "spec/helper/all" require "em-synchrony/activerecord" # create database widgets; # use widgets; # create table widgets (idx INT); class Widget < ActiveRecord::Base; end; describe "Fiberized ActiveRecord driver for mysql2" do DELAY = 0.25 QUERY = "SELECT sleep(#{DELAY})" it "should establish AR connection" do EventMachine.synchrony do ActiveRecord::Base.establish_connection( :adapter => 'em_mysql2', :database => 'widgets', :username => 'root' ) result = Widget.find_by_sql(QUERY) result.size.should == 1 EventMachine.stop end end it "should fire sequential, synchronous requests within single fiber" do EventMachine.synchrony do ActiveRecord::Base.establish_connection( :adapter => 'em_mysql2', :database => 'widgets', :username => 'root' ) start = now res = [] res.push Widget.find_by_sql(QUERY) res.push Widget.find_by_sql(QUERY) (now - start.to_f).should be_within(DELAY * res.size * 0.15).of(DELAY * res.size) res.size.should == 2 EventMachine.stop end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
em-synchrony-1.0.0 | spec/activerecord_spec.rb |