Sha256: 8edbbcc403b15c19f7e62699d1fe2f16ec1ce43a2e516193b2d6495c99f5119d

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 KB

Contents

require 'spec_helper'

describe EbisuConnection::Slave do
  context "initialize(conf is String)" do
    it "hostname only" do
      s = EbisuConnection::Slave.new("host_1", "slave")
      expect(s.hostname).to eq("host_1")
      expect(s.weight).to eq(1)
    end

    it "hostname and weight" do
      s = EbisuConnection::Slave.new("host_1, 10", "slave")
      expect(s.hostname).to eq("host_1")
      expect(s.weight).to eq(10)
    end

    it "hostname, weight and port" do
      s = EbisuConnection::Slave.new("host_1:1975, 10", "slave")
      expect(s.hostname).to eq("host_1")
      expect(s.weight).to eq(10)
    end
  end

  context "initialize(conf is Hash)" do
    it "hostname only" do
      s = EbisuConnection::Slave.new({:host => "host_1"}, "slave")
      expect(s.hostname).to eq("host_1")
      expect(s.weight).to eq(1)
    end

    it "hostname and weight" do
      s = EbisuConnection::Slave.new({:host => "host_1", :weight => 10}, "slave")
      expect(s.hostname).to eq("host_1")
      expect(s.weight).to eq(10)
    end

    it "hostname, weight and port" do
      s = EbisuConnection::Slave.new({:host => "host_1", :weight => 10, :port => 1975}, "slave")
      expect(s.hostname).to eq("host_1")
      expect(s.weight).to eq(10)
    end
  end

  context "#connection" do
    it "return Mysql2Adapter object" do
      s = EbisuConnection::Slave.new("localhost", "slave")
      expect(s.connection).to be_a(ActiveRecord::ConnectionAdapters::Mysql2Adapter)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ebisu_connection-0.3.0 spec/unit/slave_spec.rb