Skip to content

Commit

Permalink
Merge pull request #16 from rbrosinha/del-args
Browse files Browse the repository at this point in the history
Del args
  • Loading branch information
luispollo committed May 8, 2017
2 parents dafc723 + 44c5471 commit 14cbba6
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion etcd-rb.gemspec
Expand Up @@ -20,7 +20,7 @@ Gem::Specification.new do |s|
s.require_paths = %w(lib)
s.bindir = 'bin'

s.add_dependency 'httpclient', '~> 2.3.0'
s.add_dependency 'httpclient', '~> 2.8.0'
s.add_dependency 'multi_json', '~> 1.7'

s.platform = Gem::Platform::RUBY
Expand Down
4 changes: 2 additions & 2 deletions lib/etcd/client/protocol.rb
Expand Up @@ -77,8 +77,8 @@ def update(key, value, expected_value, options={})
#
# @param key [String] the key to remove
# @return [String] the previous value, if any
def delete(key)
data = request_data(:delete, key_uri(key))
def delete(key, args={})
data = request_data(:delete, key_uri(key), args)
return nil unless data
data[S_PREV_NODE][S_VALUE]
end
Expand Down
1 change: 0 additions & 1 deletion lib/etcd/observer.rb
Expand Up @@ -8,7 +8,6 @@ def initialize(client, prefix, handler, options = {})
@handler = handler
@options = options
@index = nil
reset_logger!(Logger::DEBUG)
end

def run
Expand Down
2 changes: 1 addition & 1 deletion lib/etcd/version.rb
@@ -1,5 +1,5 @@
# encoding: utf-8

module Etcd
VERSION = '1.1.0'.freeze
VERSION = '1.1.3'.freeze
end
6 changes: 6 additions & 0 deletions spec/etcd/client_spec.rb
Expand Up @@ -113,13 +113,19 @@ def base_uri
describe '#delete' do
before do
stub_request(:delete, "#{base_uri}/keys/foo").to_return(body: MultiJson.dump({'prevNode' => {'value' => 1}}))
stub_request(:delete, "#{base_uri}/keys/foo?recursive=true").to_return(body: MultiJson.dump({'prevNode' => {'value' => 1}}))
end

it 'sends a DELETE request to remove a key' do
client.delete('/foo')
WebMock.should have_requested(:delete, "#{base_uri}/keys/foo")
end

it 'sends a DELETE request to remove a key with args' do
client.delete('/foo', query: { recursive: true })
WebMock.should have_requested(:delete, "#{base_uri}/keys/foo?recursive=true")
end

it 'returns the previous value' do
stub_request(:delete, "#{base_uri}/keys/foo").to_return(body: MultiJson.dump({'prevNode' => {'value' => 'bar'}}))
client.delete('/foo').should eq('bar')
Expand Down

0 comments on commit 14cbba6

Please sign in to comment.