meta-tags 1.2.4 → 1.2.5

Sign up to get free protection for your applications and to get access to all the features.
data/meta-tags.gemspec CHANGED
@@ -14,13 +14,15 @@ Gem::Specification.new do |s|
14
14
 
15
15
  s.add_dependency 'actionpack'
16
16
 
17
+ s.add_development_dependency 'rake'
17
18
  s.add_development_dependency 'rspec'
18
19
  s.add_development_dependency 'yard'
20
+ s.add_development_dependency 'bluecloth'
19
21
 
20
22
  s.files = `git ls-files`.split("\n")
21
- s.test_files = `git ls-files -- {spec,features}/*`.split("\n")
23
+ s.test_files = `git ls-files -- {spec}/*`.split("\n")
22
24
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
23
- s.extra_rdoc_files = ['README.rdoc']
25
+ s.extra_rdoc_files = ['README.md', 'CHANGELOG.md']
24
26
  s.rdoc_options = ['--charset=UTF-8']
25
27
  s.require_paths = ['lib']
26
28
  end
@@ -0,0 +1,42 @@
1
+ require 'spec_helper'
2
+
3
+ class MetaTagsController < ActionController::Base
4
+ attr_reader :rendered
5
+
6
+ def render_without_meta_tags
7
+ @rendered = true
8
+ end
9
+
10
+ def index
11
+ @page_title = 'title'
12
+ @page_keywords = 'key1, key2, key3'
13
+ @page_description = 'description'
14
+ render
15
+ end
16
+
17
+ public :set_meta_tags, :meta_tags
18
+ end
19
+
20
+ describe MetaTags::ControllerHelper do
21
+ subject { MetaTagsController.new }
22
+
23
+ context 'module' do
24
+ it 'should be mixed into ActionController::Base' do
25
+ ActionController::Base.included_modules.should include(MetaTags::ControllerHelper)
26
+ end
27
+
28
+ it 'should respond to "set_meta_tags" helper' do
29
+ subject.should respond_to(:set_meta_tags)
30
+ end
31
+ end
32
+
33
+ describe '.render' do
34
+ it 'should set meta tags from instance variables' do
35
+ subject.index
36
+ subject.rendered.should be_true
37
+ subject.meta_tags.should == { :title => 'title', :keywords => 'key1, key2, key3', :description => 'description' }
38
+ end
39
+ end
40
+
41
+ it_behaves_like '.set_meta_tags'
42
+ end
@@ -1,9 +1,7 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  describe MetaTags::ViewHelper do
4
- before :each do
5
- @view = ActionView::Base.new
6
- end
4
+ subject { ActionView::Base.new }
7
5
 
8
6
  context 'module' do
9
7
  it 'should be mixed into ActionView::Base' do
@@ -11,120 +9,125 @@ describe MetaTags::ViewHelper do
11
9
  end
12
10
 
13
11
  it 'should respond to "title" helper' do
14
- @view.should respond_to(:title)
12
+ subject.should respond_to(:title)
15
13
  end
16
14
 
17
15
  it 'should respond to "description" helper' do
18
- @view.should respond_to(:description)
16
+ subject.should respond_to(:description)
19
17
  end
20
18
 
21
19
  it 'should respond to "keywords" helper' do
22
- @view.should respond_to(:keywords)
20
+ subject.should respond_to(:keywords)
23
21
  end
24
22
 
25
23
  it 'should respond to "noindex" helper' do
26
- @view.should respond_to(:noindex)
24
+ subject.should respond_to(:noindex)
27
25
  end
28
26
 
29
27
  it 'should respond to "nofollow" helper' do
30
- @view.should respond_to(:nofollow)
28
+ subject.should respond_to(:nofollow)
31
29
  end
32
30
 
33
31
  it 'should respond to "set_meta_tags" helper' do
34
- @view.should respond_to(:set_meta_tags)
32
+ subject.should respond_to(:set_meta_tags)
35
33
  end
36
34
 
37
35
  it 'should respond to "display_meta_tags" helper' do
