Sha256: 3fd9bc3faf2711054e7e50fea762185e4b0ca0e65b8ea1f25cf63396a181cbea
Contents?: true
Size: 1.22 KB
Versions: 23
Compression:
Stored size: 1.22 KB
Contents
require 'spec_helper' describe ActiveRecord::Turntable::Algorithm::RangeAlgorithm do before(:all) do reload_turntable!(File.join(File.dirname(__FILE__), "../../../config/turntable.yml")) end context "When initialized" do before do @alg = ActiveRecord::Turntable::Algorithm::RangeAlgorithm.new(ActiveRecord::Base.turntable_config[:clusters][:user_cluster]) end context "#calculate with 1" do subject { @alg.calculate(1) } it { is_expected.to eq(ActiveRecord::Base.turntable_config[:clusters][:user_cluster][:shards][0][:connection]) } end context "#calculate with 19999" do subject { @alg.calculate(19999) } it { is_expected.to eq(ActiveRecord::Base.turntable_config[:clusters][:user_cluster][:shards][0][:connection]) } end context "#calculate with 20000" do subject { @alg.calculate(20000) } it { is_expected.to eq(ActiveRecord::Base.turntable_config[:clusters][:user_cluster][:shards][1][:connection]) } end context "#calculate with 10000000" do it "raises ActiveRecord::Turntable::CannotSpecifyShardError" do expect { @alg.calculate(10000000) }.to raise_error(ActiveRecord::Turntable::CannotSpecifyShardError) end end end end
Version data entries
23 entries across 23 versions & 1 rubygems