nanoc-toolbox 0.0.7 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,17 +1,37 @@
1
1
  require "spec_helper"
2
- include Nanoc::Toolbox::Helpers::GoogleAnalytics
2
+
3
+
4
+ class GoogleAnalyticsDummyClass
5
+ include Nanoc::Toolbox::Helpers::GoogleAnalytics
6
+ def initialize
7
+ @config = { :ga_tracking_code => "UA-0000000-0" }
8
+ end
9
+ end
3
10
 
4
11
  describe Nanoc::Toolbox::Helpers::GoogleAnalytics do
5
- subject { Nanoc::Toolbox::Helpers::GoogleAnalytics }
12
+ subject { GoogleAnalyticsDummyClass.new }
13
+
6
14
  it { should respond_to(:ga_tracking_snippet) }
15
+
7
16
  describe ".ga_tracking_snippet" do
17
+
8
18
  it "returns a string that contains the JS" do
9
- ga_tracking_snippet("").should include("<script")
10
- ga_tracking_snippet("").should include("var _gaq = _gaq || [];")
19
+ subject.ga_tracking_snippet().should include("<script")
20
+ subject.ga_tracking_snippet().should include("var _gaq = _gaq || [];")
11
21
  end
12
-
22
+
13
23
  it "includes the passed code" do
14
- ga_tracking_snippet("qwertzuiop").should include("qwertzuiop")
24
+ subject.ga_tracking_snippet("UA-123456-1").should include("UA-123456-1")
25
+ end
26
+
27
+ it "includes the tracking code from the site config" do
28
+ subject.instance_variable_set(:@config, { :ga_tracking_code => "UA-0000000-0"})
29
+ subject.ga_tracking_snippet().should include "UA-0000000-0"
30
+ end
31
+
32
+ it "includes the placeholder code when no value is found" do
33
+ subject.instance_variable_set(:@config, { })
34
+ subject.ga_tracking_snippet().should include "UA-xxxxxx-x"
15
35
  end
16
36
  end
17
- end
37
+ end
@@ -1,85 +1,85 @@
1
1
  require "spec_helper"
2
2
 
3
3
  class GravatarDummyClass
4
+ include Nanoc::Toolbox::Helpers::Gravatar
4
5
  end
5
6
 
6
7
  describe Nanoc::Toolbox::Helpers::Gravatar do
7
- before(:each) do
8
- @gravatar = GravatarDummyClass.new
9
- @gravatar.extend(described_class)
10
-
8
+ subject { GravatarDummyClass.new }
9
+
10
+ before(:all) do
11
11
  @email = 'anouar@adlani.com'
12
12
  @avatar = 'avatar/4d076af1db60b16e1ce080505baf821c'
13
13
  @secure_host = {
14
14
  true => 'https://secure.gratatar.com/' + @avatar,
15
15
  false => 'http://gravatar.com/' + @avatar
16
16
  }
17
-
18
17
  end
19
18
 
20
- describe "#@gravatar.gravatar_url" do
19
+ it { should respond_to(:gravatar_url) }
20
+ it { should respond_to(:gravatar_image) }
21
+
22
+
23
+ describe "#subject.gravatar_url" do
21
24
  context "when no parameters passed in the options" do
22
25
  it "converts an email address to the a gravatar URL" do
23
- @gravatar.gravatar_url(@email).should == @secure_host[false]
26
+ subject.gravatar_url(@email).should == @secure_host[false]
24
27
  end
25
28
 
26
29
  it "converts an email address to the a secure gravatar URL when requested" do
27
- @gravatar.gravatar_url(@email, :secure => true).should == @secure_host[true]
30
+ subject.gravatar_url(@email, :secure => true).should == @secure_host[true]
28
31
  end
29
32
 
30
33
  it "raise an Argument error when the email is invalid" do
