Created
June 30, 2015 23:28
-
-
Save vilmibm/17f3ed88f0731343f601 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
client.command(1) # says i'm passing one argument | |
client.command(1,2) # says i'm passing zero arguments | |
client.command(1,2,3) # says i'm passing zero arguments | |
client.command(1, 2, 3, 4) # says i'm passing four arguments | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def command(endpoint, payload, version=@version) | |
path = "/commands" | |
payload = JSON.generate({'command' => command, | |
'version' => version, | |
'payload' => payload}) | |
debug("#{path} #{payload}") | |
ret = self.class.post( | |
path, | |
:body => {'payload' => payload}, | |
:options => { | |
:headers => { | |
'Accept' => 'application/json', | |
'Content-Type' => 'application/x-www-form-urlencoded' | |
} | |
} | |
) | |
raise_if_error(ret) | |
JSON.parse(ret.body).uuid | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plath 16:21 puppetdb-ruby (catchup ✘)✹ ➜ bundle exec rspec | |
...........F...... | |
Failures: | |
1) command formats payload correctly | |
Failure/Error: client.command(1, 2, 3) | |
ArgumentError: | |
wrong number of arguments (0 for 2..3) | |
# ./lib/puppetdb/client.rb:84:in `command' | |
# ./lib/puppetdb/client.rb:87:in `command' | |
# ./spec/unit/client_spec.rb:151:in `block (2 levels) in <top (required)>' | |
Finished in 0.00586 seconds (files took 0.0934 seconds to load) | |
18 examples, 1 failure | |
Failed examples: | |
rspec ./spec/unit/client_spec.rb:143 # command formats payload correctly | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment