summaryrefslogtreecommitdiffstats
path: root/lib/plugins/gravatar/spec/gravatar_spec.rb
blob: 365d42dbf58698ef5e20e15eeb5e437e0de2cef4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# frozen_string_literal: false

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

describe "gravatar_url with a custom default URL" do
  before(:each) do
    @original_options = DEFAULT_OPTIONS.dup
    DEFAULT_OPTIONS[:default] = "no_avatar.png"
    @url = gravatar_url("somewhere")
  end
  
  it "should include the \"default\" argument in the result" do
    @url.should match(/&default=no_avatar.png/)
  end
  
  after(:each) do
    DEFAULT_OPTIONS.merge!(@original_options)
  end
  
end

describe "gravatar_url with default settings" do
  before(:each) do
    @url = gravatar_url("somewhere")
  end
  
  it "should have a nil default URL" do
    DEFAULT_OPTIONS[:default].should be_nil
  end
  
  it "should not include the \"default\" argument in the result" do
    @url.should_not match(/&default=/)
  end  
  
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