38
- @view.should respond_to(:display_meta_tags)
36
+ subject.should respond_to(:display_meta_tags)
39
37
  end
40
38
  end
41
39
 
42
40
  context 'returning values' do
43
41
  it 'should return title' do
44
- @view.title('some-title').should == 'some-title'
42
+ subject.title('some-title').should == 'some-title'
45
43
  end
46
44
 
47
45
  it 'should return headline if specified' do
48
- @view.title('some-title', 'some-headline').should == 'some-headline'
46
+ subject.title('some-title', 'some-headline').should == 'some-headline'
49
47
  end
50
48
 
51
49
  it 'should return description' do
52
- @view.description('some-description').should == 'some-description'
50
+ subject.description('some-description').should == 'some-description'
53
51
  end
54
52
 
55
53
  it 'should return keywords' do
56
- @view.keywords('some-keywords').should == 'some-keywords'
54
+ subject.keywords('some-keywords').should == 'some-keywords'
57
55
  end
58
56
 
59
57
  it 'should return noindex' do
60
- @view.noindex('some-noindex').should == 'some-noindex'
58
+ subject.noindex('some-noindex').should == 'some-noindex'
61
59
  end
62
60
 
63
61
  it 'should return nofollow' do
64
- @view.noindex('some-nofollow').should == 'some-nofollow'
62
+ subject.noindex('some-nofollow').should == 'some-nofollow'
65
63
  end
66
64
  end
67
65
 
68
- context 'title' do
66
+ context 'displaying title' do
69
67
  it 'should use website name if title is empty' do
70
- @view.display_meta_tags(:site => 'someSite').should == '<title>someSite</title>'
68
+ subject.display_meta_tags(:site => 'someSite').should == '<title>someSite</title>'
71
69
  end
72
70
 
73
71
  it 'should display title when "title" used' do
74
- @view.title('someTitle')
75
- @view.display_meta_tags(:site => 'someSite').should == '<title>someSite | someTitle</title>'
72
+ subject.title('someTitle')
73
+ subject.display_meta_tags(:site => 'someSite').should == '<title>someSite | someTitle</title>'
74
+ end
75
+
76
+ it 'should display title only when "site" is empty' do
77
+ subject.title('someTitle')
78
+ subject.display_meta_tags.should == '<title>someTitle</title>'
76
79
  end
77
80
 
78
81
  it 'should display title when "set_meta_tags" used' do
79
- @view.set_meta_tags(:title => 'someTitle')
80
- @view.display_meta_tags(:site => 'someSite').should == '<title>someSite | someTitle</title>'
82
+ subject.set_meta_tags(:title => 'someTitle')
83
+ subject.display_meta_tags(:site => 'someSite').should == '<title>someSite | someTitle</title>'
81
84
  end
82
85
 
83
86
  it 'should display custom title if given' do
84
- @view.title('someTitle')
85
- @view.display_meta_tags(:site => 'someSite', :title => 'defaultTitle').should == '<title>someSite | someTitle</title>'
87
+ subject.title('someTitle')
88
+ subject.display_meta_tags(:site => 'someSite', :title => 'defaultTitle').should == '<title>someSite | someTitle</title>'
86
89
  end
87
90
 
88
91
  it 'should use website before page by default' do
89
- @view.display_meta_tags(:site => 'someSite', :title => 'someTitle').should == '<title>someSite | someTitle</title>'
92
+ subject.display_meta_tags(:site => 'someSite', :title => 'someTitle').should == '<title>someSite | someTitle</title>'
90
93
  end
91
94
 
92
95
  it 'should only use markup in titles in the view' do
93
- @view.title('<b>someTitle</b>').should == '<b>someTitle</b>'
94
- @view.display_meta_tags(:site => 'someSite').should == '<title>someSite | someTitle</title>'
96
+ subject.title('<b>someTitle</b>').should == '<b>someTitle</b>'
97
+ subject.display_meta_tags(:site => 'someSite').should == '<title>someSite | someTitle</title>'
95
98
  end
96
99
 
97
100
  it 'should use page before website if :reverse' do
