Skip to content
This repository has been archived by the owner on Apr 18, 2023. It is now read-only.

Commit

Permalink
implemented simple pavatar provider for tests
Browse files Browse the repository at this point in the history
  - test/lib/pavatar_provider.rb - simple sinatra pavatar provider
  - Samall updated to gemspec (rake gem:gem works now!)
  • Loading branch information
antono committed May 27, 2009
1 parent 44a6b06 commit 936a850
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Manifest.txt
Expand Up @@ -4,7 +4,7 @@ History.txt
init.rb
License.txt
Manifest.txt
README.txt
README.rdoc
Rakefile
lib/avatar.rb
lib/avatar/object_support.rb
Expand Down
1 change: 1 addition & 0 deletions lib/avatar/source/pavatar_source.rb
Expand Up @@ -16,6 +16,7 @@ class PavatarSource
#
def avatar_url_for(person, options = {})
return nil if person.nil?
options = options.merge! ::Avatar.default_avatar_options
field = options.delete(:pavatar_field) || :blog_url
raise ArgumentError.new('No field specified; either specify a default field or pass in a value for :pavatar_field (probably :blog_url)') unless field

Expand Down
Binary file added test/lib/pavatar.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 6 additions & 3 deletions test/lib/pavatar_provider.rb
@@ -1,11 +1,14 @@
require 'rubygems'
gem 'rack', '0.9.1'
require 'sinatra'

get '/' do
response['X-Pavatar'] = 'http://blog.example.com/pavatar.png'
response['X-Pavatar'] = 'http://localhost:4567/pavatar.png'
end

get '/pavatar.png' do
attachement('pavatar.png')
'yep' # we just need 200
end

get '/hsegment/pavatar.png' do
'yep' # we just need 200
end
20 changes: 20 additions & 0 deletions test/test_pavatar_source.rb
@@ -0,0 +1,20 @@
require File.dirname(__FILE__) + '/test_helper.rb'
require 'avatar/source/pavatar_source'

class TestPavatarSource < Test::Unit::TestCase

def setup
@source = Avatar::Source::PavatarSource.new
@gary = Person.new('antono@example.com', 'Antono Vasiljev', 'http://localhost:4567/')
end

def test_nil_when_person_is_nil
assert_nil @source.avatar_url_for(nil)
end

def test_not_nil_when_person_is_not_nil
assert_equal 'http://localhost:4567/pavatar.png', @source.avatar_url_for(@gary)
end


end

0 comments on commit 936a850

Please sign in to comment.