31
- lambda{@gravatar.gravatar_url('')}.should raise_error(ArgumentError)
32
- lambda{@gravatar.gravatar_url('a@a.c')}.should raise_error(ArgumentError)
33
- lambda{@gravatar.gravatar_url('@example.com')}.should raise_error(ArgumentError)
34
- lambda{@gravatar.gravatar_url('name@name@example.com')}.should raise_error(ArgumentError)
34
+ lambda{subject.gravatar_url('')}.should raise_error(ArgumentError)
35
+ lambda{subject.gravatar_url('a@a.c')}.should raise_error(ArgumentError)
36
+ lambda{subject.gravatar_url('@example.com')}.should raise_error(ArgumentError)
37
+ lambda{subject.gravatar_url('name@name@example.com')}.should raise_error(ArgumentError)
35
38
  end
36
39
 
37
40
  it "strips the additionnal spaces before and after the email" do
38
- @gravatar.gravatar_url(" \n #{@email} \n").should == @secure_host[false]
41
+ subject.gravatar_url(" \n #{@email} \n").should == @secure_host[false]
39
42
  end
40
43
  end
41
44
 
42
-
43
45
  context "when parameters passed in the options" do
44
-
45
46
  it "removes unknown parameters" do
46
- @gravatar.gravatar_url(@email, :blabl => 'jsdfsdfsd').should == @secure_host[false]
47
+ subject.gravatar_url(@email, :blabl => 'jsdfsdfsd').should == @secure_host[false]
47
48
  end
48
49
 
49
50
  it "removes empty or nil parameters" do
50
- @gravatar.gravatar_url(@email, :size => '', :rating => nil).should == @secure_host[false]
51
+ subject.gravatar_url(@email, :size => '', :rating => nil).should == @secure_host[false]
51
52
  end
52
53
 
53
54
  it "should sort the url parameters" do
54
- @gravatar.gravatar_url(@email, :size => 45, :default_icon => 'monsterid', :rating => 'x').should == @secure_host[false] + '?default_icon=monsterid&rating=x&size=45'
55
+ subject.gravatar_url(@email, :size => 45, :default_icon => 'monsterid', :rating => 'x').should == @secure_host[false] + '?default_icon=monsterid&rating=x&size=45'
55
56
  end
56
57
 
57
58
  it "accepts well formed option and render them" do
58
- @gravatar.gravatar_url(@email, :size => 45, :rating => 'x').should == @secure_host[false] + '?rating=x&size=45'
59
+ subject.gravatar_url(@email, :size => 45, :rating => 'x').should == @secure_host[false] + '?rating=x&size=45'
59
60
  end
60
61
 
61
62
  it "ignores the bad type or the out of rnage parameters" do
62
- @gravatar.gravatar_url(@email, :size => '45', :rating => 'xssss').should == @secure_host[false] + '?size=45'
63
+ subject.gravatar_url(@email, :size => '45', :rating => 'xssss').should == @secure_host[false] + '?size=45'
63
64
  end
64
65
  end
65
66
  end
66
67
 
67
68
  describe "#gravatar_image" do
68
-
69
69
  it "converts an email to an html tag" do
70
- @gravatar.gravatar_image(@email).should == %[<img src="#{@secure_host[false]}" />]
70
+ subject.gravatar_image(@email).should == %[<img src="#{@secure_host[false]}" />]
71
71
  end
72
72
 
73
73
  it "converts an email to an html tag with options for the gravatar" do
74
- @gravatar.gravatar_image(@email, :size => 45, :default_icon => 'monsterid', :rating => 'xss').should == %[<img src="#{@secure_host[false]}?default_icon=monsterid&size=45" />]
74
+ subject.gravatar_image(@email, :size => 45, :default_icon => 'monsterid', :rating => 'xss').should == %[<img src="#{@secure_host[false]}?default_icon=monsterid&size=45" />]
75
75
  end
76
76
 
77
77
  it "converts an email to an html tag with options for the img tag" do
78
- @gravatar.gravatar_image(@email, :height => 10).should == %[<img height="10" src="#{@secure_host[false]}" />]
78
+ subject.gravatar_image(@email, :height => 10).should == %[<img height="10" src="#{@secure_host[false]}" />]
79
79
  end
