Skip to content

Commit

Permalink
Get include paths correct for Ruby 1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
reagent committed Dec 29, 2010
1 parent 398fa39 commit fcd3b03
Show file tree
Hide file tree
Showing 33 changed files with 483 additions and 483 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ require 'rubygems'
require 'rake/gempackagetask'
require 'rake/testtask'

require 'lib/fleakr/version'
require File.expand_path('../lib/fleakr/version', __FILE__)

spec = Gem::Specification.new do |s|
s.name = 'fleakr'
Expand Down
24 changes: 12 additions & 12 deletions test/unit/fleakr/api/authentication_request_test.rb
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
30 changes: 15 additions & 15 deletions test/unit/fleakr/api/file_parameter_test.rb
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
2 changes: 1 addition & 1 deletion test/unit/fleakr/api/method_request_test.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require File.dirname(__FILE__) + '/../../../test_helper'
require File.expand_path('../../../../test_helper', __FILE__)

module Fleakr::Api
class MethodRequestTest < Test::Unit::TestCase
Expand Down
88 changes: 44 additions & 44 deletions test/unit/fleakr/api/option_test.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
require File.dirname(__FILE__) + '/../../../test_helper'
require File.expand_path('../../../../test_helper', __FILE__)

module Fleakr::Api

class OptionTest < Test::Unit::TestCase

def self.should_know_the_class_for(type, options)
should "know the class for the :#{type} type" do
Option.class_for(type).should == options[:is]
end
end

context "The Option class" do
should_know_the_class_for :title, :is => Fleakr::Api::SimpleOption
should_know_the_class_for :description, :is => Fleakr::Api::SimpleOption
Expand All @@ -18,64 +18,64 @@ def self.should_know_the_class_for(type, options)
should_know_the_class_for :level, :is => Fleakr::Api::LevelOption
should_know_the_class_for :type, :is => Fleakr::Api::TypeOption
should_know_the_class_for :hide?, :is => Fleakr::Api::HiddenOption

should "be able to create an option for a type" do
option = stub()

Option.expects(:class_for).with(:title).returns(Fleakr::Api::SimpleOption)
Fleakr::Api::SimpleOption.expects(:new).with(:title, 'blip').returns(option)

Option.for(:title, 'blip').should == option
end
end

end

class SimpleOptionTest < Test::Unit::TestCase

context "An instance of the SimpleOption class" do
should "have a type" do
so = SimpleOption.new(:title, 'blip')
so.type.should == :title
end

should "have a value" do
so = SimpleOption.new(:title, 'blip')
so.value.should == 'blip'
end

should "be able to generate a hash representation of itself" do
so = SimpleOption.new(:title, 'blip')
so.to_hash.should == {:title => 'blip'}
end
end

end

class TagOptionTest < Test::Unit::TestCase

context "An instance of the TagOption class" do

should "normalize the input value to an array" do
to = TagOption.new(:tags, 'blip')
to.value.should == ['blip']
end

should "be able to generate a hash representation of itself with tags joined on spaces" do
to = TagOption.new(:tags, %w(bop bip))
to.to_hash.should == {:tags => '"bop" "bip"'}
end

should "quote tag values with spaces" do
to = TagOption.new(:tags, ['tag', 'one with spaces'])
to.to_hash.should == {:tags => '"tag" "one with spaces"'}
end
end

end

class ViewOptionTest < Test::Unit::TestCase

context "An instance of the ViewOption class" do
should "be able to generate a hash representation for viewing by :everyone" do
vo = ViewOption.new(:viewable_by, :everyone)
Expand All @@ -86,94 +86,94 @@ class ViewOptionTest < Test::Unit::TestCase
vo = ViewOption.new(:viewable_by, :family)
vo.to_hash.should == {:is_public => 0, :is_family => 1, :is_friend => 0}
end

should "be able to generate a hash representation for viewing by :friends" do
vo = ViewOption.new(:viewable_by, :friends)
vo.to_hash.should == {:is_public => 0, :is_family => 0, :is_friend => 1}
end

should "know the visibility is public if value is set to :everyone" do
vo = ViewOption.new(:viewable_by, :everyone)
vo.public?.should be(true)
end

should "know the visibility is not public if :everyone is not the only value" do
vo = ViewOption.new(:viewable_by, [:everyone, :family])
vo.public?.should be(false)
end

should "know that its visible to friends and family if specified as such" do
vo = ViewOption.new(:viewable_by, [:friends, :family])
vo.friends?.should be(true)
vo.family?.should be(true)
end

end

end

class LevelOptionTest < Test::Unit::TestCase

context "An instance of the LevelOption class" do

should "be able to generate a hash representation for the :safe level" do
lo = LevelOption.new(:level, :safe)
lo.to_hash.should == {:safety_level => 1}
end

should "be able to generate a hash representation for the :moderate level" do
lo = LevelOption.new(:level, :moderate)
lo.to_hash.should == {:safety_level => 2}
end

should "be able to generate a hash representation for the :restricted level" do
lo = LevelOption.new(:level, :restricted)
lo.to_hash.should == {:safety_level => 3}
end

end

end

class TypeOptionTest < Test::Unit::TestCase

context "An instance of the TypeOption class" do

should "be able to generate a hash representation for the :photo type" do
to = TypeOption.new(:type, :photo)
to.to_hash.should == {:content_type => 1}
end

should "be able to generate a hash representation for the :screenshot type" do
to = TypeOption.new(:type, :screenshot)
to.to_hash.should == {:content_type => 2}
end

should "be able to generate a hash representation for the :other type" do
to = TypeOption.new(:type, :other)
to.to_hash.should == {:content_type => 3}
end

end

end

class HiddenOptionTest < Test::Unit::TestCase

context "An instance of the HiddenOption class" do

should "be able to generate a hash representation when set to true" do
ho = HiddenOption.new(:hide?, true)
ho.to_hash.should == {:hidden => 2}
end

should "be able to generate a hash representation when set to false" do
ho = HiddenOption.new(:hide?, false)
ho.to_hash.should == {:hidden => 1}
end

end

end

end
Loading

0 comments on commit fcd3b03

Please sign in to comment.