tophat 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,7 +1,9 @@
1
- # TopHat [![Build Status](https://secure.travis-ci.org/spagalloco/tophat.png?branch=master)][travis] [![Dependency Status](https://gemnasium.com/spagalloco/tophat.png?travis)][gemnasium]
1
+ # TopHat [![Build Status](https://secure.travis-ci.org/spagalloco/tophat.png?branch=master)][travis] [![Dependency Status](https://gemnasium.com/spagalloco/tophat.png?travis)][gemnasium] [![Code Climate](https://codeclimate.com/badge.png)][codeclimate]
2
+
2
3
 
3
4
  [travis]: http://travis-ci.org/spagalloco/tophat
4
5
  [gemnasium]: https://gemnasium.com/spagalloco/tophat
6
+ [codeclimate]: https://codeclimate.com/github/spagalloco/tophat
5
7
 
6
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.
7
9
 
@@ -13,6 +15,10 @@ Just add it to your Gemfile:
13
15
 
14
16
  Note: TopHat is Rails 3.0+ compatible.
15
17
 
18
+ ## Changes in 2.1
19
+
20
+ TopHat version < 2.1 aliased the `title` as `t` and conflicted with an existing Rails helper used for i18n translation. Version 2.1 removes this alias. If you were using `t` as part of TopHat previously, you will need to change your code to use TopHat's `title` helper instead.
21
+
16
22
  ## Layout Usage
17
23
 
18
24
  You'll want to add the relevant TopHat helpers to your layouts:
@@ -179,7 +185,7 @@ Which will render a twitter card like so:
179
185
  <meta name="twitter:player" value="https://example.com/embed/a">
180
186
  <meta name="twitter:player:width" value="435">
181
187
  <meta name="twitter:player:height" value="251">
182
-
188
+
183
189
  To render the twitter card in your layout, simply call the twitter_card helper with no arguments:
184
190
 
185
191
  <%= twitter_card %>
data/lib/tophat/html.rb CHANGED
@@ -2,35 +2,71 @@ module TopHat
2
2
  module HtmlHelper
3
3
 
4
4
  def html_tag(options={})
5
- if options[:xmlns] && options[:xmlns].kind_of?(Array)
6
- options.delete(:xmlns).each do |xmlns|
7
- if xmlns.kind_of?(Hash)
8
- options["xmlns:#{xmlns[:prefix]}"] = xmlns[:url]
9
- else
10
- options['xmlns'] = xmlns
11
- end
12
- end
5
+ opts = options.dup
6
+ opts.merge!(xmlns_options(opts.delete(:xmlns))) if opts[:xmlns]
7
+ opts.merge!(prefix_options(opts.delete(:prefix))) if opts[:prefix]
8
+
9
+ tag(:html, opts, true)
10
+ end
11
+
12
+ private
13
+
14
+ def xmlns_options(xmlns)
15
+ options = {}
16
+
17
+ if xmlns.kind_of?(String)
18
+ options['xmlns'] = xmlns
19
+ elsif xmlns.kind_of?(Array)
20
+ options.merge!(xmlns_from_array(xmlns))
21
+ elsif xmlns.kind_of?(Hash)
22
+ options.merge!(xmlns_from_hash(xmlns))
13
23
  end
14
24
 
15
- if options[:prefix]
16
- if options[:prefix].kind_of?(Hash)
17
- prefix_options = options.delete(:prefix)
18
- options['prefix'] = "#{prefix_options[:prefix]}: #{prefix_options[:url]}"
19
- elsif options[:prefix].kind_of?(Array)
20
- prefixes = []
21
- options.delete(:prefix).each do |prefix|
22
- if prefix.kind_of?(Hash)
23
- prefixes << "#{prefix[:prefix]}: #{prefix[:url]}"
24
- else
25
- prefixes << prefix
26
- end
27
- end
28
-
29
- options['prefix'] = prefixes.join(' ')
25
+ options
26
+ end
27
+
28
+ def xmlns_from_array(xmlns)
29
+ options = {}
30
+
31
+ xmlns.each do |x|
32
+ if x.kind_of?(Hash)
33
+ options.merge!(xmlns_from_hash(x))
34
+ else
35
+ options['xmlns'] = x
30
36
  end