80
80
 
81
81
  it "converts an email to an html tag with options for the gravatar and for the img" do
82
- @gravatar.gravatar_image(@email, :height => 10, :size => 45, :default_icon => 'monsterid', :rating => 'xss').should == %[<img height="10" src="#{@secure_host[false]}?default_icon=monsterid&size=45" />]
82
+ subject.gravatar_image(@email, :height => 10, :size => 45, :default_icon => 'monsterid', :rating => 'xss').should == %[<img height="10" src="#{@secure_host[false]}?default_icon=monsterid&size=45" />]
83
83
  end
84
84
  end
85
85
  end
@@ -2,6 +2,9 @@ require "spec_helper"
2
2
  include Nanoc::Toolbox::Helpers::HtmlTag
3
3
 
4
4
  describe Nanoc::Toolbox::Helpers::HtmlTag do
5
+ it { should respond_to(:tag) }
6
+ it { should respond_to(:content_tag) }
7
+
5
8
  describe "#tag" do
6
9
  it "returns an simple self-closing tag by default" do
7
10
  tag("br").should == "<br />"
@@ -10,6 +13,10 @@ describe Nanoc::Toolbox::Helpers::HtmlTag do
10
13
  it "returns an simple self-closing tag with option" do
11
14
  tag("hr", :class => "thin").should == %[<hr class="thin" />]
12
15
  end
16
+
17
+ it "returns an orphean tag when open is set to true" do
18
+ tag("hr", {:class => "thin"}, true).should == %[<hr class="thin">]
19
+ end
13
20
  end
14
21
 
15
22
  describe "#content_tag" do
@@ -21,4 +28,4 @@ describe Nanoc::Toolbox::Helpers::HtmlTag do
21
28
  content_tag("b", "Hello", :class => "highlight").should == %[<b class="highlight">Hello</b>]
22
29
  end
23
30
  end
24
- end
31
+ end
@@ -1,81 +1,142 @@
1
1
  require "spec_helper"
2
2
 
3
-
4
3
  class NavigationDummyClass
4
+ include Nanoc::Toolbox::Helpers::Navigation
5
5
  end
6
6
 
7
7
  describe Nanoc::Toolbox::Helpers::Navigation do
8
- before(:each) do
9
- @navigation = NavigationDummyClass.new
10
- @navigation.extend(described_class)
11
- end
8
+ subject { NavigationDummyClass.new }
9
+
10
+ it { should respond_to(:render_menu) }
11
+ it { should respond_to(:navigation_for) }
12
+ it { should respond_to(:toc_for) }
13
+ it { should respond_to(:breadcrumb_for) }
12
14
 
13
15
  describe ".render_menu" do
16
+ before do
17
+ @sections = [
18
+ {:title => "Title", :link => "http://example.com", :subsections => [
19
+ {:title => "Title", :link => "http://example.com", :subsections => [
20
+ {:title => "Title", :link => "http://example.com", :subsections => [
21
+ {:title => "Title", :link => "http://example.com"}
22
+ ]}
23
+ ]}
24
+ ]}]
25
+ end
26
+
14
27
  context "when no options specified" do
28
+
15
29
  it "returns nil when the menu is empty" do
16
- @navigation.render_menu([]).should be_nil
30
+ subject.render_menu([]).should be_nil
17
31
  end
18
32
 
19
33
  it "returns a simple ordered list when given a 1 level menu" do
20
34
  sections = [{:title => "Title", :link => "http://example.com" }]
21
- html_menu = %[<ol><li><a href="http://example.com">Title</a></li></ol>]
22
-
23
- @navigation.render_menu(sections).should == html_menu
35
+ html_menu = %[<ol class="menu"><li><a href="http://example.com">Title</a></li></ol>]
36
+ subject.render_menu(sections).should == html_menu
24
37
  end
25
38
 
26
39
  it "returns a nested ordered list when given a multi level menu" do
