meta-tags 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ describe MetaTags::ViewHelper, 'displaying Open Search meta tags' do
4
+ subject { ActionView::Base.new }
5
+
6
+ it 'should display meta tags specified with :open_search' do
7
+ subject.set_meta_tags(open_search: {
8
+ title: 'Open Search Title',
9
+ href: '/open_search_path.xml'
10
+ })
11
+ subject.display_meta_tags(site: 'someSite').tap do |meta|
12
+ expect(meta).to have_tag('link', with: {
13
+ href: '/open_search_path.xml',
14
+ rel: 'search',
15
+ title: 'Open Search Title',
16
+ type: 'application/opensearchdescription+xml',
17
+ })
18
+ end
19
+ end
20
+
21
+ it 'should not display meta tags without content' do
22
+ subject.set_meta_tags(open_search: {
23
+ title: '',
24
+ href: '',
25
+ })
26
+ subject.display_meta_tags(site: 'someSite').tap do |meta|
27
+ expect(meta).to_not have_tag('link', with: {
28
+ rel: 'search',
29
+ type: 'application/opensearchdescription+xml',
30
+ })
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ describe MetaTags::ViewHelper, 'displaying refresh' do
4
+ subject { ActionView::Base.new }
5
+
6
+ it 'displays refresh when "refresh" is used' do
7
+ subject.refresh(5)
8
+ subject.display_meta_tags(site: 'someSite').tap do |meta|
9
+ expect(meta).to have_tag('meta', with: { content: '5', 'http-equiv' => 'refresh' })
10
+ end
11
+ end
12
+
13
+ it 'displays refresh when "set_meta_tags" used' do
14
+ subject.set_meta_tags(refresh: 5)
15
+ subject.display_meta_tags(site: 'someSite').tap do |meta|
16
+ expect(meta).to have_tag('meta', with: { content: '5', 'http-equiv' => 'refresh' })
17
+ end
18
+ end
19
+
20
+ it 'should use custom refresh if given' do
21
+ subject.refresh("5;url=http://example.com/")
22
+ subject.display_meta_tags(site: 'someSite').tap do |meta|
23
+ expect(meta).to have_tag('meta', with: { content: '5;url=http://example.com/', 'http-equiv' => "refresh" })
24
+ end
25
+ end
26
+
27
+ it 'should display nothing by default' do
28
+ subject.display_meta_tags(site: 'someSite').tap do |meta|
29
+ expect(meta).to_not have_tag('meta', with: { 'http-equiv' => "refresh" })
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,155 @@
1
+ require 'spec_helper'
2
+
3
+ describe MetaTags::ViewHelper do
4
+ subject { ActionView::Base.new }
5
+
6
+ context 'displaying title' do
7
+ it 'should not display title if blank' do
8
+ expect(subject.display_meta_tags).to eq('')
9
+ subject.title('')
10
+ expect(subject.display_meta_tags).to eq('')
11
+ end
12
+
13
+ it 'should use website name if title is empty' do
14
+ subject.display_meta_tags(site: 'someSite').tap do |meta|
15
+ expect(meta).to eq('<title>someSite</title>')
16
+ end
17
+ end
18
+
19
+ it 'should display title when "title" used' do
20
+ subject.title('someTitle')
21
+ subject.display_meta_tags(site: 'someSite').tap do |meta|
22
+ expect(meta).to eq('<title>someSite | someTitle</title>')
23
+ end
24
+ end
25
+
26
+ it 'should display title only when "site" is empty' do
27
+ subject.title('someTitle')
28
+ expect(subject.display_meta_tags).to eq('<title>someTitle</title>')
29
+ end
30
+
31
+ it 'should display title when "set_meta_tags" used' do
32
+ subject.set_meta_tags(title: 'someTitle')
33
+ subject.display_meta_tags(site: 'someSite').tap do |meta|
34
+ expect(meta).to eq('<title>someSite | someTitle</title>')
35
+ end
36
+ end
37
+
38
+ it 'should display custom title if given' do
39
+ subject.title('someTitle')
40
+ subject.display_meta_tags(site: 'someSite', title: 'defaultTitle').tap do |meta|
41
+ expect(meta).to eq('<title>someSite | someTitle</title>')
42
+ end
43
+ end
44
+
45
+ it 'should use website before page by default' do
46
+ subject.display_meta_tags(site: 'someSite', title: 'someTitle').tap do |meta|
47
+ expect(meta).to eq('<title>someSite | someTitle</title>')
48
+ end
49
+ end
50
+
51
+ it 'should only use markup in titles in the view' do
52
+ expect(subject.title('<b>someTitle</b>')).to eq('<b>someTitle</b>')
53
+ subject.display_meta_tags(site: 'someSite').tap do |meta|
54
+ expect(meta).to eq('<title>someSite | someTitle</title>')
55
+ end
56
+ end
57
+
58
+ it 'should use page before website if :reverse' do
59
+ subject.display_meta_tags(site: 'someSite', title: 'someTitle', reverse: true).tap do |meta|
60
+ expect(meta).to eq('<title>someTitle | someSite</title>')
61
+ end
62
+ end
63
+
64
+ it 'should be lowercase if :lowercase' do
65
+ subject.display_meta_tags(site: 'someSite', title: 'someTitle', lowercase: true).tap do |meta|
66
+ expect(meta).to eq('<title>someSite | sometitle</title>')
67
+ end
68
+ end
69
+
70
+ it 'should use custom separator if :separator' do
71
+ subject.title('someTitle')
72
+ subject.display_meta_tags(site: 'someSite', separator: '-').tap do |meta|
73
+ expect(meta).to eq('<title>someSite - someTitle</title>')
74
+ end
75
+ subject.display_meta_tags(site: 'someSite', separator: ':').tap do |meta|
76
+ expect(meta).to eq('<title>someSite : someTitle</title>')
77
+ end
78
+ subject.display_meta_tags(site: 'someSite', separator: '&amp;').tap do |meta|
79
+ expect(meta).to eq('<title>someSite &amp;amp; someTitle</title>')
80
+ end
81
+ subject.display_meta_tags(site: 'someSite', separator: '&amp;'.html_safe).tap do |meta|
82
+ expect(meta).to eq('<title>someSite &amp; someTitle</title>')
83
+ end
84
+ subject.display_meta_tags(site: 'someSite: ', separator: false).tap do |meta|
85
+ expect(meta).to eq('<title>someSite: someTitle</title>')
86
+ end
87
+ end
88
+
89
+ it 'should use custom prefix and suffix if available' do
90
+ subject.display_meta_tags(site: 'someSite', title: 'someTitle', prefix: ' -', suffix: '- ').tap do |meta|
91
+ expect(meta).to eq('<title>someSite -|- someTitle</title>')
92
+ end
93
+ end
94
+
95
+ it 'should collapse prefix if false' do
96
+ subject.display_meta_tags(site: 'someSite', title: 'someTitle', prefix: false).tap do |meta|
97
+ expect(meta).to eq('<title>someSite| someTitle</title>')
98
+ end
99
+ end
100
+
101
+ it 'should collapse suffix if false' do
102
+ subject.display_meta_tags(site: 'someSite', title: 'someTitle', suffix: false).tap do |meta|
103
+ expect(meta).to eq('<title>someSite |someTitle</title>')
104
+ end
105
+ end
106
+
107
+ it 'should use all custom options if available' do
108
+ subject.display_meta_tags({
109
+ site: 'someSite',
110
+ title: 'someTitle',
111
+ prefix: ' -',
112
+ suffix: '+ ',
113
+ separator: ':',
114
+ lowercase: true,
115
+ reverse: true,
116
+ }).tap do |meta|
117
+ expect(meta).to eq('<title>sometitle -:+ someSite</title>')
118
+ end
119
+ end
120
+
121
+ it 'should allow Arrays in title' do
122
+ subject.display_meta_tags(site: 'someSite', title: ['someTitle', 'anotherTitle']).tap do |meta|
123
+ expect(meta).to eq('<title>someSite | someTitle | anotherTitle</title>')
124
+ end
125
+ end
126
+
127
+ it 'should allow Arrays in title with :lowercase' do
128
+ subject.display_meta_tags(site: 'someSite', title: ['someTitle', 'anotherTitle'], lowercase: true).tap do |meta|
129
+ expect(meta).to eq('<title>someSite | sometitle | anothertitle</title>')
130
+ end
131
+ end
132
+
133
+ it 'should build title in reverse order if :reverse' do
134
+ subject.display_meta_tags({
135
+ site: 'someSite',
136
+ title: ['someTitle', 'anotherTitle'],
137
+ prefix: ' -',
138
+ suffix: '+ ',
139
+ separator: ':',
140
+ reverse: true,
141
+ }).tap do |meta|
142
+ expect(meta).to eq('<title>anotherTitle -:+ someTitle -:+ someSite</title>')
143
+ end
144
+ end
145
+ end
146
+
147
+ context '.display_title' do
148
+ it 'should display custom title if given' do
149
+ subject.title('someTitle')
150
+ subject.display_title(site: 'someSite', title: 'defaultTitle').tap do |meta|
151
+ expect(meta).to eq('someSite | someTitle')
152
+ end
153
+ end
154
+ end
155
+ end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ describe MetaTags::ViewHelper, 'displaying Twitter meta tags' do
4
+ subject { ActionView::Base.new }
5
+
6
+ it 'should display meta tags specified with :twitter' do
7
+ subject.set_meta_tags(twitter: {
8
+ title: 'Twitter Share Title',
9
+ card: 'photo',
10
+ image: {
11
+ _: 'http://example.com/1.png',
12
+ width: 123,
13
+ height: 321,
14
+ }
15
+ })
16
+ subject.display_meta_tags(site: 'someSite').tap do |meta|
17
+ expect(meta).to have_tag('meta', with: { content: "Twitter Share Title", name: "twitter:title" })
18
+ expect(meta).to have_tag('meta', with: { content: "photo", name: "twitter:card" })
19
+ expect(meta).to have_tag('meta', with: { content: "http://example.com/1.png", name: "twitter:image" })
20
+ expect(meta).to have_tag('meta', with: { content: "123", name: "twitter:image:width" })
21
+ expect(meta).to have_tag('meta', with: { content: "321", name: "twitter:image:height" })
22
+ end
23
+ end
24
+
25
+ it "should display mirrored content" do
26
+ subject.set_meta_tags(title: 'someTitle')
27
+ subject.display_meta_tags(twitter: { title: :title }).tap do |meta|
28
+ expect(meta).to have_tag('meta', with: { content: "someTitle", name: "twitter:title" })
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,57 @@
1
+ require 'spec_helper'
2
+
3
+ describe MetaTags::ViewHelper do
4
+ subject { ActionView::Base.new }
5
+
6
+ context 'returning values' do
7
+ it 'should return title' do
8
+ expect(subject.title('some-title')).to eq('some-title')
9
+ end
10
+
11
+ it 'should return headline if specified' do
12
+ expect(subject.title('some-title', 'some-headline')).to eq('some-headline')
13
+ end
14
+
15
+ it 'should return title' do
16
+ expect(subject.title('some-title')).to eq('some-title')
17
+ expect(subject.title).to eq('some-title')
18
+ end
19
+
20
+ it 'should return description' do
21
+ expect(subject.description('some-description')).to eq('some-description')
22
+ end
23
+
24
+ it 'should return keywords' do
25
+ expect(subject.keywords('some-keywords')).to eq('some-keywords')
26
+ end
27
+
28
+ it 'should return noindex' do
29
+ expect(subject.noindex('some-noindex')).to eq('some-noindex')
30
+ end
31
+
32
+ it 'should return nofollow' do
33
+ expect(subject.noindex('some-nofollow')).to eq('some-nofollow')
34
+ end
35
+ end
36
+
37
+ context 'while handling string meta tag names' do
38
+ it 'should work with common parameters' do
39
+ subject.display_meta_tags('site' => 'someSite', 'title' => 'someTitle').tap do |meta|
40
+ expect(meta).to eq('<title>someSite | someTitle</title>')
41
+ end
42
+ end
43
+
44
+ it 'should work with open graph parameters' do
45
+ subject.set_meta_tags('og' => {
46
+ 'title' => 'facebook title',
47
+ 'description' => 'facebook description'
48
+ })
49
+ subject.display_meta_tags(site: 'someSite').tap do |meta|
50
+ expect(meta).to have_tag('meta', with: { content: "facebook title", property: "og:title" })
51
+ expect(meta).to have_tag('meta', with: { content: "facebook description", property: "og:description" })
52
+ end
53
+ end
54
+ end
55
+
56
+ it_behaves_like '.set_meta_tags'
57
+ end
metadata CHANGED
@@ -1,83 +1,97 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: meta-tags
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmytro Shteflyuk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-15 00:00:00.000000000 Z
11
+ date: 2015-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 3.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ! '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 3.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ! '>='
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 3.3.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 3.3.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec-html-matchers
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
46
60
  - !ruby/object:Gem::Version
