Sha256: c295571e082a181bbfd3452548e39bab2c21eabe0733d04b5afc27dd64297b44

Contents?: true

Size: 1.68 KB

Versions: 15

Compression:

Stored size: 1.68 KB

Contents

require 'spec_helper'

describe LitmusPaper::Dependency::HaproxyBackends do
  describe "available?" do
    before(:each) do
      FileUtils.rm_rf("/tmp/stub-haproxy-stats")
      system "spec/support/haproxy_test_socket /tmp/stub-haproxy-stats &"
      sleep 1
    end

    it "is available if at least one backend is up" do
      pending "Broken on TravisCI 1.9.x; works locally" if ENV["TRAVIS_RUBY_VERSION"] =~ /\A1.9/
      haproxy = LitmusPaper::Dependency::HaproxyBackends.new("/tmp/stub-haproxy-stats", "yellow_cluster")
      haproxy.should be_available
    end

    it "returns false if no nodes are available" do
      pending "Broken on TravisCI 1.9.x; works locally" if ENV["TRAVIS_RUBY_VERSION"] =~ /\A1.9/
      haproxy = LitmusPaper::Dependency::HaproxyBackends.new("/tmp/stub-haproxy-stats", "orange_cluster")
      haproxy.should_not be_available
    end
  end

  describe "timeouts" do
    before(:each) do
      FileUtils.rm_rf("/tmp/stub-haproxy-stats")
      system "spec/support/haproxy_test_socket /tmp/stub-haproxy-stats 3 &"
      sleep 1
    end

    it "returns false after a configurable number of seconds" do
      pending "Broken on TravisCI 1.9.x; works locally" if ENV["TRAVIS_RUBY_VERSION"] =~ /\A1.9/
      haproxy = LitmusPaper::Dependency::HaproxyBackends.new("/tmp/stub-haproxy-stats", "yellow_cluster", :timeout_seconds => 1)
      haproxy.should_not be_available
    end
  end

  describe "to_s" do
    it "includes the socket file and the cluster" do
      haproxy = LitmusPaper::Dependency::HaproxyBackends.new("/tmp/stub-haproxy-stats", "orange_cluster")
      haproxy.to_s.should == 'Dependency::HaproxyBackends(/tmp/stub-haproxy-stats, orange_cluster)'
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
litmus_paper-0.7.9 spec/litmus_paper/dependency/haproxy_backends_spec.rb
litmus_paper-0.7.5 spec/litmus_paper/dependency/haproxy_backends_spec.rb
litmus_paper-0.7.4 spec/litmus_paper/dependency/haproxy_backends_spec.rb
litmus_paper-0.7.3 spec/litmus_paper/dependency/haproxy_backends_spec.rb
litmus_paper-0.7.2 spec/litmus_paper/dependency/haproxy_backends_spec.rb
litmus_paper-0.7.1 spec/litmus_paper/dependency/haproxy_backends_spec.rb
litmus_paper-0.7.0 spec/litmus_paper/dependency/haproxy_backends_spec.rb
litmus_paper-0.6.3 spec/litmus_paper/dependency/haproxy_backends_spec.rb
litmus_paper-0.6.2 spec/litmus_paper/dependency/haproxy_backends_spec.rb
litmus_paper-0.6.1 spec/litmus_paper/dependency/haproxy_backends_spec.rb
litmus_paper-0.6.0 spec/litmus_paper/dependency/haproxy_backends_spec.rb
litmus_paper-0.5.0 spec/litmus_paper/dependency/haproxy_backends_spec.rb
litmus_paper-0.4.0 spec/litmus_paper/dependency/haproxy_backends_spec.rb
litmus_paper-0.3.5 spec/litmus_paper/dependency/haproxy_backends_spec.rb
litmus_paper-0.3.3 spec/litmus_paper/dependency/haproxy_backends_spec.rb