31
37
  end
32
38
 
33
- tag(:html, options, true)
39
+ options
40
+ end
41
+
42
+ def xmlns_from_hash(h)
43
+ { "xmlns:#{h[:prefix]}" => h[:url] }
44
+ end
45
+
46
+ def prefix_options(prefix)
47
+ options = {}
48
+
49
+ options['prefix'] = case prefix
50
+ when String then prefix
51
+ when Hash then prefix_from_hash(prefix)
52
+ when Array then prefix_from_array(prefix)
53
+ end
54
+
55
+ options
56
+ end
57
+
58
+ def prefix_from_array(prefixes)
59
+ prefixes.map do |prefix|
60
+ if prefix.kind_of?(Hash)
61
+ prefix_from_hash(prefix)
62
+ else
63
+ prefix
64
+ end
65
+ end.join(' ')
66
+ end
67
+
68
+ def prefix_from_hash(h)
69
+ "#{h[:prefix]}: #{h[:url]}"
34
70
  end
35
71
 
36
72
  end
@@ -18,14 +18,14 @@ module TopHat
18
18
  end
19
19
 
20
20
  def app_id
21
- tag(:meta, :property => 'fb:app_id', :content => @app_id) + "\n".html_safe if @app_id
21
+ tag(:meta, :property => 'fb:app_id', :content => @app_id) + "\n".html_safe
22
22
  end
23
23
 
24
24
  def admins
25
- tag(:meta, :property => 'fb:admins', :content => [*@admins].join(',')) + "\n".html_safe if @admins
25
+ tag(:meta, :property => 'fb:admins', :content => [*@admins].join(',')) + "\n".html_safe
26
26
  end
27
27
 
28
- def render_graph_data
28
+ def graph_data
29
29
  output = ActiveSupport::SafeBuffer.new
30
30
  @graph_data.each do |key, value|
31
31
  output << tag(:meta, :property => "og:#{key}", :content => value)
@@ -48,6 +48,14 @@ module TopHat
48
48
  @graph_data[method] = args.shift
49
49
  end
50
50
 
51
+ def to_html
52
+ output = ActiveSupport::SafeBuffer.new
53
+ output << app_id if defined?(@app_id) && @app_id
54
+ output << admins if defined?(@admins) && @admins
55
+ output << graph_data if has_graph_data?
56
+ output
57
+ end
58
+
51
59
  end
52
60
 
