-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get include paths correct for Ruby 1.9
- Loading branch information
Showing
33 changed files
with
483 additions
and
483 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,37 @@ | ||
require File.dirname(__FILE__) + '/../../../test_helper' | ||
require File.expand_path('../../../../test_helper', __FILE__) | ||
|
||
module Fleakr::Api | ||
class AuthenticationRequestTest < Test::Unit::TestCase | ||
|
||
context "An instance of AuthenticationRequest" do | ||
|
||
should "know the endpoint URL" do | ||
request = AuthenticationRequest.new | ||
request.endpoint_url.should == 'http://flickr.com/services/auth/' | ||
end | ||
|
||
should "be able to make a request" do | ||
endpoint_uri = stub() | ||
|
||
request = AuthenticationRequest.new | ||
request.stubs(:endpoint_uri).with().returns(endpoint_uri) | ||
|
||
Net::HTTP.expects(:get_response).with(endpoint_uri).returns('response') | ||
|
||
request.response.should == 'response' | ||
end | ||
|
||
should "know the authorization_url for the authentication request" do | ||
response_headers = {'Location' => 'http://example.com/auth'} | ||
response = stub() {|r| r.stubs(:header).with().returns(response_headers) } | ||
|
||
request = AuthenticationRequest.new | ||
request.stubs(:response).with().returns(response) | ||
|
||
request.authorization_url.should == 'http://example.com/auth' | ||
end | ||
|
||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,58 @@ | ||
require File.dirname(__FILE__) + '/../../../test_helper' | ||
require File.expand_path('../../../../test_helper', __FILE__) | ||
|
||
module Fleakr::Api | ||
class FileParameterTest < Test::Unit::TestCase | ||
|
||
context "An instance of the FileParameter class" do | ||
|
||
setup do | ||
@temp_dir = File.expand_path(create_temp_directory) | ||
@filename = "#{@temp_dir}/image.jpg" | ||
end | ||
|
||
teardown do | ||
FileUtils.rm_rf(@temp_dir) | ||
end | ||
|
||
{'jpg' => 'image/jpeg', 'png' => 'image/png', 'gif' => 'image/gif'}.each do |ext, mime_type| | ||
should "know the correct MIME type for an extension of #{ext}" do | ||
parameter = FileParameter.new('photo', "#{@temp_dir}/image.#{ext}") | ||
parameter.mime_type.should == mime_type | ||
end | ||
end | ||
|
||
should "retrieve the contents of the file when accessing the value" do | ||
File.expects(:read).with(@filename).returns('bopbip') | ||
|
||
parameter = FileParameter.new('photo', @filename) | ||
parameter.value.should == 'bopbip' | ||
end | ||
|
||
should "cache the file contents after retrieving them" do | ||
File.expects(:read).with(@filename).once.returns('bopbip') | ||
|
||
parameter = FileParameter.new('photo', @filename) | ||
2.times { parameter.value } | ||
end | ||
|
||
should "know how to generate a form representation of itself" do | ||
filename = 'image.jpg' | ||
mime_type = 'image/jpeg' | ||
|
||
parameter = FileParameter.new('photo', filename) | ||
parameter.stubs(:mime_type).with().returns(mime_type) | ||
parameter.stubs(:value).with().returns('data') | ||
expected = | ||
|
||
expected = | ||
"Content-Disposition: form-data; name=\"photo\"; filename=\"#{filename}\"\r\n" + | ||
"Content-Type: image/jpeg\r\n" + | ||
"\r\n" + | ||
"data\r\n" | ||
|
||
parameter.to_form.should == expected | ||
end | ||
|
||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.