From 04484271369dafac81fafbb2e1899a3e9f34bc6e Mon Sep 17 00:00:00 2001 From: Lisa P Date: Thu, 25 Feb 2016 15:06:45 +0100 Subject: [PATCH] create error in v3.rb --- lib/travis/api/v3.rb | 1 + lib/travis/api/v3/error.rb | 6 ------ spec/v3/error_handling_spec.rb | 15 +++++++++++++++ 3 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 spec/v3/error_handling_spec.rb diff --git a/lib/travis/api/v3.rb b/lib/travis/api/v3.rb index 8c8be745..dd8c2af6 100644 --- a/lib/travis/api/v3.rb +++ b/lib/travis/api/v3.rb @@ -35,6 +35,7 @@ module Travis NotImplemented = ServerError .create('request not (yet) implemented', status: 501) RequestLimitReached = ClientError .create('request limit reached for resource', status: 429) AlreadySyncing = ClientError .create('sync already in progress', status: 409) + MethodNotAllowed = ClientError .create('method not allowed', status: 405) end end end diff --git a/lib/travis/api/v3/error.rb b/lib/travis/api/v3/error.rb index 61d10882..fefd2b08 100644 --- a/lib/travis/api/v3/error.rb +++ b/lib/travis/api/v3/error.rb @@ -35,10 +35,4 @@ module Travis::API::V3 super(message) end end - - class MethodNotAllowed < Error - def self.status - 405 - end - end end diff --git a/spec/v3/error_handling_spec.rb b/spec/v3/error_handling_spec.rb new file mode 100644 index 00000000..b86bf917 --- /dev/null +++ b/spec/v3/error_handling_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' + +describe Travis::API::V3::ServiceIndex do + let(:headers) {{ }} + let(:path) { "/v3/repo/1/enable" } + let(:json) { JSON.load(response.body) } + let(:response) { get(path, {}, headers) } + let(:resources) { json.fetch('resources') } + + it "handles wrong HTTP method with 405 status" do + + response.status.should == 405 + end + +end