27
- sections = [{:title => "Title", :link => "http://example.com", :subsections => [{:title => "Title", :link => "http://example.com" },{:title => "Title", :link => "http://example.com" }] }]
28
- html_menu = %[<ol><li><a href="http://example.com">Title</a><ol><li><a href="http://example.com">Title</a></li><li><a href="http://example.com">Title</a></li></ol></li></ol>]
29
-
30
- @navigation.render_menu(sections).should == html_menu
40
+ html_menu = %[<ol class="menu"><li><a href="http://example.com">Title</a><ol class="menu"><li><a href="http://example.com">Title</a><ol class="menu"><li><a href="http://example.com">Title</a></li></ol></li></ol></li></ol>]
41
+ subject.render_menu(@sections).should == html_menu
31
42
  end
32
43
 
33
- it "returns only 3 levels when nothing is specified in the options" do
34
- sections = [
35
- {:title => "Title", :link => "http://example.com", :subsections => [
36
- {:title => "Title", :link => "http://example.com", :subsections => [
37
- {:title => "Title", :link => "http://example.com", :subsections => [
38
- {:title => "Title", :link => "http://example.com"}
39
- ]}
40
- ]}
41
- ]}]
42
- html_menu = %[<ol><li><a href="http://example.com">Title</a><ol><li><a href="http://example.com">Title</a><ol><li><a href="http://example.com">Title</a></li></ol></li></ol></li></ol>]
43
- @navigation.render_menu(sections).should == html_menu
44
+ it "returns only 3 levels deep" do
45
+ html_menu = %[<ol class="menu"><li><a href="http://example.com">Title</a><ol class="menu"><li><a href="http://example.com">Title</a><ol class="menu"><li><a href="http://example.com">Title</a></li></ol></li></ol></li></ol>]
46
+ subject.render_menu(@sections).should == html_menu
44
47
  end
45
48
 
46
- it "returns menu within an html ordered list (<ol> <li>) when nothing is specified in the options" do
47
- sections = [{:title => "Title", :link => "http://example.com" }]
48
- @navigation.render_menu(sections).should =~ /^<ol><li>/
49
+ it "returns menu within an html ordered list with menu class(<ol> <li>)" do
50
+ subject.render_menu(@sections).should =~ /^<ol class="menu"><li>/
49
51
  end
50
52
  end
51
-
52
- context "when no options specified" do
53
- it "returns menu within a html unordered list (<ul> <li>) when it is specified in the options" do
54
- sections = [{:title => "Title", :link => "http://example.com" }]
55
- @navigation.render_menu(sections, :collection_tag => 'ul').should =~ /^<ul><li>/
53
+
54
+ context "when options specified" do
55
+ it "renders a title" do
56
+ subject.render_menu(@sections, :title => 'title').should =~ /^<h2>title<\/h2>/
57
+ subject.render_menu(@sections, :title => 'title', :title_tag => 'h1').should =~ /^<h1>title<\/h1>/
56
58
  end
57
-
58
- it "returns menu within a div/span when it is specified in the options" do
59
- sections = [{:title => "Title", :link => "http://example.com" }]
60
- @navigation.render_menu(sections, :collection_tag => 'div', :item_tag => 'span').should =~ /^<div><span>/
59
+ it "returns menu within a html unordered list (<ul> <li>) " do
60
+ subject.render_menu(@sections, :collection_tag => 'ul').should =~ /^<ul class="menu"><li>/
61
61
  end