47
61
  version: '0'
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
- - - ! '>='
66
+ - - ">="
53
67
  - !ruby/object:Gem::Version
54
68
  version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: yard
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
- - - ! '>='
73
+ - - ">="
60
74
  - !ruby/object:Gem::Version
61
75
  version: '0'
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
- - - ! '>='
80
+ - - ">="
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: bluecloth
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
- - - ! '>='
87
+ - - ">="
74
88
  - !ruby/object:Gem::Version
75
89
  version: '0'
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
- - - ! '>='
94
+ - - ">="
81
95
  - !ruby/object:Gem::Version
82
96
  version: '0'
83
97
  description: Search Engine Optimization (SEO) plugin for Ruby on Rails applications.
@@ -89,10 +103,11 @@ extra_rdoc_files:
89
103
  - README.md
90
104
  - CHANGELOG.md
91
105
  files:
92
- - .gitignore
93
- - .ruby-gemset
94
- - .ruby-version
95
- - .travis.yml
106
+ - ".gitignore"
107
+ - ".rspec"
108
+ - ".ruby-gemset"
109
+ - ".ruby-version"
110
+ - ".travis.yml"
96
111
  - CHANGELOG.md
97
112
  - Gemfile
98
113
  - MIT-LICENSE
@@ -100,6 +115,7 @@ files:
100
115
  - Rakefile
