Skip to content

Commit

Permalink
Add /API/Tests/Details (delete)
Browse files Browse the repository at this point in the history
  • Loading branch information
Genki Sugawara committed Jan 2, 2015
1 parent 573a559 commit bfa9dfb
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/statuscake/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class StatusCake::Client
'/API/Tests/Periods' => :get,
'/API/Tests' => :get,
'/API/Tests/Details' => :get,
# Delete test when HTTP method is "DELETE"
# see https://www.statuscake.com/api/Tests/Deleting%20a%20Test.md
'/API/Tests/Update' => :put,
}

Expand Down Expand Up @@ -52,7 +54,8 @@ def initialize(options)

class_eval <<-EOS, __FILE__, __LINE__ + 1
def #{name}(params = {})
request(#{path.inspect}, #{method.inspect}, params)
method = params.delete(:method) || #{method.inspect}
request(#{path.inspect}, method, params)
end
EOS
end
Expand Down
25 changes: 25 additions & 0 deletions spec/statuscake_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,31 @@
end
end

describe '/API/Tests/Details (delete)' do
let(:params) do
{TestID: 241}
end

let(:response) do
{"TestID"=>6735,
"Affected"=>1,
"Success"=>true,
"Message"=>"This Check Has Been Deleted. It can not be recovered."}
end

it do
client = status_cake do |stub|
stub.delete('/API/Tests/Details') do |env|
expect(env.request_headers).to eq request_headers
expect(env.params).to eq stringify_hash(params)
[200, {'Content-Type' => 'json'}, JSON.dump(response)]
end
end

expect(client.tests_details(params.merge(method: :delete))).to eq response
end
end

describe '/API/Tests/Update' do
let(:params) do
{
Expand Down

0 comments on commit bfa9dfb

Please sign in to comment.