62
-
63
- it "returns only 2 levels when it's specified in the options" do
64
- sections = [
65
- {:title => "Title", :link => "http://example.com", :subsections => [
66
- {:title => "Title", :link => "http://example.com", :subsections => [
67
- {:title => "Title", :link => "http://example.com", :subsections => [
68
- {:title => "Title", :link => "http://example.com"}
69
- ]}
70
- ]}
71
- ]}]
72
- html_menu = %[<ol><li><a href="http://example.com">Title</a><ol><li><a href="http://example.com">Title</a></li></ol></li></ol>]
73
- @navigation.render_menu(sections, :depth => 2).should == html_menu
62
+
63
+ it "returns menu within a div/span " do
64
+ subject.render_menu(@sections, :collection_tag => 'div', :item_tag => 'span').should =~ /^<div class="menu"><span>/
65
+ end
66
+
67
+ it "returns only 2 levels deep" do
68
+ html_menu = %[<ol class="menu"><li><a href="http://example.com">Title</a><ol class="menu"><li><a href="http://example.com">Title</a></li></ol></li></ol>]
69
+ subject.render_menu(@sections, :depth => 2).should == html_menu
70
+ end
71
+
72
+ it "set a specific class name" do
73
+ subject.render_menu(@sections, :collection_tag => 'ul').should =~ /^<ul class="menu"><li>/
74
74
  end
75
75
  end
76
76
  end
77
77
 
78
78
  describe ".toc_for" do
79
- it "should return a toc for a page"
79
+ before :all do
80
+ @content = <<-EOS
81
+ <html>
82
+ <body>
83
+ <div id="title1" class="section">
84
+ <h1>Title 1</h1>
85
+ <div id="title21" class="section">
86
+ <h2>Title 2<h2>
87
+ </div>
88
+ <div id="title22" class="section">
89
+ <h2>Title 2<h2>
90
+ </div>
91
+ <div id="title23" class="section">
92
+ <h2>Title 2<h2>
93
+ </div>
94
+ </div>
95
+ </body>
96
+ </html>
97
+ EOS
98
+ end
99
+
100
+ it "should return a toc for a page" do
101
+ item_rep = Nanoc::ItemRep.new(Nanoc::Item.new("", {:title => ""}, "/yetAnotherItem/"), "")
102
+ item_rep.instance_variable_set :@content, {:pre => @content}
103
+
104
+ subject.toc_for(item_rep).should include "#title1"
105
+ subject.toc_for(item_rep).should include "#title21"
106
+ subject.toc_for(item_rep).should include "#title22"
107
+ subject.toc_for(item_rep).should include "#title23"
108
+
109
+ subject.toc_for(item_rep).should include "Title 1"
110
+ subject.toc_for(item_rep).should include "Title 2"
111
+ end
112
+
113
+ it "calls find_to_sections and render_menu for the formating" do
114
+ item_rep = Nanoc::ItemRep.new(Nanoc::Item.new("", {:title => ""}, "/yetAnotherItem/"), "")
115
+ item_rep.instance_variable_set :@content, {:pre => @content}
116
+
117
+ subject.should_receive(:find_toc_sections).once
118
+ subject.should_receive(:render_menu).once
119
+ subject.toc_for(item_rep)
120
+ end
121
+
122
+ it "returns an empty string when the main content is empty" do
123
+ item_rep = Nanoc::ItemRep.new(Nanoc::Item.new("", {:title => ""}, "/yetAnotherItem/"), "")
124
+ item_rep.instance_variable_set :@content, {:pre => ""}
125
+ subject.toc_for(item_rep).should eq ""
126
+ end
127
+
128
+ it "returns an empty string when the provided css path returns nothing" do
129
+ item_rep = Nanoc::ItemRep.new(Nanoc::Item.new("", {:title => ""}, "/yetAnotherItem/"), "")
130
+ item_rep.instance_variable_set :@content, {:pre => @content}
131
+ subject.toc_for(item_rep, {:path => "section"}).should eq ""
132
+ end
133
+ end
134
+
135
+ describe ".navigation_for" do
136
+ it "should return a navigation menu for a item"
137
+ end
138
+
139
+ describe ".breadcrumb_for" do
140
+ it "should return a breadcrumb for an item"
80
141
  end
81
142
  end
