spec/unit/etcd/client_spec.rb in etcd-0.0.5 vs spec/unit/etcd/client_spec.rb in etcd-0.0.6
- old
+ new
@@ -10,57 +10,65 @@
it "should use localhost and 4001 port by default" do
expect(client.host).to eq('127.0.0.1')
expect(client.port).to eq(4001)
end
- it "shlould follow redirection by default" do
+ it "should have SSL turned off by default" do
+ expect(client.use_ssl).to be_false
+ end
+
+ it "should have SSL verification turned on by default" do
+ expect(client.verify_mode).to eq(OpenSSL::SSL::VERIFY_PEER)
+ end
+
+ it "should follow redirection by default" do
expect(client.allow_redirect).to be_true
end
it "#machines should make /machines GET http request" do
- client.should_receive(:api_execute).with('/v1/machines', :get).and_return('foobar')
+ client.should_receive(:api_execute).with('/v2/machines', :get).and_return('foobar')
expect(client.machines).to eq(['foobar'])
end
it "#leader should make /leader GET http request" do
- client.should_receive(:api_execute).with('/v1/leader', :get).and_return('foobar')
+ client.should_receive(:api_execute).with('/v2/leader', :get).and_return('foobar')
expect(client.leader).to eq('foobar')
end
- it "#get('/foo') should make /v1/keys/foo GET http request" do
- client.should_receive(:api_execute).with('/v1/keys/foo', :get).and_return('{"value":1}')
+ it "#get('/foo') should make /v2/keys/foo GET http request" do
+ client.should_receive(:api_execute).with('/v2/keys/foo', :get, {:params=>{}}).and_return('{"value":1}')
expect(client.get('/foo').value).to eq(1)
end
describe "#set" do
- it "set('/foo', 1) should invoke /v1/keys/foo POST http request" do
- client.should_receive(:api_execute).with('/v1/keys/foo', :post, {'value'=>1}).and_return('{"value":1}')
+ it "set('/foo', 1) should invoke /v2/keys/foo PUT http request" do
+ client.should_receive(:api_execute).with('/v2/keys/foo', :put, params: {'value'=>1}).and_return('{"value":1}')
expect(client.set('/foo', 1).value).to eq(1)
end
- it "set('/foo', 1, 4) should invoke /v1/keys/foo POST http request and set the ttl to 4" do
- client.should_receive(:api_execute).with('/v1/keys/foo', :post, {'value'=>1, 'ttl'=>4}).and_return('{"value":1}')
+ it "set('/foo', 1, 4) should invoke /v2/keys/foo PUT http request and set the ttl to 4" do
+ client.should_receive(:api_execute).with('/v2/keys/foo', :put, params: {'value'=>1, 'ttl'=>4}).and_return('{"value":1}')
expect(client.set('/foo', 1, 4).value).to eq(1)
end
end
describe "#test_and_set" do
- it "test_and_set('/foo', 1, 4) should invoke /v1/keys/foo POST http request" do
- client.should_receive(:api_execute).with('/v1/keys/foo', :post, {'value'=>1, 'prevValue'=>4}).and_return('{"value":1}')
+ it "test_and_set('/foo', 1, 4) should invoke /v2/keys/foo PUT http request" do
+ client.should_receive(:api_execute).with('/v2/keys/foo', :put, params: {'value'=>1, 'prevValue'=>4}).and_return('{"value":1}')
expect(client.test_and_set('/foo', 1, 4).value).to eq(1)
end
- it "test_and_set('/foo', 1, 4, 10) should invoke /v1/keys/foo POST http request and set the ttl to 10" do
- client.should_receive(:api_execute).with('/v1/keys/foo', :post, {'value'=>1, 'prevValue'=>4, 'ttl'=>10}).and_return('{"value":1}')
+ it "test_and_set('/foo', 1, 4, 10) should invoke /v2/keys/foo PUT http request and set the ttl to 10" do
+ client.should_receive(:api_execute).with('/v2/keys/foo', :put, params: {'value'=>1, 'prevValue'=>4, 'ttl'=>10}).and_return('{"value":1}')
expect(client.test_and_set('/foo', 1, 4, 10).value).to eq(1)
end
end
- it "#watch('/foo') should make /v1/watch/foo GET http request" do
- client.should_receive(:api_execute).with('/v1/watch/foo', :get).and_return('{"value":1}')
+ it "#watch('/foo') should make /v2/watch/foo GET http request" do
+ client.should_receive(:api_execute).with('/v2/keys/foo', :get, {:timeout=>60, :params=>{:wait=>true}}).and_return('{"value":1}')
expect(client.watch('/foo').value).to eq(1)
end
- it "#delete('/foo') should make /v1/keys/foo DELETE http request" do
- client.should_receive(:api_execute).with('/v1/keys/foo', :delete).and_return('{"index":"1"}')
+ it "#delete('/foo') should make /v2/keys/foo DELETE http request" do
+ client.should_receive(:api_execute).with('/v2/keys/foo', :delete, {:params=>{}}).and_return('{"index":"1"}')
client.delete('/foo')
end
it_should_behave_like Etcd::Helpers
end