tophat 2.2.0 → 2.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +0 -1
- data/.travis.yml +13 -7
- data/Gemfile +1 -2
- data/README.md +5 -5
- data/lib/tophat/meta.rb +1 -1
- data/lib/tophat/robots.rb +11 -12
- data/lib/tophat/version.rb +1 -1
- data/spec/spec_helper.rb +12 -0
- data/spec/tophat/html_helper_spec.rb +9 -9
- data/spec/tophat/meta_helper_spec.rb +21 -16
- data/spec/tophat/opengraph_helper_spec.rb +41 -31
- data/spec/tophat/robots_helper_spec.rb +11 -11
- data/spec/tophat/stylesheet_helper_spec.rb +56 -56
- data/spec/tophat/title_helper_spec.rb +20 -20
- data/spec/tophat/twitter_card_helper_spec.rb +11 -11
- data/spec/tophat_spec.rb +21 -21
- data/tophat.gemspec +1 -1
- metadata +14 -25
- data/Guardfile +0 -6
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b56ca22052879feee712624be7e4280ba092ebe4
|
4
|
+
data.tar.gz: 17028a90e939dff0feb788e70638376330b9d97a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 232aa078654be03c161781b600c5589bbcc1d7b3987282f5856bef5bad67264d3a325eb66aebc5129d442f7afd3b97b5b12811e55a1b80e2774abef2cb1bbb9b
|
7
|
+
data.tar.gz: a7b08dbbab148bd2456f2883d1008059f960f1477e6939454f23bfa770943b80edd46fccc74d7e4fbd803687b2fdb0d95a2d1d746958a7e1139e6e5b214213e8
|
data/.rspec
CHANGED
data/.travis.yml
CHANGED
@@ -1,13 +1,19 @@
|
|
1
1
|
bundler_args: --without development
|
2
2
|
language: ruby
|
3
3
|
rvm:
|
4
|
-
- rbx-18mode
|
5
|
-
- rbx-19mode
|
6
|
-
- 1.8.7
|
7
|
-
- 1.9.2
|
8
4
|
- 1.9.3
|
9
|
-
- 2.0
|
5
|
+
- 2.0
|
6
|
+
- 2.1
|
7
|
+
- jruby-19mode
|
8
|
+
- jruby-19mode
|
9
|
+
- jruby-head
|
10
|
+
- rbx-2
|
11
|
+
- ruby-head
|
10
12
|
matrix:
|
11
13
|
allow_failures:
|
12
|
-
- rvm:
|
13
|
-
- rvm:
|
14
|
+
- rvm: jruby-head
|
15
|
+
- rvm: jruby-19mode
|
16
|
+
- rvm: rbx-2
|
17
|
+
- rvm: ruby-head
|
18
|
+
fash_finish: true
|
19
|
+
sudo: false
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
# TopHat [![Build Status](https://secure.travis-ci.org/
|
1
|
+
# TopHat [![Build Status](https://secure.travis-ci.org/stve/tophat.png?branch=master)][travis] [![Dependency Status](https://gemnasium.com/stve/tophat.png?travis)][gemnasium] [![Code Climate](https://codeclimate.com/github/stve/tophat.png)][codeclimate]
|
2
2
|
|
3
3
|
|
4
|
-
[travis]: http://travis-ci.org/
|
5
|
-
[gemnasium]: https://gemnasium.com/
|
6
|
-
[codeclimate]: https://codeclimate.com/github/
|
4
|
+
[travis]: http://travis-ci.org/stve/tophat
|
5
|
+
[gemnasium]: https://gemnasium.com/stve/tophat
|
6
|
+
[codeclimate]: https://codeclimate.com/github/stve/tophat
|
7
7
|
|
8
8
|
TopHat is a set of view helpers to keep your layouts and views DRY. Easily include meta tags like keywords and descriptions, Open Graph and Twitter Cards in your Rails views.
|
9
9
|
|
@@ -196,4 +196,4 @@ Pull requests welcome: fork, make a topic branch, commit (squash when possible)
|
|
196
196
|
|
197
197
|
## Copyright
|
198
198
|
|
199
|
-
Copyright (c)
|
199
|
+
Copyright (c) 2014 Steve Agalloco. See [LICENSE](https://github.com/stve/tophat/blob/master/LICENSE.md) for details.
|
data/lib/tophat/meta.rb
CHANGED
@@ -28,7 +28,7 @@ module TopHat
|
|
28
28
|
else
|
29
29
|
default_description = options.delete(:default)
|
30
30
|
options[:name] = 'description'
|
31
|
-
options[:content] = TopHat.current['description']
|
31
|
+
options[:content] = TopHat.current['description'].blank? ? default_description : TopHat.current['description']
|
32
32
|
|
33
33
|
meta_tag(options) if options[:content]
|
34
34
|
end
|
data/lib/tophat/robots.rb
CHANGED
@@ -3,25 +3,24 @@ module TopHat
|
|
3
3
|
|
4
4
|
DEFAULT_DESCRIPTOR = 'robots'
|
5
5
|
|
6
|
-
def noindex(descriptor=nil)
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
tag(:meta, :name => descriptor, :content => 'noindex')
|
6
|
+
def noindex(descriptor = nil, content = 'noindex')
|
7
|
+
robot_tag(descriptor, content)
|
8
|
+
end
|
9
|
+
|
10
|
+
def nofollow(descriptor = nil, content = 'nofollow')
|
11
|
+
robot_tag(descriptor, content)
|
13
12
|
end
|
14
13
|
|
15
|
-
def
|
14
|
+
def robot_tag(descriptor = nil, content)
|
16
15
|
if descriptor
|
17
|
-
TopHat.current[
|
16
|
+
TopHat.current[content] = descriptor || DEFAULT_DESCRIPTOR
|
18
17
|
else
|
19
|
-
descriptor = TopHat.current[
|
18
|
+
descriptor = TopHat.current[content] || DEFAULT_DESCRIPTOR
|
20
19
|
end
|
21
|
-
tag(:meta, :name => descriptor, :content =>
|
20
|
+
tag(:meta, :name => descriptor, :content => content)
|
22
21
|
end
|
23
22
|
|
24
|
-
def canonical(path=nil)
|
23
|
+
def canonical(path = nil)
|
25
24
|
tag(:link, :rel => 'canonical', :href => path) if path
|
26
25
|
end
|
27
26
|
|
data/lib/tophat/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -7,41 +7,41 @@ describe TopHat::HtmlHelper do
|
|
7
7
|
|
8
8
|
describe 'html_tag' do
|
9
9
|
it 'returns a simple tag by default' do
|
10
|
-
@template.html_tag.
|
10
|
+
expect(@template.html_tag).to eq('<html>')
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'accepts a version in an options hash' do
|
14
14
|
output = @template.html_tag(:version => '123')
|
15
|
-
output.
|
15
|
+
expect(output).to eq('<html version="123">')
|
16
16
|
end
|
17
17
|
|
18
18
|
context 'xmlns' do
|
19
19
|
it 'accepts xmlns passed as strings' do
|
20
20
|
output = @template.html_tag(:xmlns => 'http://someurl.com')
|
21
|
-
output.
|
21
|
+
expect(output).to eq('<html xmlns="http://someurl.com">')
|
22
22
|
end
|
23
23
|
|
24
24
|
it 'accepts xmlns passed as hashes' do
|
25
25
|
output = @template.html_tag(:xmlns => { :prefix => 'fb', :url => 'http://someurl.com' })
|
26
|
-
output.
|
26
|
+
expect(output).to eq('<html xmlns:fb="http://someurl.com">')
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'accepts xmlns passed as an array of hashes' do
|
30
30
|
xmlns = { :prefix => 'fb', :url => 'http://developers.facebook.com/schema/' }
|
31
31
|
output = @template.html_tag(:xmlns => [xmlns])
|
32
|
-
output.
|
32
|
+
expect(output).to eq('<html xmlns:fb="http://developers.facebook.com/schema/">')
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
36
|
context 'prefixes' do
|
37
37
|
it 'accepts prefixes passed as strings' do
|
38
38
|
output = @template.html_tag(:prefix => 'ohai')
|
39
|
-
output.
|
39
|
+
expect(output).to eq('<html prefix="ohai">')
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'accepts prefixes passed as a hash' do
|
43
43
|
output = @template.html_tag(:prefix => { :prefix => 'og', :url => 'http://ogp.me/ns#' })
|
44
|
-
output.
|
44
|
+
expect(output).to eq('<html prefix="og: http://ogp.me/ns#">')
|
45
45
|
end
|
46
46
|
|
47
47
|
it 'accepts prefixes passed as an array of hashes' do
|
@@ -50,12 +50,12 @@ describe TopHat::HtmlHelper do
|
|
50
50
|
{ :prefix => 'fb', :url => 'http://ogp.me/ns/fb#' }
|
51
51
|
]
|
52
52
|
output = @template.html_tag(:prefix => prefixes)
|
53
|
-
output.
|
53
|
+
expect(output).to eq('<html prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb#">')
|
54
54
|
end
|
55
55
|
|
56
56
|
it 'accepts prefixes passes and an array of strings' do
|
57
57
|
output = @template.html_tag(:prefix => ['og: http://ogp.me/ns#', 'fb: http://ogp.me/ns/fb#'])
|
58
|
-
output.
|
58
|
+
expect(output).to eq('<html prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb#">')
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
@@ -8,19 +8,19 @@ describe TopHat::MetaHelper do
|
|
8
8
|
|
9
9
|
describe "charset" do
|
10
10
|
it 'renders a meta tag with a charset' do
|
11
|
-
@template.charset('utf-8').
|
11
|
+
expect(@template.charset('utf-8')).to eq('<meta charset="utf-8">')
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
describe "viewport" do
|
16
16
|
it 'renders a meta tag with a viewport' do
|
17
|
-
@template.viewport('width=device-width').
|
17
|
+
expect(@template.viewport('width=device-width')).to eq('<meta content="width=device-width" name="viewport">')
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
21
|
describe "meta_tag" do
|
22
22
|
it 'renders meta_tags' do
|
23
|
-
@template.meta_tag(:charset => 'utf-8').
|
23
|
+
expect(@template.meta_tag(:charset => 'utf-8')).to eq('<meta charset="utf-8" />')
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -31,11 +31,11 @@ describe TopHat::MetaHelper do
|
|
31
31
|
end
|
32
32
|
|
33
33
|
it "saves keywords" do
|
34
|
-
@template.keywords(@keywords).
|
34
|
+
expect(@template.keywords(@keywords)).to eq(@keywords.join(', '))
|
35
35
|
end
|
36
36
|
|
37
37
|
it "uses default keywords if keywords is empty" do
|
38
|
-
@template.keywords(:default => @keywords).
|
38
|
+
expect(@template.keywords(:default => @keywords)).to eq("<meta content=\"#{@keywords.join(', ')}\" name=\"keywords\" />")
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
@@ -45,56 +45,61 @@ describe TopHat::MetaHelper do
|
|
45
45
|
end
|
46
46
|
|
47
47
|
it "saves keywords" do
|
48
|
-
@template.keywords(@keywords).
|
48
|
+
expect(@template.keywords(@keywords)).to eq(@keywords)
|
49
49
|
end
|
50
50
|
|
51
51
|
it "uses default keywords passed as a string if keywords is empty" do
|
52
|
-
@template.keywords(:default => @keywords).
|
52
|
+
expect(@template.keywords(:default => @keywords)).to eq("<meta content=\"#{@keywords}\" name=\"keywords\" />")
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
56
|
it "return nil when no default is configured and no keywords are defined" do
|
57
|
-
@template.keywords.
|
57
|
+
expect(@template.keywords).to be_nil
|
58
58
|
end
|
59
59
|
|
60
60
|
it "returns nil when passed nil" do
|
61
|
-
@template.keywords(nil).
|
61
|
+
expect(@template.keywords(nil)).to be_nil
|
62
62
|
end
|
63
63
|
|
64
64
|
it "merges default tags with page tags, when merge_default is set to true" do
|
65
65
|
@template.keywords("Stu, Pete")
|
66
|
-
@template.keywords(:default => "John, Paul, George, Ringo", :merge_default => true).
|
66
|
+
expect(@template.keywords(:default => "John, Paul, George, Ringo", :merge_default => true)).to eq("<meta content=\"Stu, Pete, John, Paul, George, Ringo\" name=\"keywords\" />")
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
70
|
describe ".description" do
|
71
71
|
it "saves the description" do
|
72
72
|
desc = "Cinderella story. Outta nowhere. A former greenskeeper, now, about to become the Masters champion."
|
73
|
-
@template.description(desc).
|
73
|
+
expect(@template.description(desc)).to eq(desc)
|
74
74
|
end
|
75
75
|
|
76
76
|
it "uses the default description if no description is defined" do
|
77
77
|
desc = "A flute without holes, is not a flute. A donut without a hole, is a Danish."
|
78
|
-
@template.description(:default => desc).
|
78
|
+
expect(@template.description(:default => desc)).to eq("<meta content=\"#{desc}\" name=\"description\" />")
|
79
79
|
end
|
80
80
|
|
81
81
|
it "returns nil when passed nil" do
|
82
|
-
@template.description(nil).
|
82
|
+
expect(@template.description(nil)).to be_nil
|
83
83
|
end
|
84
84
|
|
85
85
|
it "returns nil when no default is configured and no description is defined" do
|
86
|
-
@template.description.
|
86
|
+
expect(@template.description).to be_nil
|
87
87
|
end
|
88
88
|
|
89
89
|
it 'overrides the default' do
|
90
90
|
@template.description('This is a custom description')
|
91
|
-
@template.description(:default => 'This is a default description.').
|
91
|
+
expect(@template.description(:default => 'This is a default description.')).to eq('<meta content="This is a custom description" name="description" />')
|
92
92
|
end
|
93
|
+
|
94
|
+
it "uses the default description if custom description is blank" do
|
95
|
+
@template.description('')
|
96
|
+
expect(@template.description(:default => 'This is a default description')).to eq('<meta content="This is a default description" name="description" />')
|
97
|
+
end
|
93
98
|
end
|
94
99
|
|
95
100
|
describe ".itemprop" do
|
96
101
|
it "renders an itemprop meta tag" do
|
97
|
-
@template.itemprop(:rating, '1').
|
102
|
+
expect(@template.itemprop(:rating, '1')).to eq("<meta content=\"1\" itemprop=\"rating\" />")
|
98
103
|
end
|
99
104
|
end
|
100
105
|
|
@@ -14,29 +14,39 @@ describe TopHat::OpenGraphHelper do
|
|
14
14
|
context 'default style' do
|
15
15
|
it 'renders an html tag with namespace' do
|
16
16
|
output = @template.opengraph_html
|
17
|
-
output.
|
18
|
-
output.
|
19
|
-
output.
|
17
|
+
expect(output).to match(/<html/)
|
18
|
+
expect(output).to match(/xmlns\:og/)
|
19
|
+
expect(output).to match(/xmlns\:fb/)
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
23
|
context 'html5 style' do
|
24
24
|
it 'renders an html tag with namespace' do
|
25
25
|
output = @template.opengraph_html('html5')
|
26
|
-
output.
|
27
|
-
output.
|
28
|
-
output.
|
26
|
+
expect(output).to match(/<html/)
|
27
|
+
expect(output).to match(/xmlns\:og/)
|
28
|
+
expect(output).to match(/xmlns\:fb/)
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
32
|
context 'unknown style' do
|
33
33
|
it 'returns an empty html tag' do
|
34
|
-
@template.opengraph_html('funny').
|
34
|
+
expect(@template.opengraph_html('funny')).to eq('<html>')
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'it supports deprecated html_with_opengraph' do
|
39
|
-
|
39
|
+
capture_warning do
|
40
|
+
expect(@template.opengraph_html).to eq(@template.html_with_opengraph)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'deprecates html_with_opengraph' do
|
45
|
+
warning = capture_warning do
|
46
|
+
@template.html_with_opengraph
|
47
|
+
end
|
48
|
+
|
49
|
+
expect(warning).to eq("html_with_opengraph has been deprecated, use opengraph_html instead.\n")
|
40
50
|
end
|
41
51
|
end
|
42
52
|
|
@@ -44,14 +54,14 @@ describe TopHat::OpenGraphHelper do
|
|
44
54
|
context "as a string" do
|
45
55
|
it "generates a site admin tag" do
|
46
56
|
@template.opengraph(:admins => '123,124')
|
47
|
-
@template.opengraph.
|
57
|
+
expect(@template.opengraph).to include('<meta content="123,124" property="fb:admins" />')
|
48
58
|
end
|
49
59
|
end
|
50
60
|
|
51
61
|
context "as an array" do
|
52
62
|
it "generates a site admin tag" do
|
53
63
|
@template.opengraph(:admins => [123, 124])
|
54
|
-
@template.opengraph.
|
64
|
+
expect(@template.opengraph).to include('<meta content="123,124" property="fb:admins" />')
|
55
65
|
end
|
56
66
|
end
|
57
67
|
end
|
@@ -59,19 +69,19 @@ describe TopHat::OpenGraphHelper do
|
|
59
69
|
context "app_id when configured" do
|
60
70
|
it "generates an app_id meta tag" do
|
61
71
|
@template.opengraph(:app_id => 'MyApp')
|
62
|
-
@template.opengraph.
|
72
|
+
expect(@template.opengraph).to include('<meta content="MyApp" property="fb:app_id" />')
|
63
73
|
end
|
64
74
|
end
|
65
75
|
|
66
76
|
context "additional open graph properties" do
|
67
77
|
it "generates opengraph meta tags" do
|
68
78
|
@template.opengraph { |og| og.title 'The Great Gatsby' }
|
69
|
-
@template.opengraph.
|
79
|
+
expect(@template.opengraph).to include('<meta content="The Great Gatsby" property="og:title" />')
|
70
80
|
end
|
71
81
|
|
72
82
|
it "allows use of the tag 'type'" do
|
73
83
|
@template.opengraph { |og| og.type 'sports_team' }
|
74
|
-
@template.opengraph.
|
84
|
+
expect(@template.opengraph).to include('<meta content="sports_team" property="og:type" />')
|
75
85
|
end
|
76
86
|
|
77
87
|
it "supports multiple tags" do
|
@@ -81,8 +91,8 @@ describe TopHat::OpenGraphHelper do
|
|
81
91
|
end
|
82
92
|
output = @template.opengraph
|
83
93
|
|
84
|
-
output.
|
85
|
-
output.
|
94
|
+
expect(output).to include('<meta content="movie" property="og:type" />')
|
95
|
+
expect(output).to include('<meta content="Austin Powers: International Man of Mystery" property="og:title" />')
|
86
96
|
end
|
87
97
|
|
88
98
|
it 'supports default tags' do
|
@@ -94,9 +104,9 @@ describe TopHat::OpenGraphHelper do
|
|
94
104
|
og.rating '5/10'
|
95
105
|
end
|
96
106
|
|
97
|
-
output.
|
98
|
-
output.
|
99
|
-
output.
|
107
|
+
expect(output).to include('<meta content="movie" property="og:type" />')
|
108
|
+
expect(output).to include('<meta content="Rain Man" property="og:title" />')
|
109
|
+
expect(output).to include('<meta content="5/10" property="og:rating" />')
|
100
110
|
end
|
101
111
|
end
|
102
112
|
|
@@ -108,10 +118,10 @@ describe TopHat::OpenGraphHelper do
|
|
108
118
|
end
|
109
119
|
output = @template.opengraph
|
110
120
|
|
111
|
-
output.
|
112
|
-
output.
|
113
|
-
output.
|
114
|
-
output.
|
121
|
+
expect(output).to include('<meta content="MyApp" property="fb:app_id" />')
|
122
|
+
expect(output).to include('<meta content="123,1234" property="fb:admins" />')
|
123
|
+
expect(output).to include('<meta content="movie" property="og:type" />')
|
124
|
+
expect(output).to include('<meta content="Rain Man" property="og:title" />')
|
115
125
|
end
|
116
126
|
|
117
127
|
it "generates all tags when app_id and admins passed as part of rendering" do
|
@@ -121,10 +131,10 @@ describe TopHat::OpenGraphHelper do
|
|
121
131
|
end
|
122
132
|
output = @template.opengraph(:app_id => 'MyApp', :admins => [123, 1234])
|
123
133
|
|
124
|
-
output.
|
125
|
-
output.
|
126
|
-
output.
|
127
|
-
output.
|
134
|
+
expect(output).to include('<meta content="MyApp" property="fb:app_id" />')
|
135
|
+
expect(output).to include('<meta content="123,1234" property="fb:admins" />')
|
136
|
+
expect(output).to include('<meta content="movie" property="og:type" />')
|
137
|
+
expect(output).to include('<meta content="Rain Man" property="og:title" />')
|
128
138
|
end
|
129
139
|
|
130
140
|
it 'supports default tags' do
|
@@ -136,11 +146,11 @@ describe TopHat::OpenGraphHelper do
|
|
136
146
|
og.rating '5/10'
|
137
147
|
end
|
138
148
|
|
139
|
-
output.
|
140
|
-
output.
|
141
|
-
output.
|
142
|
-
output.
|
143
|
-
output.
|
149
|
+
expect(output).to include('<meta content="MyApp" property="fb:app_id" />')
|
150
|
+
expect(output).to include('<meta content="123,1234" property="fb:admins" />')
|
151
|
+
expect(output).to include('<meta content="movie" property="og:type" />')
|
152
|
+
expect(output).to include('<meta content="Rain Man" property="og:title" />')
|
153
|
+
expect(output).to include('<meta content="5/10" property="og:rating" />')
|
144
154
|
end
|
145
155
|
end
|
146
156
|
|
@@ -8,53 +8,53 @@ describe TopHat::RobotsHelper do
|
|
8
8
|
|
9
9
|
describe ".nofollow" do
|
10
10
|
it "defaults to all robots" do
|
11
|
-
@template.nofollow.
|
11
|
+
expect(@template.nofollow).to eq("<meta content=\"nofollow\" name=\"robots\" />")
|
12
12
|
end
|
13
13
|
|
14
14
|
it "uses a descriptor if one is provided" do
|
15
|
-
@template.nofollow('googlebot').
|
15
|
+
expect(@template.nofollow('googlebot')).to eq("<meta content=\"nofollow\" name=\"googlebot\" />")
|
16
16
|
end
|
17
17
|
|
18
18
|
it "generates a default tag when passed nil" do
|
19
|
-
@template.nofollow(nil).
|
19
|
+
expect(@template.nofollow(nil)).to eq("<meta content=\"nofollow\" name=\"robots\" />")
|
20
20
|
end
|
21
21
|
|
22
22
|
it 'stores a descriptor' do
|
23
23
|
@template.nofollow('twitterbot')
|
24
|
-
@template.nofollow.
|
24
|
+
expect(@template.nofollow).to eq("<meta content=\"nofollow\" name=\"twitterbot\" />")
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
describe ".noindex" do
|
29
29
|
it "defaults to all robots" do
|
30
|
-
@template.noindex.
|
30
|
+
expect(@template.noindex).to eq("<meta content=\"noindex\" name=\"robots\" />")
|
31
31
|
end
|
32
32
|
|
33
33
|
it "uses a descriptor if one is provided" do
|
34
|
-
@template.noindex('googlebot').
|
34
|
+
expect(@template.noindex('googlebot')).to eq("<meta content=\"noindex\" name=\"googlebot\" />")
|
35
35
|
end
|
36
36
|
|
37
37
|
it "generates a default tag when passed nil" do
|
38
|
-
@template.noindex(nil).
|
38
|
+
expect(@template.noindex(nil)).to eq("<meta content=\"noindex\" name=\"robots\" />")
|
39
39
|
end
|
40
40
|
|
41
41
|
it 'stores a descriptor' do
|
42
42
|
@template.noindex('twitterbot')
|
43
|
-
@template.noindex.
|
43
|
+
expect(@template.noindex).to eq("<meta content=\"noindex\" name=\"twitterbot\" />")
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
47
|
describe ".canonical" do
|
48
48
|
it "returns nil when not passed a path" do
|
49
|
-
@template.canonical.
|
49
|
+
expect(@template.canonical).to be_nil
|
50
50
|
end
|
51
51
|
|
52
52
|
it "renders a tag when passed a path" do
|
53
|
-
@template.canonical('http://mysite.com/somepath/').
|
53
|
+
expect(@template.canonical('http://mysite.com/somepath/')).to eq("<link href=\"http://mysite.com/somepath/\" rel=\"canonical\" />")
|
54
54
|
end
|
55
55
|
|
56
56
|
it "returns nil when passed nil" do
|
57
|
-
@template.canonical(nil).
|
57
|
+
expect(@template.canonical(nil)).to be_nil
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
@@ -17,131 +17,131 @@ describe TopHat::StylesheetHelper do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
it "defines IE conditionals" do
|
20
|
-
@template.ie_5_conditional {
|
20
|
+
expect(@template.ie_5_conditional {
|
21
21
|
@template.stylesheet_link_tag(@stylesheet)
|
22
|
-
}.
|
22
|
+
}).to eq("<!--[if IE 5]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->")
|
23
23
|
|
24
|
-
@template.ie_5_5_conditional {
|
24
|
+
expect(@template.ie_5_5_conditional {
|
25
25
|
@template.stylesheet_link_tag(@stylesheet)
|
26
|
-
}.
|
26
|
+
}).to eq("<!--[if IE 5.5]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->")
|
27
27
|
|
28
|
-
@template.ie_6_conditional {
|
28
|
+
expect(@template.ie_6_conditional {
|
29
29
|
@template.stylesheet_link_tag(@stylesheet)
|
30
|
-
}.
|
30
|
+
}).to eq("<!--[if IE 6]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->")
|
31
31
|
|
32
|
-
@template.ie_7_conditional {
|
32
|
+
expect(@template.ie_7_conditional {
|
33
33
|
@template.stylesheet_link_tag(@stylesheet)
|
34
|
-
}.
|
34
|
+
}).to eq("<!--[if IE 7]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->")
|
35
35
|
|
36
|
-
@template.ie_8_conditional {
|
36
|
+
expect(@template.ie_8_conditional {
|
37
37
|
@template.stylesheet_link_tag(@stylesheet)
|
38
|
-
}.
|
38
|
+
}).to eq("<!--[if IE 8]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->")
|
39
39
|
|
40
|
-
@template.ie_9_conditional {
|
40
|
+
expect(@template.ie_9_conditional {
|
41
41
|
@template.stylesheet_link_tag(@stylesheet)
|
42
|
-
}.
|
42
|
+
}).to eq("<!--[if IE 9]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->")
|
43
43
|
end
|
44
44
|
|
45
45
|
it "renders defined IE conditional with greater than operator" do
|
46
|
-
@template.ie_5_conditional(:gt) {
|
46
|
+
expect(@template.ie_5_conditional(:gt) {
|
47
47
|
@template.stylesheet_link_tag(@stylesheet)
|
48
|
-
}.
|
48
|
+
}).to eq("<!--[if gt IE 5]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->")
|
49
49
|
|
50
|
-
@template.ie_5_5_conditional(:gt) {
|
50
|
+
expect(@template.ie_5_5_conditional(:gt) {
|
51
51
|
@template.stylesheet_link_tag(@stylesheet)
|
52
|
-
}.
|
52
|
+
}).to eq("<!--[if gt IE 5.5]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->")
|
53
53
|
end
|
54
54
|
|
55
55
|
it "renders defined IE conditional with greater than or equal to operator" do
|
56
|
-
@template.ie_5_conditional(:gte) {
|
56
|
+
expect(@template.ie_5_conditional(:gte) {
|
57
57
|
@template.stylesheet_link_tag(@stylesheet)
|
58
|
-
}.
|
58
|
+
}).to eq("<!--[if gte IE 5]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->")
|
59
59
|
|
60
|
-
@template.ie_5_5_conditional(:gte) {
|
60
|
+
expect(@template.ie_5_5_conditional(:gte) {
|
61
61
|
@template.stylesheet_link_tag(@stylesheet)
|
62
|
-
}.
|
62
|
+
}).to eq("<!--[if gte IE 5.5]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->")
|
63
63
|
end
|
64
64
|
|
65
65
|
it "renders defined IE conditional with ! operator" do
|
66
|
-
@template.ie_5_conditional(:not) {
|
66
|
+
expect(@template.ie_5_conditional(:not) {
|
67
67
|
@template.stylesheet_link_tag(@stylesheet)
|
68
|
-
}.
|
68
|
+
}).to eq("<!--[if !IE 5]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->")
|
69
69
|
|
70
|
-
@template.ie_5_5_conditional(:not) {
|
70
|
+
expect(@template.ie_5_5_conditional(:not) {
|
71
71
|
@template.stylesheet_link_tag(@stylesheet)
|
72
|
-
}.
|
72
|
+
}).to eq("<!--[if !IE 5.5]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->")
|
73
73
|
end
|
74
74
|
|
75
75
|
it "renders defined IE conditional with less than operator" do
|
76
|
-
@template.ie_5_conditional(:lt) {
|
76
|
+
expect(@template.ie_5_conditional(:lt) {
|
77
77
|
@template.stylesheet_link_tag(@stylesheet)
|
78
|
-
}.
|
78
|
+
}).to eq("<!--[if lt IE 5]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->")
|
79
79
|
|
80
|
-
@template.ie_5_5_conditional(:lt) {
|
80
|
+
expect(@template.ie_5_5_conditional(:lt) {
|
81
81
|
@template.stylesheet_link_tag(@stylesheet)
|
82
|
-
}.
|
82
|
+
}).to eq("<!--[if lt IE 5.5]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->")
|
83
83
|
end
|
84
84
|
|
85
85
|
it "renders defined IE conditional with less than or equal to operator" do
|
86
|
-
@template.ie_5_conditional(:lte) {
|
86
|
+
expect(@template.ie_5_conditional(:lte) {
|
87
87
|
@template.stylesheet_link_tag(@stylesheet)
|
88
|
-
}.
|
88
|
+
}).to eq("<!--[if lte IE 5]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->")
|
89
89
|
|
90
|
-
@template.ie_5_5_conditional(:lte) {
|
90
|
+
expect(@template.ie_5_5_conditional(:lte) {
|
91
91
|
@template.stylesheet_link_tag(@stylesheet)
|
92
|
-
}.
|
92
|
+
}).to eq("<!--[if lte IE 5.5]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->")
|
93
93
|
end
|
94
94
|
|
95
95
|
it "renders defined IE conditional with equal to operator" do
|
96
|
-
@template.ie_5_conditional(:eq) {
|
96
|
+
expect(@template.ie_5_conditional(:eq) {
|
97
97
|
@template.stylesheet_link_tag(@stylesheet)
|
98
|
-
}.
|
98
|
+
}).to eq("<!--[if eq IE 5]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->")
|
99
99
|
|
100
|
-
@template.ie_5_5_conditional(:eq) {
|
100
|
+
expect(@template.ie_5_5_conditional(:eq) {
|
101
101
|
@template.stylesheet_link_tag(@stylesheet)
|
102
|
-
}.
|
102
|
+
}).to eq("<!--[if eq IE 5.5]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->")
|
103
103
|
end
|
104
104
|
|
105
105
|
it "renders defined conditionals for other browsers" do
|
106
|
-
@template.opera_conditional {
|
106
|
+
expect(@template.opera_conditional {
|
107
107
|
@template.stylesheet_link_tag(@stylesheet)
|
108
|
-
}.
|
108
|
+
}).to eq("<!--[if Opera]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->")
|
109
109
|
|
110
|
-
@template.webkit_conditional {
|
110
|
+
expect(@template.webkit_conditional {
|
111
111
|
@template.stylesheet_link_tag(@stylesheet)
|
112
|
-
}.
|
112
|
+
}).to eq("<!--[if Webkit]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->")
|
113
113
|
|
114
|
-
@template.webkit_conditional(:eq) {
|
114
|
+
expect(@template.webkit_conditional(:eq) {
|
115
115
|
@template.stylesheet_link_tag(@stylesheet)
|
116
|
-
}.
|
116
|
+
}).to eq("<!--[if eq Webkit]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->")
|
117
117
|
|
118
|
-
@template.gecko_conditional {
|
118
|
+
expect(@template.gecko_conditional {
|
119
119
|
@template.stylesheet_link_tag(@stylesheet)
|
120
|
-
}.
|
120
|
+
}).to eq("<!--[if Gecko]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->")
|
121
121
|
|
122
|
-
@template.ie_mac_conditional {
|
122
|
+
expect(@template.ie_mac_conditional {
|
123
123
|
@template.stylesheet_link_tag(@stylesheet)
|
124
|
-
}.
|
124
|
+
}).to eq("<!--[if IEMac]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->")
|
125
125
|
|
126
|
-
@template.konqueror_conditional {
|
126
|
+
expect(@template.konqueror_conditional {
|
127
127
|
@template.stylesheet_link_tag(@stylesheet)
|
128
|
-
}.
|
128
|
+
}).to eq("<!--[if Konq]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->")
|
129
129
|
|
130
|
-
@template.ie_mobile_conditional {
|
130
|
+
expect(@template.ie_mobile_conditional {
|
131
131
|
@template.stylesheet_link_tag(@stylesheet)
|
132
|
-
}.
|
132
|
+
}).to eq("<!--[if IEmob]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->")
|
133
133
|
|
134
|
-
@template.psp_conditional {
|
134
|
+
expect(@template.psp_conditional {
|
135
135
|
@template.stylesheet_link_tag(@stylesheet)
|
136
|
-
}.
|
136
|
+
}).to eq("<!--[if PSP]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->")
|
137
137
|
|
138
|
-
@template.net_front_conditional {
|
138
|
+
expect(@template.net_front_conditional {
|
139
139
|
@template.stylesheet_link_tag(@stylesheet)
|
140
|
-
}.
|
140
|
+
}).to eq("<!--[if NetF]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->")
|
141
141
|
|
142
|
-
@template.mobile_safari_conditional {
|
142
|
+
expect(@template.mobile_safari_conditional {
|
143
143
|
@template.stylesheet_link_tag(@stylesheet)
|
144
|
-
}.
|
144
|
+
}).to eq("<!--[if SafMob]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->")
|
145
145
|
|
146
146
|
end
|
147
147
|
|
@@ -8,90 +8,90 @@ describe TopHat::TitleHelper do
|
|
8
8
|
|
9
9
|
context "saving a title" do
|
10
10
|
it "saves the title" do
|
11
|
-
@template.title('Kind of Blue').
|
11
|
+
expect(@template.title('Kind of Blue')).to eq('Kind of Blue')
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
context "displaying a title" do
|
16
16
|
it "uses the website name if title is empty" do
|
17
|
-
@template.title(:site => "Miles Davis").
|
17
|
+
expect(@template.title(:site => "Miles Davis")).to eq("<title>Miles Davis</title>")
|
18
18
|
end
|
19
19
|
|
20
20
|
it "displays the title if no website was specified" do
|
21
21
|
save_basic_title
|
22
|
-
@template.title().
|
22
|
+
expect(@template.title()).to eq('<title>Kind of Blue</title>')
|
23
23
|
end
|
24
24
|
|
25
25
|
it "uses website before page by default" do
|
26
26
|
save_basic_title
|
27
|
-
@template.title(:site => "Miles Davis", :separator => '|').
|
27
|
+
expect(@template.title(:site => "Miles Davis", :separator => '|')).to eq("<title>Miles Davis | Kind of Blue</title>")
|
28
28
|
end
|
29
29
|
|
30
30
|
it "only uses markup in titles in the view" do
|
31
|
-
save_basic_title("<b>Kind of Blue</b>").
|
32
|
-
@template.title(:site => "Miles Davis", :separator => '|').
|
31
|
+
expect(save_basic_title("<b>Kind of Blue</b>")).to eq("<b>Kind of Blue</b>")
|
32
|
+
expect(@template.title(:site => "Miles Davis", :separator => '|')).to eq("<title>Miles Davis | Kind of Blue</title>")
|
33
33
|
end
|
34
34
|
|
35
35
|
it "uses page before website if :reverse" do
|
36
36
|
save_basic_title
|
37
|
-
@template.title(:site => "Miles Davis", :reverse => true, :separator => '|').
|
37
|
+
expect(@template.title(:site => "Miles Davis", :reverse => true, :separator => '|')).to eq("<title>Kind of Blue | Miles Davis</title>")
|
38
38
|
end
|
39
39
|
|
40
40
|
it "uses website before page if :reverse and :reverse_on_default" do
|
41
|
-
@template.title(:site => "John Coltrane", :default => "My Favorite Things", :reverse => true, :reverse_on_default => false, :separator => '|').
|
41
|
+
expect(@template.title(:site => "John Coltrane", :default => "My Favorite Things", :reverse => true, :reverse_on_default => false, :separator => '|')).to eq("<title>John Coltrane | My Favorite Things</title>")
|
42
42
|
end
|
43
43
|
|
44
44
|
it "lowercases the title if :lowercase" do
|
45
45
|
save_basic_title
|
46
|
-
@template.title(:site => "Miles Davis", :lowercase => true, :separator => '|').
|
46
|
+
expect(@template.title(:site => "Miles Davis", :lowercase => true, :separator => '|')).to eq("<title>miles davis | kind of blue</title>")
|
47
47
|
end
|
48
48
|
|
49
49
|
it "uppercases the title if :uppercase" do
|
50
50
|
save_basic_title
|
51
|
-
@template.title(:site => "Miles Davis", :uppercase => true, :separator => '|').
|
51
|
+
expect(@template.title(:site => "Miles Davis", :uppercase => true, :separator => '|')).to eq("<title>MILES DAVIS | KIND OF BLUE</title>")
|
52
52
|
end
|
53
53
|
|
54
54
|
it "uses a custom separator if :separator" do
|
55
55
|
save_basic_title
|
56
|
-
@template.title(:site => "Miles Davis", :separator => "-").
|
57
|
-
@template.title(:site => "Miles Davis", :separator => ":").
|
58
|
-
@template.title(:site => "Miles Davis", :separator => "—").
|
56
|
+
expect(@template.title(:site => "Miles Davis", :separator => "-")).to eq("<title>Miles Davis - Kind of Blue</title>")
|
57
|
+
expect(@template.title(:site => "Miles Davis", :separator => ":")).to eq("<title>Miles Davis : Kind of Blue</title>")
|
58
|
+
expect(@template.title(:site => "Miles Davis", :separator => "—")).to eq("<title>Miles Davis &mdash; Kind of Blue</title>")
|
59
59
|
end
|
60
60
|
|
61
61
|
it "uses custom prefix and suffix if available" do
|
62
62
|
save_basic_title
|
63
|
-
@template.title(:site => "Miles Davis", :prefix => " |", :suffix => "| ", :separator => '|').
|
63
|
+
expect(@template.title(:site => "Miles Davis", :prefix => " |", :suffix => "| ", :separator => '|')).to eq("<title>Miles Davis ||| Kind of Blue</title>")
|
64
64
|
end
|
65
65
|
|
66
66
|
it "collapses prefix if false" do
|
67
67
|
save_basic_title
|
68
|
-
@template.title(:site => "Miles Davis", :prefix => false, :separator => ":").
|
68
|
+
expect(@template.title(:site => "Miles Davis", :prefix => false, :separator => ":")).to eq("<title>Miles Davis: Kind of Blue</title>")
|
69
69
|
end
|
70
70
|
|
71
71
|
it "collapses suffix if false" do
|
72
72
|
save_basic_title
|
73
|
-
@template.title(:site => "Miles Davis", :suffix => false, :separator => "~").
|
73
|
+
expect(@template.title(:site => "Miles Davis", :suffix => false, :separator => "~")).to eq("<title>Miles Davis ~Kind of Blue</title>")
|
74
74
|
end
|
75
75
|
|
76
76
|
it "uses all custom options if available" do
|
77
77
|
save_basic_title
|
78
78
|
custom_options = { :site => "Miles Davis", :prefix => " ", :suffix => " ", :separator => "-", :lowercase => true, :reverse => true }
|
79
|
-
@template.title(custom_options).
|
79
|
+
expect(@template.title(custom_options)).to eq("<title>kind of blue - miles davis</title>")
|
80
80
|
end
|
81
81
|
|
82
82
|
it "uses the default title if title is not present or blank" do
|
83
83
|
save_basic_title("")
|
84
|
-
@template.title(:site => "Miles Davis", :default => "Round About Midnight", :separator => '|').
|
84
|
+
expect(@template.title(:site => "Miles Davis", :default => "Round About Midnight", :separator => '|')).to eq("<title>Miles Davis | Round About Midnight</title>")
|
85
85
|
end
|
86
86
|
|
87
87
|
it "allows custom options per title" do
|
88
88
|
save_custom_title
|
89
|
-
@template.title(:site => "Freddie Freeloader", :separator => '|').
|
89
|
+
expect(@template.title(:site => "Freddie Freeloader", :separator => '|')).to eq("<title>Kind of Blue | Freddie Freeloader</title>")
|
90
90
|
end
|
91
91
|
|
92
92
|
it "accepts an array of strings as the title" do
|
93
93
|
@template.title(['My', 'Favorite', 'Things'])
|
94
|
-
@template.title(:site => "Freddie Freeloader", :separator => '|').
|
94
|
+
expect(@template.title(:site => "Freddie Freeloader", :separator => '|')).to eq("<title>Freddie Freeloader | My | Favorite | Things</title>")
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
@@ -16,7 +16,7 @@ describe TopHat::TwitterCardHelper do
|
|
16
16
|
@template.twitter_card('summary')
|
17
17
|
|
18
18
|
output = @template.twitter_card
|
19
|
-
output.
|
19
|
+
expect(output).to eq('<meta name="twitter:card" value="summary" />')
|
20
20
|
end
|
21
21
|
|
22
22
|
it 'generates twitter:card meta tags' do
|
@@ -28,8 +28,8 @@ describe TopHat::TwitterCardHelper do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
output = @template.twitter_card
|
31
|
-
output.
|
32
|
-
output.
|
31
|
+
expect(output).to include('<meta name="twitter:title" value="Rain Man" />')
|
32
|
+
expect(output).to include('<meta name="twitter:image" value="http://someurl.com/animage.jpg" />')
|
33
33
|
end
|
34
34
|
|
35
35
|
it 'generates nested twitter:card meta tags' do
|
@@ -41,9 +41,9 @@ describe TopHat::TwitterCardHelper do
|
|
41
41
|
end
|
42
42
|
|
43
43
|
output = @template.twitter_card
|
44
|
-
output.
|
45
|
-
output.
|
46
|
-
output.
|
44
|
+
expect(output).to include('<meta name="twitter:image" value="http://someurl.com/animage.jpg" />')
|
45
|
+
expect(output).to include('<meta name="twitter:image:height" value="123" />')
|
46
|
+
expect(output).to include('<meta name="twitter:image:width" value="456" />')
|
47
47
|
end
|
48
48
|
|
49
49
|
|
@@ -57,8 +57,8 @@ describe TopHat::TwitterCardHelper do
|
|
57
57
|
end
|
58
58
|
|
59
59
|
output = @template.twitter_card
|
60
|
-
output.
|
61
|
-
output.
|
60
|
+
expect(output).to include('<meta name="twitter:player:stream" value="http://example.com/raw-stream/a.mp4" />')
|
61
|
+
expect(output).to include('<meta name="twitter:player:stream:content_type" value="123" />')
|
62
62
|
end
|
63
63
|
|
64
64
|
it 'supports default tags' do
|
@@ -73,9 +73,9 @@ describe TopHat::TwitterCardHelper do
|
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
76
|
-
output.
|
77
|
-
output.
|
78
|
-
output.
|
76
|
+
expect(output).to include('<meta name="twitter:player:embed" value="https://example.com/embed/a" />')
|
77
|
+
expect(output).to include('<meta name="twitter:player:site" value="https://example.com" />')
|
78
|
+
expect(output).not_to include('<meta name="twitter:embed" value="https://example.com/embed/a" />')
|
79
79
|
end
|
80
80
|
|
81
81
|
end
|
data/spec/tophat_spec.rb
CHANGED
@@ -7,84 +7,84 @@ describe TopHat do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
it "is mixed into ActionView::Base" do
|
10
|
-
ActionView::Base.included_modules.include?(TopHat::TitleHelper).
|
11
|
-
ActionView::Base.included_modules.include?(TopHat::MetaHelper).
|
12
|
-
ActionView::Base.included_modules.include?(TopHat::StylesheetHelper).
|
10
|
+
expect(ActionView::Base.included_modules.include?(TopHat::TitleHelper)).to be_truthy
|
11
|
+
expect(ActionView::Base.included_modules.include?(TopHat::MetaHelper)).to be_truthy
|
12
|
+
expect(ActionView::Base.included_modules.include?(TopHat::StylesheetHelper)).to be_truthy
|
13
13
|
end
|
14
14
|
|
15
15
|
it "responds to the 'title' helper" do
|
16
|
-
@template.respond_to?(:title).
|
16
|
+
expect(@template.respond_to?(:title)).to be_truthy
|
17
17
|
end
|
18
18
|
|
19
19
|
it "responds to the 'title' helper alias" do
|
20
|
-
@template.respond_to?(:t).
|
20
|
+
expect(@template.respond_to?(:t)).to be_truthy
|
21
21
|
end
|
22
22
|
|
23
23
|
it "responds to the 'description' helper" do
|
24
|
-
@template.respond_to?(:description).
|
24
|
+
expect(@template.respond_to?(:description)).to be_truthy
|
25
25
|
end
|
26
26
|
|
27
27
|
it "responds to the 'keywords' helper" do
|
28
|
-
@template.respond_to?(:keywords).
|
28
|
+
expect(@template.respond_to?(:keywords)).to be_truthy
|
29
29
|
end
|
30
30
|
|
31
31
|
it "responds to the 'ie_5_conditional' helper" do
|
32
|
-
@template.respond_to?(:ie_5_conditional).
|
32
|
+
expect(@template.respond_to?(:ie_5_conditional)).to be_truthy
|
33
33
|
end
|
34
34
|
|
35
35
|
it "responds to the 'ie_5_5_conditional' helper" do
|
36
|
-
@template.respond_to?(:ie_5_5_conditional).
|
36
|
+
expect(@template.respond_to?(:ie_5_5_conditional)).to be_truthy
|
37
37
|
end
|
38
38
|
|
39
39
|
it "responds to the 'ie_6_conditional' helper" do
|
40
|
-
@template.respond_to?(:ie_6_conditional).
|
40
|
+
expect(@template.respond_to?(:ie_6_conditional)).to be_truthy
|
41
41
|
end
|
42
42
|
|
43
43
|
it "responds to the 'ie_7_conditional' helper" do
|
44
|
-
@template.respond_to?(:ie_7_conditional).
|
44
|
+
expect(@template.respond_to?(:ie_7_conditional)).to be_truthy
|
45
45
|
end
|
46
46
|
|
47
47
|
it "responds to the 'ie_8_conditional' helper" do
|
48
|
-
@template.respond_to?(:ie_8_conditional).
|
48
|
+
expect(@template.respond_to?(:ie_8_conditional)).to be_truthy
|
49
49
|
end
|
50
50
|
|
51
51
|
it "responds to the 'ie_9_conditional' helper" do
|
52
|
-
@template.respond_to?(:ie_9_conditional).
|
52
|
+
expect(@template.respond_to?(:ie_9_conditional)).to be_truthy
|
53
53
|
end
|
54
54
|
|
55
55
|
it "responds to the 'opengraph' helper" do
|
56
|
-
@template.respond_to?(:opengraph).
|
56
|
+
expect(@template.respond_to?(:opengraph)).to be_truthy
|
57
57
|
end
|
58
58
|
|
59
59
|
it "responds to the 'noindex' helper" do
|
60
|
-
@template.respond_to?(:noindex).
|
60
|
+
expect(@template.respond_to?(:noindex)).to be_truthy
|
61
61
|
end
|
62
62
|
|
63
63
|
it "responds to the 'nofollow' helper" do
|
64
|
-
@template.respond_to?(:nofollow).
|
64
|
+
expect(@template.respond_to?(:nofollow)).to be_truthy
|
65
65
|
end
|
66
66
|
|
67
67
|
it "responds to the 'canonical' helper" do
|
68
|
-
@template.respond_to?(:canonical).
|
68
|
+
expect(@template.respond_to?(:canonical)).to be_truthy
|
69
69
|
end
|
70
70
|
|
71
71
|
it "responds to the 'twitter_card' helper" do
|
72
|
-
@template.respond_to?(:twitter_card).
|
72
|
+
expect(@template.respond_to?(:twitter_card)).to be_truthy
|
73
73
|
end
|
74
74
|
|
75
75
|
it "responds to the 'html_tag' helper" do
|
76
|
-
@template.respond_to?(:html_tag).
|
76
|
+
expect(@template.respond_to?(:html_tag)).to be_truthy
|
77
77
|
end
|
78
78
|
|
79
79
|
describe '.current' do
|
80
80
|
it 'returns a hash' do
|
81
|
-
TopHat.current.
|
81
|
+
expect(TopHat.current).to be_kind_of(Hash)
|
82
82
|
end
|
83
83
|
|
84
84
|
it 'allows the hash to be modified' do
|
85
85
|
TopHat.current[:title] = 'foo'
|
86
86
|
|
87
|
-
TopHat.current[:title].
|
87
|
+
expect(TopHat.current[:title]).to eq('foo')
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
data/tophat.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.platform = Gem::Platform::RUBY
|
9
9
|
s.authors = ["Steve Agalloco"]
|
10
10
|
s.email = ['steve.agalloco@gmail.com']
|
11
|
-
s.homepage = "https://github.com/
|
11
|
+
s.homepage = "https://github.com/stve/tophat"
|
12
12
|
s.description = %q{Simple view helpers for your layouts}
|
13
13
|
s.summary = %q{Simple view helpers for your layouts}
|
14
14
|
|
metadata
CHANGED
@@ -1,30 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tophat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
5
|
-
prerelease:
|
4
|
+
version: 2.2.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Steve Agalloco
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2015-07-02 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: actionpack
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: 3.0.0
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: 3.0.0
|
30
27
|
description: Simple view helpers for your layouts
|
@@ -34,12 +31,11 @@ executables: []
|
|
34
31
|
extensions: []
|
35
32
|
extra_rdoc_files: []
|
36
33
|
files:
|
37
|
-
- .document
|
38
|
-
- .gitignore
|
39
|
-
- .rspec
|
40
|
-
- .travis.yml
|
34
|
+
- ".document"
|
35
|
+
- ".gitignore"
|
36
|
+
- ".rspec"
|
37
|
+
- ".travis.yml"
|
41
38
|
- Gemfile
|
42
|
-
- Guardfile
|
43
39
|
- LICENSE.md
|
44
40
|
- README.md
|
45
41
|
- Rakefile
|
@@ -64,35 +60,28 @@ files:
|
|
64
60
|
- spec/tophat/twitter_card_helper_spec.rb
|
65
61
|
- spec/tophat_spec.rb
|
66
62
|
- tophat.gemspec
|
67
|
-
homepage: https://github.com/
|
63
|
+
homepage: https://github.com/stve/tophat
|
68
64
|
licenses: []
|
65
|
+
metadata: {}
|
69
66
|
post_install_message:
|
70
67
|
rdoc_options: []
|
71
68
|
require_paths:
|
72
69
|
- lib
|
73
70
|
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
-
none: false
|
75
71
|
requirements:
|
76
|
-
- -
|
72
|
+
- - ">="
|
77
73
|
- !ruby/object:Gem::Version
|
78
74
|
version: '0'
|
79
|
-
segments:
|
80
|
-
- 0
|
81
|
-
hash: -2300101656837364012
|
82
75
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
-
none: false
|
84
76
|
requirements:
|
85
|
-
- -
|
77
|
+
- - ">="
|
86
78
|
- !ruby/object:Gem::Version
|
87
79
|
version: '0'
|
88
|
-
segments:
|
89
|
-
- 0
|
90
|
-
hash: -2300101656837364012
|
91
80
|
requirements: []
|
92
81
|
rubyforge_project:
|
93
|
-
rubygems_version:
|
82
|
+
rubygems_version: 2.4.8
|
94
83
|
signing_key:
|
95
|
-
specification_version:
|
84
|
+
specification_version: 4
|
96
85
|
summary: Simple view helpers for your layouts
|
97
86
|
test_files:
|
98
87
|
- spec/spec_helper.rb
|
data/Guardfile
DELETED