shared_examples_for "a webhook" do |verb| it "should #{verb} to the given uri" do request = stub_request(verb, "www.example.com") Expressive.run("(#{verb} \"http://www.example.com\")") assert_requested(request) end it "should add an entry in the errors element of the scope" do message = 'Something went Pete Tong' exception = RestClient::Exception.new exception.message = message stub_request(verb, 'www.example.com').to_raise(exception) Expressive.run("(#{verb} \"http://www.example.com\")", @scope) @scope['_errors'].should eql message end it "should add an entry in the errors element of the scope" do stub_request(verb, "badexample.com").to_raise(RestClient::ResourceNotFound.new) Expressive.run("(#{verb} \"badexample.com\")", @scope) @scope['_errors'].should eql 'Resource Not Found' end it "should add an entry in the errors element of the scope" do stub_request(verb, 'www.example.com').to_timeout Expressive.run("(#{verb} \"http://www.example.com\")", @scope) @scope['_errors'].should eql 'Request Timeout' end end