2008-10-30 05:58:04 +03:00
|
|
|
require 'rubygems'
|
|
|
|
require 'erb' # to get "h"
|
|
|
|
require 'active_support' # to get "returning"
|
|
|
|
require File.dirname(__FILE__) + '/../lib/gravatar'
|
|
|
|
include GravatarHelper, GravatarHelper::PublicMethods, ERB::Util
|
|
|
|
|
2010-09-10 07:09:02 +04:00
|
|
|
describe "gravatar_url with a custom default URL" do
|
|
|
|
before(:each) do
|
2008-10-30 05:58:04 +03:00
|
|
|
@original_options = DEFAULT_OPTIONS.dup
|
|
|
|
DEFAULT_OPTIONS[:default] = "no_avatar.png"
|
|
|
|
@url = gravatar_url("somewhere")
|
|
|
|
end
|
|
|
|
|
2010-09-10 07:09:02 +04:00
|
|
|
it "should include the \"default\" argument in the result" do
|
2008-10-30 05:58:04 +03:00
|
|
|
@url.should match(/&default=no_avatar.png/)
|
|
|
|
end
|
|
|
|
|
2010-09-10 07:09:02 +04:00
|
|
|
after(:each) do
|
2008-10-30 05:58:04 +03:00
|
|
|
DEFAULT_OPTIONS.merge!(@original_options)
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2010-09-10 07:09:02 +04:00
|
|
|
describe "gravatar_url with default settings" do
|
|
|
|
before(:each) do
|
2008-10-30 05:58:04 +03:00
|
|
|
@url = gravatar_url("somewhere")
|
|
|
|
end
|
|
|
|
|
2010-09-10 07:09:02 +04:00
|
|
|
it "should have a nil default URL" do
|
2008-10-30 05:58:04 +03:00
|
|
|
DEFAULT_OPTIONS[:default].should be_nil
|
|
|
|
end
|
|
|
|
|
2010-09-10 07:09:02 +04:00
|
|
|
it "should not include the \"default\" argument in the result" do
|
2008-10-30 05:58:04 +03:00
|
|
|
@url.should_not match(/&default=/)
|
|
|
|
end
|
|
|
|
|
2010-09-10 07:09:02 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
describe "gravatar with a custom title option" do
|
|
|
|
it "should include the title in the result" do
|
|
|
|
gravatar('example@example.com', :title => "This is a title attribute").should match(/This is a title attribute/)
|
|
|
|
end
|
|
|
|
end
|