Sha256: 1ee331c0fa14721266fbe033a74f6f39b57643f8e9594f6bd0efd5fc89d4b7cd
Contents?: true
Size: 1.34 KB
Versions: 1
Compression:
Stored size: 1.34 KB
Contents
require 'spec_helper' describe ConnectionManager::MethodRecorder do before(:each) do class Fruit < ActiveRecord::Base #include ConnectionManager::MethodRecorder def self.shards ConnectionManager::MethodRecorder.new([self]) end end end context 'shards'do it "it should record methods" do a = Fruit.shards.select('fruits.*').where(:id => 1).order('created_at').first a.recordings.should eql({:select => ['fruits.*'], :where => [:id =>1], :order => ['created_at'], :first => []}) end context '#execute' do it "should return an array of results" do a = Fruit.shards.first.execute a.should be_a_kind_of(Array) end it "should execute the active record methods on the the provided class" do fruit = Factory.create(:fruit) class_to_call = Fruit a = class_to_call.shards.where(:id => fruit.id).first.execute a[0].should be_a_kind_of(class_to_call) end it "should not matter how the where statement is formated" do fruit = Factory.create(:fruit) a = Fruit.shards.where(:id => fruit.id).first.execute b = Fruit.shards.where(['id = ?', fruit.id]).first.execute c = Fruit.shards.where('id = ?', fruit.id).first.execute (a == b && b == c).should be_true end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
connection_manager-0.2.0 | spec/lib/method_recorder_spec.rb |