Sha256: 7716c6fe43eeb2d16cd0eee4c4000ee2db6dbd17aa1ddde07e573177fb105aa6
Contents?: true
Size: 1.22 KB
Versions: 9
Compression:
Stored size: 1.22 KB
Contents
require 'spec_helper' describe ActiveRecord::Turntable::Algorithm::ModuloAlgorithm 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::ModuloAlgorithm.new(ActiveRecord::Base.turntable_config[:clusters][:mod_cluster]) end context "#calculate with 1" do subject { @alg.calculate(1) } it { is_expected.to eq(ActiveRecord::Base.turntable_config[:clusters][:user_cluster][:shards][1][:connection]) } end context "#calculate with 3" do subject { @alg.calculate(3) } it { is_expected.to eq(ActiveRecord::Base.turntable_config[:clusters][:user_cluster][:shards][3][:connection]) } end context "#calculate with 5" do subject { @alg.calculate(5) } it { is_expected.to eq(ActiveRecord::Base.turntable_config[:clusters][:user_cluster][:shards][0][:connection]) } end context "#calculate with a value that is not a number" do it "raises ActiveRecord::Turntable::CannotSpecifyShardError" do expect { @alg.calculate('a') }.to raise_error(ActiveRecord::Turntable::CannotSpecifyShardError) end end end end
Version data entries
9 entries across 9 versions & 1 rubygems