Skip to content

Commit

Permalink
Refactor response status specs
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Jan 11, 2011
1 parent 97f9037 commit c1c8ea1
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 180 deletions.
126 changes: 0 additions & 126 deletions spec/faraday/raise_http_4xx_spec.rb

This file was deleted.

54 changes: 0 additions & 54 deletions spec/faraday/raise_http_5xx_spec.rb

This file was deleted.

34 changes: 34 additions & 0 deletions spec/faraday/response_spec.rb
@@ -0,0 +1,34 @@
require File.expand_path('../../spec_helper', __FILE__)

describe Faraday::Response do
before do
@client = Twitter::Client.new
end

{
400 => Twitter::BadRequest,
401 => Twitter::Unauthorized,
403 => Twitter::Forbidden,
404 => Twitter::NotFound,
406 => Twitter::NotAcceptable,
420 => Twitter::EnhanceYourCalm,
500 => Twitter::InternalServerError,
502 => Twitter::BadGateway,
503 => Twitter::ServiceUnavailable,
}.each do |status, exception|
context "when HTTP status is #{status}" do

before do
stub_get('statuses/user_timeline.json').
with(:query => {:screen_name => 'sferik'}).
to_return(:status => status)
end

it "should raise #{exception.name} error" do
lambda do
@client.user_timeline('sferik')
end.should raise_error(exception)
end
end
end
end

0 comments on commit c1c8ea1

Please sign in to comment.