@@ -0,0 +1,155 @@
1
+ require 'spec_helper'
2
+
3
+ class DummyTaggingExtra
4
+ include Nanoc::Toolbox::Helpers::TaggingExtra
5
+ end
6
+
7
+ describe Nanoc::Toolbox::Helpers::TaggingExtra do
8
+ subject { DummyTaggingExtra.new }
9
+
10
+ it { should respond_to :tag_set }
11
+ it { should respond_to :has_tag? }
12
+ it { should respond_to :items_with_tag }
13
+ it { should respond_to :count_tags }
14
+ it { should respond_to :rank_tags }
15
+ it { should respond_to :create_tag_pages }
16
+ it { should respond_to :tag_links_for }
17
+
18
+ describe ".tag_set" do
19
+ it "returns all the tags present in a collection of item" do
20
+ items = [ {:tags => ['a', 'b', 'c', 'd']}, {:tags => ['e', 'f']} ]
21
+ subject.tag_set(items).should eq %w{a b c d e f}
22
+ end
23
+
24
+ it "returns distinct tags in a collection of items" do
25
+ items = [ {:tags => ['a', 'b', 'c', 'd']}, {:tags => ['a', 'd', 'c', 'e', 'f']}]
26
+ subject.tag_set(items).should eq %w{a b c d e f}
27
+ end
28
+
29
+ it "returns tags without nil value when an item has no tag" do
30
+ items = [ {:tags => ['a', 'b', 'c', 'd']}, {:tags => ['a', 'd', 'c', 'e', 'f']}, {}]
31
+ subject.tag_set(items).should eq %w{a b c d e f}
32
+ end
33
+ end
34
+
35
+ describe ".has_tag?" do
36
+ it "returns true when the item contains the desired tag" do
37
+ item = { :tags => ['a', 'b', 'c'] }
38
+ subject.has_tag?(item, 'a').should be_true
39
+ end
40
+ it "returns false when the item contains the desired tag" do
41
+ item = { :tags => ['a', 'b', 'c'] }
42
+ subject.has_tag?(item, 'd').should be_false
43
+ end
44
+ it "returns fals when the item do not have tag" do
45
+ item = { }
46
+ subject.has_tag?(item, 'd').should be_false
47
+ end
48
+ end
49
+
50
+ describe ".items_with_tag" do
51
+ it "returns only the item whith the specified tag" do
52
+ item_a = {:tags => ['a', 'b', 'c', 'd']}
53
+ item_b = {:tags => ['a', 'd', 'c', 'e', 'f']}
54
+ items = [ item_a, item_b, {}]
55
+ subject.items_with_tag('f', items).should eq [item_b]
56
+ end
57
+
58
+ it "returns only all the item whith the specified tag" do
59
+ item_a = {:tags => ['a', 'b', 'c', 'd']}
60
+ item_b = {:tags => ['a', 'd', 'c', 'e', 'f']}
61
+ items = [ item_a, item_b, {}]
62
+ subject.items_with_tag('a', items).should eq [item_a, item_b]
63
+ end
64
+
65
+ it "returns an empty array when no item has been found" do
66
+ item_a = {:tags => ['a', 'b', 'c', 'd']}
67
+ item_b = {:tags => ['a', 'd', 'c', 'e', 'f']}
68
+ items = [ item_a, item_b, {}]
69
+ subject.items_with_tag('g', items).should eq []
70
+ end
71
+ end
72
+
73
+ describe ".count_tag" do
74
+ it "return the occurences of all the tags in a collection of item" do
75
+ items = [ {:tags => ['a', 'b', 'c', 'd']}, {:tags => ['a', 'd', 'c', 'e' ]}]
76
+ subject.count_tags(items).should eq({'a' => 2, 'b' => 1, 'c' => 2, 'd' => 2, 'e' => 1 })
77
+ end
78
+ it "return the occurences of all the tags without the empty item" do
79
+ items = [ {:tags => ['a', 'b', 'c', 'd']}, {:tags => ['a', 'd', 'c', 'e' ]}, {}]
80
+ subject.count_tags(items).should eq({'a' => 2, 'b' => 1, 'c' => 2, 'd' => 2, 'e' => 1 })
81
+ end
82
+ end
83
+
84
+ describe ".rank_tags" do
85
+ it "Sort the tags of an item collection in N classes of rank" do
86
+ items = [ {:tags => ['a', 'b']}, {:tags => ['b', 'c']} ]
87
+ subject.rank_tags(2, items)['a'].should eq 1
88
+ subject.rank_tags(2, items)['b'].should eq 0
89
+ subject.rank_tags(2, items)['c'].should eq 1
90
+ end
91
+
92
+ it "Raises exception when the number of argument is invalid" do
93
+ items = [ {:tags => ['a', 'b']}, {:tags => ['b', 'c']} ]
94
+ lambda { subject.rank_tags(-1, items) }.should raise_error ArgumentError
95
+ lambda { subject.rank_tags(0, items) }.should raise_error ArgumentError
96
+ lambda { subject.rank_tags(1, items) }.should raise_error ArgumentError
97
+ end
98
+ end
99
+
100
+ describe ".create_tag_pages" do
101
+ it "Creates in-memory tag pages" do
102
+ subject.instance_variable_set(:@items, [ {:tags => ['a', 'b']}, {:tags => ['b', 'c']} ])
103
+
104
+ expect {
105
+ subject.create_tag_pages
106
+ }.to change { subject.instance_variable_get(:@items).size }.by(3)
107
+
108
+ subject.instance_variable_get(:@items).last(3).each do |tag_item|
109
+ tag_item.should be_a Nanoc::Item
110
+ tag_item.identifier.should =~ /^\/tags\//
111
+ end
112
+ end
113
+ end
114
+
115
+ describe ".tag_links_for" do
116
+ it "generates the tags lings corresponding to the parameter" do
117
+ tags = %W[a b c d e f]
118
+ item = { :tags => tags }
119
+ subject.tag_links_for(item).size.should == tags.size
120
+ tags.each do |t|
121
+ subject.tag_links_for(item).should include("<a href=\"/tags/#{t}.html\">#{t}</a>")
122
+ end
123
+ end
124
+
125
+ it "generates the same number of links than tags" do
126
+ tags = %W[a b c d e f]
127
+ subject.tag_links_for({ :tags => tags }).size.should == 6
128
+ end
129
+
130
+ it "excludes the tags passed as second parameter" do
131
+ omited = %W[ d e ]
132
+ item = { :tags => %W[a b c d e f] }
133
+
134
+ generated_links = subject.tag_links_for(item, omited)
135
+ generated_links.size.should == (item[:tags].size - omited.size)
136
+
137
+ omited.each do |t|
138
+ generated_links.should_not include("<a href=\"/tags/#{t}.html\">#{t}</a>")
139
+ end
140
+ end
141
+
142
+ it "handle the tag format in the URL and title passed in param" do
143
+ tags = %W[a b c d e f]
144
+ item = { :tags => tags }
145
+ omited = []
146
+ options = { :title => "all articles tagged with %%TAGNAME%%", :tag_pattern => "%%TAGNAME%%", :url_format => "/tags/tag_%%TAGNAME%%.html"}
147
+
148
+ generated_links = subject.tag_links_for(item, omited, options)
149
+ tags.each do |t|
150
+ generated_links.should include("<a href=\"/tags/tag_#{t}.html\">all articles tagged with #{t}</a>")
151
+ end
152
+ end
153
+
154
+ end
155
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,10 @@
1
+ require 'simplecov'
2
+ SimpleCov.start
3
+
1
4
  require "rspec/core"
2
5
  require 'rspec/mocks'
3
6
  require "nanoc/toolbox"
7
+ require "nanoc3"
4
8
 
5
9
  unless defined?(SPEC_ROOT)
6
10
  SPEC_ROOT = File.expand_path("../", __FILE__)
@@ -8,4 +12,4 @@ end
8
12
 
9
13
  RSpec.configure do |config|
10
14
  config.mock_with :rspec
11
- end
15
+ end