53
61
  HTML4_XMLNS = [
@@ -77,19 +85,14 @@ module TopHat
77
85
  end
78
86
 
79
87
  def opengraph(options=nil, &block)
80
- if options.kind_of? Hash
81
- TopHat.current['open_graph_defaults'] = options
82
- end
88
+ TopHat.current['open_graph_defaults'] = options if options.kind_of? Hash
89
+
83
90
  if block_given?
84
91
  TopHat.current['open_graph_generator'] = OpenGraphGenerator.new(TopHat.current['open_graph_defaults'], &block)
85
92
  else
86
93
  TopHat.current['open_graph_generator'] ||= OpenGraphGenerator.new
87
94
  TopHat.current['open_graph_generator'].merge(TopHat.current['open_graph_defaults'])
88
- output = ActiveSupport::SafeBuffer.new
89
- output << TopHat.current['open_graph_generator'].app_id
90
- output << TopHat.current['open_graph_generator'].admins
91
- output << TopHat.current['open_graph_generator'].render_graph_data if TopHat.current['open_graph_generator'].has_graph_data?
92
- output
95
+ TopHat.current['open_graph_generator'].to_html
93
96
  end
94
97
  end
95
98
 
data/lib/tophat/title.rb CHANGED
@@ -1,6 +1,10 @@
1
1
  module TopHat
2
2
  module TitleHelper
3
3
 
4
+ DEFAULT_PREFIX = ' '.freeze unless defined?(DEFAULT_PREFIX)
5
+ DEFAULT_SUFFIX = ' '.freeze unless defined?(DEFAULT_SUFFIX)
6
+ DEFAULT_SEPARATOR = ''.freeze unless defined?(DEFAULT_SEPARATOR)
7
+
4
8
  def title(title=nil, options={})
5
9
  if title.is_a?(String) || title.is_a?(Array)
6
10
  save_tophat_title(title, options)
@@ -8,8 +12,7 @@ module TopHat
8
12
  display_tophat_title(title || options)
9
13
  end
10
14
  end
11
- alias t title
12
-
15
+
13
16
  private
14
17
 
15
18
  def save_tophat_title(title, options)
@@ -27,8 +30,6 @@ module TopHat
27
30
 
28
31
  title_segments.flatten! # flatten out in case the title is an array
29
32
  title_segments.compact! # clean out any nils
30
- title_segments.map! { |t| t.downcase! } if options[:lowercase]
31
- title_segments.map! { |t| t.upcase! } if options[:uppercase]
32
33
  title_segments.map! { |t| strip_tags(t) }
33
34
 
34
35
  reverse = options[:reverse]
@@ -36,32 +37,34 @@ module TopHat
36
37
 
37
38
  title_segments.reverse! if reverse
38
39
 
39
- content_tag :title, title_segments.join(delimiter_from(options)).strip
40
+ title_text = title_segments.join(delimiter_from(options))
41
+ title_text.downcase! if options[:lowercase]
42
+ title_text.upcase! if options[:uppercase]
43
+
44
+ content_tag :title, title_text.strip
40
45
  end
41
46
 
42
47
  def delimiter_from(options={})
43
48
  return "" if options.empty?
44
49
 
45
50
  # Prefix (leading space)
46
- if options[:prefix]
47
- prefix = options[:prefix]
51
+ prefix = if options[:prefix]
52
+ options[:prefix]
48
53
  elsif options[:prefix] == false
49
- prefix = ''
50
- else
51
- prefix = ' '
54
+ ''
52
55
  end
56
+ prefix ||= DEFAULT_PREFIX
53
57
 
54
58
  # Separator
55
- separator = options[:separator] || ''
59
+ separator = options[:separator] || DEFAULT_SEPARATOR
56
60
 
57
61
  # Suffix (trailing space)
58
- if options[:suffix]
59
- suffix = options[:suffix]
62
+ suffix = if options[:suffix]
63
+ options[:suffix]
60
64
  elsif options[:suffix] == false
61
- suffix = ''
62
- else
63
- suffix = ' '
65
+ ''
64
66
  end
67
+ suffix ||= DEFAULT_SUFFIX
65
68
 
66
69
  prefix + separator + suffix
67
70
  end
@@ -13,7 +13,7 @@ module TopHat
13
13
  yield self if block_given?
14
14
  end
15
15
 
16
- def render
16
+ def to_html
17
17
  output = ActiveSupport::SafeBuffer.new
18
18
  output << tag(:meta, :name => 'twitter:card', :value => @type)
19
19
  @card_data.each do |key, value|
@@ -23,6 +23,7 @@ module TopHat
23
23
  output << "\n".html_safe unless @card_data.empty?
24
24
  output
25
25
  end
26
+ alias render to_html
26
27
 
27
28
  def add_nested_attributes(method, &block)
28
29
  image_generator = TwitterCardGenerator.new(method, &block)
@@ -41,7 +42,7 @@ module TopHat
41
42
  def twitter_card(type=nil, &block)
42
43
  if type.nil?
43
44
  if TopHat.current['twitter_card']
44
- TopHat.current['twitter_card'].render
45
+ TopHat.current['twitter_card'].to_html
45
46
  end
46
47
  else
47
48
  TopHat.current['twitter_card'] = TwitterCardGenerator.new(type, &block)
@@ -1,3 +1,3 @@
1
1
  module TopHat
2
- VERSION = '2.0.0'
3
- end
2
+ VERSION = '2.1.0'
3
+ end
@@ -21,6 +21,11 @@ describe TopHat::HtmlHelper do
21
21
  output.should eq('<html xmlns="http://someurl.com">')
22
22
  end
23
23
 
24
+ it 'accepts xmlns passed as hashes' do
25
+ output = @template.html_tag(:xmlns => { :prefix => 'fb', :url => 'http://someurl.com' })
26
+ output.should eq('<html xmlns:fb="http://someurl.com">')
27
+ end
28
+
24
29
  it 'accepts xmlns passed as an array of hashes' do
25
30
  xmlns = { :prefix => 'fb', :url => 'http://developers.facebook.com/schema/' }
26
31
  output = @template.html_tag(:xmlns => [xmlns])
@@ -19,129 +19,129 @@ describe TopHat::StylesheetHelper do
19
19
  it "defines IE conditionals" do
20
20
  @template.ie_5_conditional {
21
21
  @template.stylesheet_link_tag(@stylesheet)
22
- }.should == "<!--[if IE 5]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->"
22
+ }.should eq("<!--[if IE 5]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->")
23
23
 
