test/webhook_command_test.rb in gemcutter-0.3.0 vs test/webhook_command_test.rb in gemcutter-0.4.0.pre
- old
+ new
@@ -1,12 +1,12 @@
-require 'command_helper'
+require 'helper'
class WebhookCommandTest < CommandTest
context "webhooking" do
setup do
@gem = "foo"
- @api = "https://gemcutter.org/api/v1/web_hooks"
+ @api = "https://rubygems.org/api/v1/web_hooks"
@url = "http://example.com/hook"
@command = Gem::Commands::WebhookCommand.new
stub(@command).say
end
@@ -18,11 +18,11 @@
end
end
context "adding a specific hook" do
setup do
- stub_config({ :rubygems_api_key => "key" })
+ stub_api_key("key")
stub_request(:post, @api).to_return(:body => "Success!")
@command.handle_options([@gem, "-a", @url])
@command.execute
end
@@ -43,11 +43,11 @@
end
end
context "adding a global hook" do
setup do
- stub_config({ :rubygems_api_key => "key" })
+ stub_api_key("key")
stub_request(:post, @api).to_return(:body => "Success!")
@command.handle_options(["-g", "-a", @url])
@command.execute
end
@@ -68,11 +68,11 @@
end
end
context "listing hooks with some available" do
setup do
- stub_config({ :rubygems_api_key => "key" })
+ stub_api_key("key")
stub_request(:get, @api).to_return :body => <<EOF
{
"foo": [{"url":"http://foogemhook.com","failure_count":0}],
"all gems":[{"url":"http://allgemshook.com","failure_count":0}]
}
@@ -121,11 +121,11 @@
end
end
context "listing hooks with none available" do
setup do
- stub_config({ :rubygems_api_key => "key" })
+ stub_api_key("key")
stub_request(:get, @api).to_return(:body => "{}")
@command.handle_options([])
@command.execute
end
@@ -137,11 +137,11 @@
end
context "listing hooks with a json error" do
setup do
stub(@command).terminate_interaction
- stub_config({ :rubygems_api_key => "key" })
+ stub_api_key("key")
stub_request(:get, @api).to_return(:body => "fubar")
@command.handle_options([])
@command.execute
end
@@ -158,11 +158,11 @@
end
end
context "removing specific hooks" do
setup do
- stub_config({ :rubygems_api_key => "key" })
+ stub_api_key("key")
stub_request(:delete, "#{@api}/remove").to_return(:body => "Success!")
@command.handle_options([@gem, "-r", @url])
@command.execute
end
@@ -183,11 +183,11 @@
end
end
context "removing global hooks" do
setup do
- stub_config({ :rubygems_api_key => "key" })
+ stub_api_key("key")
stub_request(:delete, "#{@api}/remove").to_return(:body => "Success!")
@command.handle_options(["-g", "-r", @url])
@command.execute
end
@@ -208,10 +208,10 @@
end
end
context "test firing hooks" do
setup do
- stub_config({ :rubygems_api_key => "key" })
+ stub_api_key("key")
stub_request(:post, "#{@api}/fire").to_return(:body => "Success!")
@command.handle_options([@gem, "-f", @url])
@command.execute
end