diff --git a/lib/faraday/response/raise_on_authentication_failure.rb b/lib/faraday/response/raise_on_authentication_failure.rb index d94771e..e90816e 100644 --- a/lib/faraday/response/raise_on_authentication_failure.rb +++ b/lib/faraday/response/raise_on_authentication_failure.rb @@ -4,7 +4,7 @@ module Faraday class Response::RaiseOnAuthenticationFailure < Response::Middleware def on_complete(response) - raise Tinder::AuthenticationFailed if response[:status] == 401 + raise Tinder::AuthenticationFailed if [401, 404].include?(response[:status]) end end end diff --git a/spec/tinder/connection_spec.rb b/spec/tinder/connection_spec.rb index b764953..8ed1fc2 100644 --- a/spec/tinder/connection_spec.rb +++ b/spec/tinder/connection_spec.rb @@ -12,6 +12,15 @@ lambda { connection.get('/rooms.json') }.should raise_error(Tinder::AuthenticationFailed) end + it "should raise an exception when an invalid subdomain is specified" do + stub_connection(Tinder::Connection) do |stub| + stub.get("/rooms.json") {[404, {}, "Not found"]} + end + + connection = Tinder::Connection.new('test', :token => 'foo') + lambda { connection.get('/rooms.json') }.should raise_error(Tinder::AuthenticationFailed) + end + it "should lookup token when username/password provided" do stub_connection(Tinder::Connection) do |stub| stub.get("/users/me.json") {[200, {}, fixture('users/me.json')]}