101
116
  - lib/meta-tags.rb
102
117
  - lib/meta_tags.rb
118
+ - lib/meta_tags/configuration.rb
103
119
  - lib/meta_tags/content_tag.rb
104
120
  - lib/meta_tags/controller_helper.rb
105
121
  - lib/meta_tags/meta_tags_collection.rb
@@ -109,30 +125,46 @@ files:
109
125
  - lib/meta_tags/version.rb
110
126
  - lib/meta_tags/view_helper.rb
111
127
  - meta-tags.gemspec
128
+ - spec/configuration_spec.rb
112
129
  - spec/controller_helper_spec.rb
113
- - spec/meta_tags_spec.rb
114
130
  - spec/spec_helper.rb
131
+ - spec/text_normalizer/normalize_title_spec.rb
132
+ - spec/text_normalizer/truncate_array_spec.rb
133
+ - spec/view_helper/charset_spec.rb
134
+ - spec/view_helper/custom_spec.rb
135
+ - spec/view_helper/description_spec.rb
136
+ - spec/view_helper/icon_spec.rb
137
+ - spec/view_helper/keywords_spec.rb
138
+ - spec/view_helper/links_spec.rb
139
+ - spec/view_helper/module_spec.rb
140
+ - spec/view_helper/noindex_spec.rb
141
+ - spec/view_helper/open_graph_spec.rb
142
+ - spec/view_helper/open_search_spec.rb
143
+ - spec/view_helper/refresh_spec.rb
144
+ - spec/view_helper/title_spec.rb
145
+ - spec/view_helper/twitter_spec.rb
146
+ - spec/view_helper_spec.rb
115
147
  homepage: http://github.com/kpumuk/meta-tags
116
148
  licenses: []
117
149
  metadata: {}
118
150
  post_install_message:
119
151
  rdoc_options:
120
- - --charset=UTF-8
152
+ - "--charset=UTF-8"
121
153
  require_paths:
122
154
  - lib
123
155
  required_ruby_version: !ruby/object:Gem::Requirement
124
156
  requirements:
125
- - - ! '>='
157
+ - - ">="
126
158
  - !ruby/object:Gem::Version
127
159
  version: '0'
128
160
  required_rubygems_version: !ruby/object:Gem::Requirement
129
161
  requirements:
130
- - - ! '>='
162
+ - - ">="
131
163
  - !ruby/object:Gem::Version
132
164
  version: '0'
133
165
  requirements: []
134
166
  rubyforge_project:
135
- rubygems_version: 2.2.2
167
+ rubygems_version: 2.4.8
136
168
  signing_key:
137
169
  specification_version: 4
138
170
  summary: Collection of SEO helpers for Ruby on Rails.