24
24
  @template.ie_5_5_conditional {
25
25
  @template.stylesheet_link_tag(@stylesheet)
26
- }.should == "<!--[if IE 5.5]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->"
26
+ }.should eq("<!--[if IE 5.5]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->")
27
27
 
28
28
  @template.ie_6_conditional {
29
29
  @template.stylesheet_link_tag(@stylesheet)
30
- }.should == "<!--[if IE 6]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->"
30
+ }.should eq("<!--[if IE 6]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->")
31
31
 
32
32
  @template.ie_7_conditional {
33
33
  @template.stylesheet_link_tag(@stylesheet)
34
- }.should == "<!--[if IE 7]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->"
34
+ }.should eq("<!--[if IE 7]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->")
35
35
 
36
36
  @template.ie_8_conditional {
37
37
  @template.stylesheet_link_tag(@stylesheet)
38
- }.should == "<!--[if IE 8]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->"
38
+ }.should eq("<!--[if IE 8]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->")
39
39
 
40
40
  @template.ie_9_conditional {
41
41
  @template.stylesheet_link_tag(@stylesheet)
42
- }.should == "<!--[if IE 9]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->"
42
+ }.should 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
46
  @template.ie_5_conditional(:gt) {
47
47
  @template.stylesheet_link_tag(@stylesheet)
48
- }.should == "<!--[if gt IE 5]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->"
48
+ }.should eq("<!--[if gt IE 5]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->")
49
49
 
50
50
  @template.ie_5_5_conditional(:gt) {
51
51
  @template.stylesheet_link_tag(@stylesheet)
52
- }.should == "<!--[if gt IE 5.5]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->"
52
+ }.should 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
56
  @template.ie_5_conditional(:gte) {
57
57
  @template.stylesheet_link_tag(@stylesheet)
58
- }.should == "<!--[if gte IE 5]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->"
58
+ }.should eq("<!--[if gte IE 5]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->")
59
59
 
60
60
  @template.ie_5_5_conditional(:gte) {
61
61
  @template.stylesheet_link_tag(@stylesheet)
62
- }.should == "<!--[if gte IE 5.5]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->"
62
+ }.should 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
66
  @template.ie_5_conditional(:not) {
67
67
  @template.stylesheet_link_tag(@stylesheet)
68
- }.should == "<!--[if !IE 5]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->"
68
+ }.should eq("<!--[if !IE 5]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->")
69
69
 
70
70
  @template.ie_5_5_conditional(:not) {
71
71
  @template.stylesheet_link_tag(@stylesheet)
72
- }.should == "<!--[if !IE 5.5]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->"
72
+ }.should 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
76
  @template.ie_5_conditional(:lt) {
77
77
  @template.stylesheet_link_tag(@stylesheet)
78
- }.should == "<!--[if lt IE 5]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->"
78
+ }.should eq("<!--[if lt IE 5]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->")
79
79
 