98
- @view.display_meta_tags(:site => 'someSite', :title => 'someTitle', :reverse => true).should == '<title>someTitle | someSite</title>'
101
+ subject.display_meta_tags(:site => 'someSite', :title => 'someTitle', :reverse => true).should == '<title>someTitle | someSite</title>'
99
102
  end
100
103
 
101
104
  it 'should be lowercase if :lowercase' do
102
- @view.display_meta_tags(:site => 'someSite', :title => 'someTitle', :lowercase => true).should == '<title>someSite | sometitle</title>'
105
+ subject.display_meta_tags(:site => 'someSite', :title => 'someTitle', :lowercase => true).should == '<title>someSite | sometitle</title>'
103
106
  end
104
107
 
105
108
  it 'should use custom separator if :separator' do
106
- @view.title('someTitle')
107
- @view.display_meta_tags(:site => 'someSite', :separator => '-').should == '<title>someSite - someTitle</title>'
108
- @view.display_meta_tags(:site => 'someSite', :separator => ':').should == '<title>someSite : someTitle</title>'
109
- @view.display_meta_tags(:site => 'someSite', :separator => '&mdash;').should == '<title>someSite &amp;mdash; someTitle</title>'
110
- @view.display_meta_tags(:site => 'someSite', :separator => '&mdash;'.html_safe).should == '<title>someSite &mdash; someTitle</title>'
111
- @view.display_meta_tags(:site => 'someSite: ', :separator => false).should == '<title>someSite: someTitle</title>'
109
+ subject.title('someTitle')
110
+ subject.display_meta_tags(:site => 'someSite', :separator => '-').should == '<title>someSite - someTitle</title>'
111
+ subject.display_meta_tags(:site => 'someSite', :separator => ':').should == '<title>someSite : someTitle</title>'
112
+ subject.display_meta_tags(:site => 'someSite', :separator => '&mdash;').should == '<title>someSite &amp;mdash; someTitle</title>'
113
+ subject.display_meta_tags(:site => 'someSite', :separator => '&mdash;'.html_safe).should == '<title>someSite &mdash; someTitle</title>'
114
+ subject.display_meta_tags(:site => 'someSite: ', :separator => false).should == '<title>someSite: someTitle</title>'
112
115
  end
113
116
 
114
117
  it 'should use custom prefix and suffix if available' do
115
- @view.display_meta_tags(:site => 'someSite', :title => 'someTitle', :prefix => ' -', :suffix => '- ').should == '<title>someSite -|- someTitle</title>'
118
+ subject.display_meta_tags(:site => 'someSite', :title => 'someTitle', :prefix => ' -', :suffix => '- ').should == '<title>someSite -|- someTitle</title>'
116
119
  end
117
120
 
118
121
  it 'should collapse prefix if false' do
119
- @view.display_meta_tags(:site => 'someSite', :title => 'someTitle', :prefix => false).should == '<title>someSite| someTitle</title>'
122
+ subject.display_meta_tags(:site => 'someSite', :title => 'someTitle', :prefix => false).should == '<title>someSite| someTitle</title>'
120
123
  end
121
124
 
122
125
  it 'should collapse suffix if false' do
123
- @view.display_meta_tags(:site => 'someSite', :title => 'someTitle', :suffix => false).should == '<title>someSite |someTitle</title>'
126
+ subject.display_meta_tags(:site => 'someSite', :title => 'someTitle', :suffix => false).should == '<title>someSite |someTitle</title>'
124
127
  end
125
128
 
126
129
  it 'should use all custom options if available' do
