spec/rhapr/environment_spec.rb in rhapr-0.0.1 vs spec/rhapr/environment_spec.rb in rhapr-0.1.0

- old
+ new

@@ -24,10 +24,18 @@ File.should_receive(:exists?).with('/etc/haproxy.cfg').and_return(true) @env_test.config_path.should == '/etc/haproxy.cfg' end + it 'should select the first configuration found, from the pre-defined list' do + File.stub!(:exists?).and_return(false) + File.should_receive(:exists?).with('/etc/haproxy/haproxy.cfg').and_return(true) + File.should_receive(:exists?).with('/etc/haproxy.cfg').and_return(true) + + @env_test.config_path.should == '/etc/haproxy/haproxy.cfg' + end + it 'should be nil if config files do not exist and $HAPROXY_CONFIG is not set' do File.stub!(:exists?).and_return(false) @env_test.config_path.should be_nil end end @@ -83,27 +91,31 @@ @env_test.exec.should be_nil end end describe '#socket' do + it 'should establish a socket connection with HAProxy' + end + + describe '#socket_path' do it 'should parse out the io socket from the config file' do @env_test.should_receive(:config).and_return { config_for(:basic_haproxy) } - @env_test.socket.should == '/tmp/haproxy' + @env_test.socket_path.should == '/tmp/haproxy' end it 'should raise an error if it cannot derive an io socket from the config file' do @env_test.should_receive(:config).and_return { config_for(:crappy_haproxy) } lambda { - @env_test.socket + @env_test.socket_path }.should raise_error(RuntimeError) end end describe '#pid' do it 'should parse out the pidfile from the config file' do - @env_test.should_receive(:config).and_return { config_for(:basic_haproxy) } + @env_test.should_receive(:config).and_return { config_for(:pid_test_haproxy) } @env_test.pid.should == '/some/other/run/haproxy.pid' end it 'should return a default path if it cannot derive an io socket from the config file' do