80
80
  @template.ie_5_5_conditional(:lt) {
81
81
  @template.stylesheet_link_tag(@stylesheet)
82
- }.should == "<!--[if lt IE 5.5]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->"
82
+ }.should 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
86
  @template.ie_5_conditional(:lte) {
87
87
  @template.stylesheet_link_tag(@stylesheet)
88
- }.should == "<!--[if lte IE 5]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->"
88
+ }.should eq("<!--[if lte IE 5]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->")
89
89
 
90
90
  @template.ie_5_5_conditional(:lte) {
91
91
  @template.stylesheet_link_tag(@stylesheet)
92
- }.should == "<!--[if lte IE 5.5]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->"
92
+ }.should 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
96
  @template.ie_5_conditional(:eq) {
97
97
  @template.stylesheet_link_tag(@stylesheet)
98
- }.should == "<!--[if eq IE 5]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->"
98
+ }.should eq("<!--[if eq IE 5]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->")
99
99
 
100
100
  @template.ie_5_5_conditional(:eq) {
101
101
  @template.stylesheet_link_tag(@stylesheet)
102
- }.should == "<!--[if eq IE 5.5]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->"
102
+ }.should 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
106
  @template.opera_conditional {
107
107
  @template.stylesheet_link_tag(@stylesheet)
108
- }.should == "<!--[if Opera]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->"
108
+ }.should eq("<!--[if Opera]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->")
109
109
 
110
110
  @template.webkit_conditional {
111
111
  @template.stylesheet_link_tag(@stylesheet)
112
- }.should == "<!--[if Webkit]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->"
112
+ }.should eq("<!--[if Webkit]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->")
113
113
 
114
114
  @template.webkit_conditional(:eq) {
115
115
  @template.stylesheet_link_tag(@stylesheet)
116
- }.should == "<!--[if eq Webkit]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->"
116
+ }.should eq("<!--[if eq Webkit]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->")
117
117
 
118
118
  @template.gecko_conditional {
119
119
  @template.stylesheet_link_tag(@stylesheet)
120
- }.should == "<!--[if Gecko]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->"
120
+ }.should eq("<!--[if Gecko]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->")
121
121
 
122
122
  @template.ie_mac_conditional {
123
123
  @template.stylesheet_link_tag(@stylesheet)
124
- }.should == "<!--[if IEMac]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->"
124
+ }.should eq("<!--[if IEMac]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->")
125
125
 
126
126
  @template.konqueror_conditional {
127
127
  @template.stylesheet_link_tag(@stylesheet)
128
- }.should == "<!--[if Konq]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->"
128
+ }.should eq("<!--[if Konq]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->")
129
129
 
130
130
  @template.ie_mobile_conditional {
131
131
  @template.stylesheet_link_tag(@stylesheet)
132
- }.should == "<!--[if IEmob]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->"
132
+ }.should eq("<!--[if IEmob]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->")
133
133
 
134
134
  @template.psp_conditional {
135
135
  @template.stylesheet_link_tag(@stylesheet)
136
- }.should == "<!--[if PSP]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->"
136
+ }.should eq("<!--[if PSP]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->")
137
137
 
138
138
  @template.net_front_conditional {
139
139
  @template.stylesheet_link_tag(@stylesheet)
140
- }.should == "<!--[if NetF]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->"
140
+ }.should eq("<!--[if NetF]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->")
141
141
 
142
142
  @template.mobile_safari_conditional {
143
143
  @template.stylesheet_link_tag(@stylesheet)
144
- }.should == "<!--[if SafMob]>\n<link href=\"/stylesheets/ie.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->"
144
+ }.should 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
 
@@ -7,91 +7,91 @@ describe TopHat::TitleHelper do
7
7
  end
8
8
 
9
9
  context "saving a title" do