127
- @view.display_meta_tags(:site => 'someSite',
130
+ subject.display_meta_tags(:site => 'someSite',
128
131
  :title => 'someTitle',
129
132
  :prefix => ' -',
130
133
  :suffix => '+ ',
@@ -134,15 +137,15 @@ describe MetaTags::ViewHelper do
134
137
  end
135
138
 
136
139
  it 'shold allow Arrays in title' do
137
- @view.display_meta_tags(:site => 'someSite', :title => ['someTitle', 'anotherTitle']).should == '<title>someSite | someTitle | anotherTitle</title>'
140
+ subject.display_meta_tags(:site => 'someSite', :title => ['someTitle', 'anotherTitle']).should == '<title>someSite | someTitle | anotherTitle</title>'
138
141
  end
139
142
 
140
143
  it 'shold allow Arrays in title with :lowercase' do
141
- @view.display_meta_tags(:site => 'someSite', :title => ['someTitle', 'anotherTitle'], :lowercase => true).should == '<title>someSite | sometitle | anothertitle</title>'
144
+ subject.display_meta_tags(:site => 'someSite', :title => ['someTitle', 'anotherTitle'], :lowercase => true).should == '<title>someSite | sometitle | anothertitle</title>'
142
145
  end
143
146
 
144
147
  it 'shold build title in reverse order if :reverse' do
145
- @view.display_meta_tags(:site => 'someSite',
148
+ subject.display_meta_tags(:site => 'someSite',
146
149
  :title => ['someTitle', 'anotherTitle'],
147
150
  :prefix => ' -',
148
151
  :suffix => '+ ',
@@ -153,171 +156,186 @@ describe MetaTags::ViewHelper do
153
156
 
154
157
  context 'displaying description' do
155
158
  it 'should display description when "description" used' do
156
- @view.description('someDescription')
157
- @view.display_meta_tags(:site => 'someSite').should include('<meta content="someDescription" name="description" />')
159
+ subject.description('someDescription')
160
+ subject.display_meta_tags(:site => 'someSite').should include('<meta content="someDescription" name="description" />')
158
161
  end
159
162
 
160
163
  it 'should display description when "set_meta_tags" used' do
161
- @view.set_meta_tags(:description => 'someDescription')
162
- @view.display_meta_tags(:site => 'someSite').should include('<meta content="someDescription" name="description" />')
164
+ subject.set_meta_tags(:description => 'someDescription')
165
+ subject.display_meta_tags(:site => 'someSite').should include('<meta content="someDescription" name="description" />')
163
166
  end
164
167
 
165
168
  it 'should display default description' do
166
- @view.display_meta_tags(:site => 'someSite', :description => 'someDescription').should include('<meta content="someDescription" name="description" />')
169
+ subject.display_meta_tags(:site => 'someSite', :description => 'someDescription').should include('<meta content="someDescription" name="description" />')
167
170
  end
168
171
 
169
172
  it 'should use custom description if given' do
170
- @view.description('someDescription')
171
- @view.display_meta_tags(:site => 'someSite', :description => 'defaultDescription').should include('<meta content="someDescription" name="description" />')
173
+ subject.description('someDescription')
174
+ subject.display_meta_tags(:site => 'someSite', :description => 'defaultDescription').should include('<meta content="someDescription" name="description" />')
172
175
  end
173
176
 
174
177
  it 'should strip multiple spaces' do
175
- @view.display_meta_tags(:site => 'someSite', :description => "some \n\r\t description").should include('<meta content="some description" name="description" />')
178
+ subject.display_meta_tags(:site => 'someSite', :description => "some \n\r\t description").should include('<meta content="some description" name="description" />')
176
179
  end
177
180
 
178
181
  it 'should strip HTML' do
179
- @view.display_meta_tags(:site => 'someSite', :description => "<p>some <b>description</b></p>").should include('<meta content="some description" name="description" />')
182
+ subject.display_meta_tags(:site => 'someSite', :description => "<p>some <b>description</b></p>").should include('<meta content="some description" name="description" />')
180
183
  end
181
184
 
182
185
  it 'should truncate correctly' do
183
- @view.display_meta_tags(:site => 'someSite', :description => "Lorem ipsum dolor sit amet, consectetuer sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.").should include('<meta content="Lorem ipsum dolor sit amet, consectetuer sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dol..." name="description" />')
186
+ subject.display_meta_tags(:site => 'someSite', :description => "Lorem ipsum dolor sit amet, consectetuer sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.").should include('<meta content="Lorem ipsum dolor sit amet, consectetuer sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dol..." name="description" />')
184
187
  end
185
188
  end
186
189
 
187
190
  context 'displaying keywords' do
188
191
  it 'should display keywords when "keywords" used' do
189
- @view.keywords('some-keywords')
190
- @view.display_meta_tags(:site => 'someSite').should include('<meta content="some-keywords" name="keywords" />')
192
+ subject.keywords('some-keywords')
193
+ subject.display_meta_tags(:site => 'someSite').should include('<meta content="some-keywords" name="keywords" />')
191
194
  end
192
195
 
193
196
  it 'should display keywords when "set_meta_tags" used' do
194
- @view.set_meta_tags(:keywords => 'some-keywords')
195
- @view.display_meta_tags(:site => 'someSite').should include('<meta content="some-keywords" name="keywords" />')
197
+ subject.set_meta_tags(:keywords => 'some-keywords')
198
+ subject.display_meta_tags(:site => 'someSite').should include('<meta content="some-keywords" name="keywords" />')
196
199
  end
197
200
 
198
201
  it 'should display default keywords' do
199
- @view.display_meta_tags(:site => 'someSite', :keywords => 'some-keywords').should include('<meta content="some-keywords" name="keywords" />')
202
+ subject.display_meta_tags(:site => 'someSite', :keywords => 'some-keywords').should include('<meta content="some-keywords" name="keywords" />')
200
203
  end
201
204
 
202
205
  it 'should use custom keywords if given' do
203
- @view.keywords('some-keywords')
204
- @view.display_meta_tags(:site => 'someSite', :keywords => 'default_keywords').should include('<meta content="some-keywords" name="keywords" />')
206
+ subject.keywords('some-keywords')
207
+ subject.display_meta_tags(:site => 'someSite', :keywords => 'default_keywords').should include('<meta content="some-keywords" name="keywords" />')
205
208
  end
206
209
 
207
210
  it 'should lowercase keywords' do
208
- @view.display_meta_tags(:site => 'someSite', :keywords => 'someKeywords').should include('<meta content="somekeywords" name="keywords" />')
211
+ subject.display_meta_tags(:site => 'someSite', :keywords => 'someKeywords').should include('<meta content="somekeywords" name="keywords" />')
209
212
  end
210
213
 
211
214
  it 'should join keywords from Array' do
212
- @view.display_meta_tags(:site => 'someSite', :keywords => %w(keyword1 keyword2)).should include('<meta content="keyword1, keyword2" name="keywords" />')
215
+ subject.display_meta_tags(:site => 'someSite', :keywords => %w(keyword1 keyword2)).should include('<meta content="keyword1, keyword2" name="keywords" />')
213
216
  end
214
217
 
215
218
  it 'should join keywords from nested Arrays' do
216
- @view.display_meta_tags(:site => 'someSite', :keywords => [%w(keyword1 keyword2), 'keyword3']).should include('<meta content="keyword1, keyword2, keyword3" name="keywords" />')
219
+ subject.display_meta_tags(:site => 'someSite', :keywords => [%w(keyword1 keyword2), 'keyword3']).should include('<meta content="keyword1, keyword2, keyword3" name="keywords" />')
217
220
  end
218
221
  end
219
222
 
220
223
  context 'displaying noindex' do
221
224
  it 'should display noindex when "noindex" used' do
222
- @view.noindex(true)
223
- @view.display_meta_tags(:site => 'someSite').should include('<meta content="noindex" name="robots" />')
225
+ subject.noindex(true)
226
+ subject.display_meta_tags(:site => 'someSite').should include('<meta content="noindex" name="robots" />')
224
227
  end
225
228
 
226
229
  it 'should display noindex when "set_meta_tags" used' do
227
- @view.set_meta_tags(:noindex => true)
228
- @view.display_meta_tags(:site => 'someSite').should include('<meta content="noindex" name="robots" />')
230
+ subject.set_meta_tags(:noindex => true)
231
+ subject.display_meta_tags(:site => 'someSite').should include('<meta content="noindex" name="robots" />')
229
232
  end
230
233
 
231
234
  it 'should use custom noindex if given' do
232
- @view.noindex('some-noindex')
233
- @view.display_meta_tags(:site => 'someSite').should include('<meta content="noindex" name="some-noindex" />')
235
+ subject.noindex('some-noindex')
236
+ subject.display_meta_tags(:site => 'someSite').should include('<meta content="noindex" name="some-noindex" />')
234
237
  end
235
238
 
236
239
  it 'should display nothing by default' do
237
- @view.display_meta_tags(:site => 'someSite').should_not include('<meta content="noindex"')
240
+ subject.display_meta_tags(:site => 'someSite').should_not include('<meta content="noindex"')
238
241
  end
239
242
  end
240
243
 
241
244
  context 'displaying nofollow' do
242
245
  it 'should display nofollow when "nofollow" used' do
243
- @view.nofollow(true)
244
- @view.display_meta_tags(:site => 'someSite').should include('<meta content="nofollow" name="robots" />')
246
+ subject.nofollow(true)
247
+ subject.display_meta_tags(:site => 'someSite').should include('<meta content="nofollow" name="robots" />')
245
248
  end
246
249
 
247
250
  it 'should display nofollow when "set_meta_tags" used' do
248
- @view.set_meta_tags(:nofollow => true)
249
- @view.display_meta_tags(:site => 'someSite').should include('<meta content="nofollow" name="robots" />')
251
+ subject.set_meta_tags(:nofollow => true)
252
+ subject.display_meta_tags(:site => 'someSite').should include('<meta content="nofollow" name="robots" />')
250
253
  end
251
254
 
252
255
  it 'should use custom nofollow if given' do
253
- @view.nofollow('some-nofollow')
254
- @view.display_meta_tags(:site => 'someSite').should include('<meta content="nofollow" name="some-nofollow" />')
256
+ subject.nofollow('some-nofollow')
257
+ subject.display_meta_tags(:site => 'someSite').should include('<meta content="nofollow" name="some-nofollow" />')
255
258
  end
256
259
 
257
260
  it 'should display nothing by default' do
258
- @view.display_meta_tags(:site => 'someSite').should_not include('<meta content="nofollow"')
261
+ subject.display_meta_tags(:site => 'someSite').should_not include('<meta content="nofollow"')
259
262
  end
260
263
  end
261
264
 
262
265
  context 'displaying both nofollow and noindex' do
263
266
  it 'should be displayed when set using helpers' do
264
- @view.noindex(true)
265
- @view.nofollow(true)
266
- @view.display_meta_tags(:site => 'someSite').should include('<meta content="noindex, nofollow" name="robots" />')
267
+ subject.noindex(true)
268
+ subject.nofollow(true)
269
+ subject.display_meta_tags(:site => 'someSite').should include('<meta content="noindex, nofollow" name="robots" />')
267
270
  end
268
271
 
269
272
  it 'should be displayed when "set_meta_tags" used' do
270
- @view.set_meta_tags(:nofollow => true, :noindex => true)
271
- @view.display_meta_tags(:site => 'someSite').should include('<meta content="noindex, nofollow" name="robots" />')
273
+ subject.set_meta_tags(:nofollow => true, :noindex => true)
274
+ subject.display_meta_tags(:site => 'someSite').should include('<meta content="noindex, nofollow" name="robots" />')
272
275
  end
273
276
 
274
277
  it 'should use custom name if string is used' do
275
- @view.noindex('some-name')
276
- @view.nofollow('some-name')
277
- @view.display_meta_tags(:site => 'someSite').should include('<meta content="noindex, nofollow" name="some-name" />')
278
+ subject.noindex('some-name')
279
+ subject.nofollow('some-name')
280
+ subject.display_meta_tags(:site => 'someSite').should include('<meta content="noindex, nofollow" name="some-name" />')
278
281
  end
279
282
 
280
283
  it 'should display two meta tags when different names used' do
281
- @view.noindex('some-noindex')
282
- @view.nofollow('some-nofollow')
283
- content = @view.display_meta_tags(:site => 'someSite')
284
- content.should include('<meta content="noindex" name="some-noindex" />')
285
- content.should include('<meta content="nofollow" name="some-nofollow" />')
284
+ subject.noindex('some-noindex')
285
+ subject.nofollow('some-nofollow')
286
+ subject.display_meta_tags(:site => 'someSite').tap do |content|
287
+ content.should include('<meta content="noindex" name="some-noindex" />')
288
+ content.should include('<meta content="nofollow" name="some-nofollow" />')
289
+ end
286
290
  end
287
291
  end
288
292
 
289
293
  context 'displaying canonical url' do
290
294
  it 'should not display canonical url by default' do
291
- @view.display_meta_tags(:site => 'someSite').should_not include('<link href="http://example.com/base/url" rel="canonical" />')
295
+ subject.display_meta_tags(:site => 'someSite').should_not include('<link href="http://example.com/base/url" rel="canonical" />')
292
296
  end
293
297
 
294
298
  it 'should display canonical url when "set_meta_tags" used' do
295
- @view.set_meta_tags(:canonical => 'http://example.com/base/url')
296
- @view.display_meta_tags(:site => 'someSite').should include('<link href="http://example.com/base/url" rel="canonical" />')
299
+ subject.set_meta_tags(:canonical => 'http://example.com/base/url')
300
+ subject.display_meta_tags(:site => 'someSite').should include('<link href="http://example.com/base/url" rel="canonical" />')
297
301
  end
298
302
 
299
303
  it 'should display default canonical url' do
300
- @view.display_meta_tags(:site => 'someSite', :canonical => 'http://example.com/base/url').should include('<link href="http://example.com/base/url" rel="canonical" />')
304
+ subject.display_meta_tags(:site => 'someSite', :canonical => 'http://example.com/base/url').should include('<link href="http://example.com/base/url" rel="canonical" />')
301
305
  end
302
306
  end
303
307
 
304
308
  context 'displaying Open Graph meta tags' do
305
309
  it 'should display meta tags specified with :open_graph' do
306
- @view.set_meta_tags(:open_graph => {
310
+ subject.set_meta_tags(:open_graph => {
307
311
  :title => 'Facebook Share Title',
308
312
  :description => 'Facebook Share Description'
309
313
  })
310
- @view.display_meta_tags(:site => 'someSite').should include('<meta content="Facebook Share Title" property="og:title" />')
311
- @view.display_meta_tags(:site => 'someSite').should include('<meta content="Facebook Share Description" property="og:description" />')
314
+ subject.display_meta_tags(:site => 'someSite').tap do |content|
315
+ content.should include('<meta content="Facebook Share Title" property="og:title" />')
316
+ content.should include('<meta content="Facebook Share Description" property="og:description" />')
317
+ end
312
318
  end
313
319
 
314
320
  it 'should display meta tags specified with :og' do
315
- @view.set_meta_tags(:og => {
321
+ subject.set_meta_tags(:og => {
316
322
  :title => 'Facebook Share Title',
317
323
  :description => 'Facebook Share Description'
318
324
  })
319
- @view.display_meta_tags(:site => 'someSite').should include('<meta content="Facebook Share Title" property="og:title" />')
320
- @view.display_meta_tags(:site => 'someSite').should include('<meta content="Facebook Share Description" property="og:description" />')
325
+ subject.display_meta_tags(:site => 'someSite').tap do |content|
326
+ content.should include('<meta content="Facebook Share Title" property="og:title" />')
327
+ content.should include('<meta content="Facebook Share Description" property="og:description" />')
328
+ end
329
+ end
330
+
331
+ it 'should use deep merge when displaying open graph meta tags' do
332
+ subject.set_meta_tags(:og => { :title => 'Facebook Share Title' })
333
+ subject.display_meta_tags(:og => { :description => 'Facebook Share Description' }).tap do |content|
334
+ content.should include('<meta content="Facebook Share Title" property="og:title" />')
335
+ content.should include('<meta content="Facebook Share Description" property="og:description" />')
336
+ end
321
337
  end
322
338
  end
339
+
340
+ it_behaves_like '.set_meta_tags'
323
341
  end