10
- it "should save the title" do
11
- @template.title('Kind of Blue').should == 'Kind of Blue'
10
+ it "saves the title" do
11
+ @template.title('Kind of Blue').should 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").should == "<title>Miles Davis</title>"
17
+ @template.title(:site => "Miles Davis").should 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().should == '<title>Kind of Blue</title>'
22
+ @template.title().should 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 => '|').should == "<title>Miles Davis | Kind of Blue</title>"
27
+ @template.title(:site => "Miles Davis", :separator => '|').should 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
31
  save_basic_title("<b>Kind of Blue</b>").should == "<b>Kind of Blue</b>"
32
- @template.title(:site => "Miles Davis", :separator => '|').should == "<title>Miles Davis | Kind of Blue</title>"
32
+ @template.title(:site => "Miles Davis", :separator => '|').should 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 => '|').should == "<title>Kind of Blue | Miles Davis</title>"
37
+ @template.title(:site => "Miles Davis", :reverse => true, :separator => '|').should 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 => '|').should == "<title>John Coltrane | My Favorite Things</title>"
41
+ @template.title(:site => "John Coltrane", :default => "My Favorite Things", :reverse => true, :reverse_on_default => false, :separator => '|').should 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 => '|').should == "<title>miles davis | kind of blue</title>"
46
+ @template.title(:site => "Miles Davis", :lowercase => true, :separator => '|').should 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 => '|').should == "<title>MILES DAVIS | KIND OF BLUE</title>"
51
+ @template.title(:site => "Miles Davis", :uppercase => true, :separator => '|').should 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 => "-").should == "<title>Miles Davis - Kind of Blue</title>"
57
- @template.title(:site => "Miles Davis", :separator => ":").should == "<title>Miles Davis : Kind of Blue</title>"
58
- @template.title(:site => "Miles Davis", :separator => "&mdash;").should == "<title>Miles Davis &amp;mdash; Kind of Blue</title>"
56
+ @template.title(:site => "Miles Davis", :separator => "-").should eq("<title>Miles Davis - Kind of Blue</title>")
57
+ @template.title(:site => "Miles Davis", :separator => ":").should eq("<title>Miles Davis : Kind of Blue</title>")
58
+ @template.title(:site => "Miles Davis", :separator => "&mdash;").should eq("<title>Miles Davis &amp;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 => '|').should == "<title>Miles Davis ||| Kind of Blue</title>"
63
+ @template.title(:site => "Miles Davis", :prefix => " |", :suffix => "| ", :separator => '|').should 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 => ":").should == "<title>Miles Davis: Kind of Blue</title>"
68
+ @template.title(:site => "Miles Davis", :prefix => false, :separator => ":").should 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 => "~").should == "<title>Miles Davis ~Kind of Blue</title>"
73
+ @template.title(:site => "Miles Davis", :suffix => false, :separator => "~").should 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).should == "<title>kind of blue - miles davis</title>"
79
+ @template.title(custom_options).should 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 => '|').should == "<title>Miles Davis | Round About Midnight</title>"
84
+ @template.title(:site => "Miles Davis", :default => "Round About Midnight", :separator => '|').should 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 => '|').should == "<title>Kind of Blue | Freddie Freeloader</title>"
89
+ @template.title(:site => "Freddie Freeloader", :separator => '|').should 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 => '|').should == "<title>Freddie Freeloader | My | Favorite | Things</title>"
94
+ @template.title(:site => "Freddie Freeloader", :separator => '|').should eq("<title>Freddie Freeloader | My | Favorite | Things</title>")
95
95
  end
96
96
  end
97
97
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tophat
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-24 00:00:00.000000000 Z
12
+ date: 2012-09-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionpack
@@ -190,7 +190,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
190
190
  version: '0'
191
191
  segments:
192
192
  - 0
193
- hash: -3156332109712594110
193
+ hash: -1469491919120880781
194
194
  required_rubygems_version: !ruby/object:Gem::Requirement
195
195
  none: false
196
196
  requirements:
@@ -199,7 +199,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
199
199
  version: '0'
200
200
  segments:
201
201
  - 0
202
- hash: -3156332109712594110
202
+ hash: -1469491919120880781
203
203
  requirements: []
204
204
  rubyforge_project:
205
205
  rubygems_version: 1.8.24