rails-bootstrap-helpers 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. data/README.md +336 -14
  2. data/lib/rails-bootstrap-helpers.rb +14 -3
  3. data/lib/rails-bootstrap-helpers/helpers/accordion_helper.rb +8 -0
  4. data/lib/rails-bootstrap-helpers/helpers/alert_helper.rb +24 -14
  5. data/lib/rails-bootstrap-helpers/helpers/base_helper.rb +25 -13
  6. data/lib/rails-bootstrap-helpers/helpers/button_helper.rb +85 -13
  7. data/lib/rails-bootstrap-helpers/helpers/form_tag_helper.rb +42 -10
  8. data/lib/rails-bootstrap-helpers/helpers/navigation_helper.rb +17 -0
  9. data/lib/rails-bootstrap-helpers/helpers/options_helper.rb +24 -3
  10. data/lib/rails-bootstrap-helpers/helpers/tag_helper.rb +26 -0
  11. data/lib/rails-bootstrap-helpers/helpers/url_helper.rb +17 -0
  12. data/lib/rails-bootstrap-helpers/rails/engine.rb +4 -2
  13. data/lib/rails-bootstrap-helpers/renderers/{abstract_button_renderer.rb → abstract_link_renderer.rb} +23 -7
  14. data/lib/rails-bootstrap-helpers/renderers/accordion_renderer.rb +94 -0
  15. data/lib/rails-bootstrap-helpers/renderers/action_link_renderer.rb +19 -0
  16. data/lib/rails-bootstrap-helpers/renderers/button_renderer.rb +6 -4
  17. data/lib/rails-bootstrap-helpers/renderers/content_tag_renderer.rb +67 -0
  18. data/lib/rails-bootstrap-helpers/renderers/dropdown_button_renderer.rb +87 -0
  19. data/lib/rails-bootstrap-helpers/renderers/iconic_icon_renderer.rb +75 -0
  20. data/lib/rails-bootstrap-helpers/renderers/row_link_renderer.rb +12 -0
  21. data/lib/rails-bootstrap-helpers/renderers/tabbable_renderer.rb +186 -0
  22. data/lib/rails-bootstrap-helpers/version.rb +1 -1
  23. data/spec/dummy/log/test.log +296 -0
  24. data/spec/helpers/accordion_helper_spec.rb +35 -0
  25. data/spec/helpers/alert_helper_spec.rb +11 -7
  26. data/spec/helpers/base_helper_spec.rb +44 -0
  27. data/spec/helpers/button_helper_spec.rb +214 -9
  28. data/spec/helpers/form_tag_helper_spec.rb +27 -0
  29. data/spec/helpers/navigation_helper_spec.rb +228 -0
  30. data/spec/helpers/options_helper_spec.rb +50 -0
  31. data/spec/helpers/tag_helper_spec.rb +26 -0
  32. data/spec/helpers/url_helper_spec.rb +33 -0
  33. data/spec/spec_helper.rb +2 -0
  34. data/spec/support/html.rb +9 -0
  35. data/spec/support/matchers/helpers/alert_helper/render_bs_alert.rb +19 -10
  36. data/spec/support/matchers/helpers/base_helper/render_icon.rb +18 -1
  37. data/spec/support/matchers/helpers/base_helper/render_iconic_icon.rb +191 -0
  38. data/spec/support/matchers/helpers/button_helper/render_bs_button_to.rb +44 -3
  39. data/spec/support/matchers/helpers/button_helper/render_inline_button_to.rb +1 -1
  40. data/spec/support/matchers/helpers/form_tag_helper/render_bs_button_tag.rb +39 -1
  41. data/spec/support/matchers/helpers/form_tag_helper/render_bs_submit_tag.rb +96 -0
  42. data/spec/support/matchers/helpers/url_helper/render_action_link_to.rb +123 -0
  43. data/spec/support/matchers/helpers/url_helper/render_row_link_to.rb +97 -0
  44. metadata +59 -8
  45. checksums.yaml +0 -15
@@ -0,0 +1,35 @@
1
+ require "spec_helper"
2
+
3
+ describe RailsBootstrapHelpers::Helpers::AccordionHelper do
4
+ describe "accordion" do
5
+ it "should render an accordion" do
6
+ expected_html = <<-eos
7
+ <div class="accordion" id="foo">
8
+ <div class="accordion-group">
9
+ <div class="accordion-heading">
10
+ <a class="accordion-toggle" data-parent="#foo.accordion" data-toggle="collapse" href="#foo.accordion .accordion-group:nth-child(1) .accordion-body.collapse">
11
+ bar
12
+ </a>
13
+ </div>
14
+
15
+ <div class="accordion-body collapse">
16
+ <div class="accordion-inner">
17
+ content
18
+ </div>
19
+ </div>
20
+ </div>
21
+ </div>
22
+ eos
23
+
24
+ expected_html = expected_html.gsub(/^\s+/, "").gsub("\n", "")
25
+
26
+ html = accordion "foo" do |a|
27
+ a.group "bar" do
28
+ "content"
29
+ end
30
+ end
31
+
32
+ html.should == expected_html
33
+ end
34
+ end
35
+ end
@@ -5,15 +5,19 @@ describe RailsBootstrapHelpers::Helpers::AlertHelper do
5
5
  it { should render_bs_alert("foo") }
6
6
 
7
7
  context "with type" do
8
- it { should render_bs_alert("foo").with_type(:error) }
9
- it { should render_bs_alert("foo").with_type(:success) }
10
- it { should render_bs_alert("foo").with_type(:info) }
11
- it { should render_bs_alert("foo").with_type(:warning) }
12
- it { should render_bs_alert("foo").with_type(:default) }
13
- it { should render_bs_alert("foo").with_type(:notice).as_class(:success) }
8
+ it { should render_bs_alert("foo").with_style(:error) }
9
+ it { should render_bs_alert("foo").with_style(:success) }
10
+ it { should render_bs_alert("foo").with_style(:info) }
11
+ it { should render_bs_alert("foo").with_style(:warning) }
12
+ it { should render_bs_alert("foo").with_style(:default) }
13
+ it { should render_bs_alert("foo").with_style(:notice).as_class(:success) }
14
14
 
15
15
  context "custom" do
16
- it { should render_bs_alert("foo").with_type(:bar) }
16
+ it { should render_bs_alert("foo").with_style(:bar) }
17
+ end
18
+
19
+ context "deprecated options" do
20
+ it { should render_bs_alert("foo").with_type(:error) }
17
21
  end
18
22
  end
19
23
 
@@ -14,5 +14,49 @@ describe RailsBootstrapHelpers::Helpers::BaseHelper do
14
14
  it { should render_icon(:foo) }
15
15
  it { should render_icon("bar") }
16
16
  end
17
+
18
+ context "with class" do
19
+ it { should render_icon(:edit).with_class("bar") }
20
+ it { should render_icon("remove").with_class("bar") }
21
+ it { should render_icon(:edit).inverted(true).with_class("bar") }
22
+ end
23
+ end
24
+
25
+ describe "iconic_icon" do
26
+ it { should render_iconic_icon(:check) }
27
+ it { should render_iconic_icon("clock") }
28
+
29
+ context "custom icons" do
30
+ it { should render_iconic_icon(:foo) }
31
+ it { should render_iconic_icon("bar") }
32
+ end
33
+
34
+ context "with color" do
35
+ it { should render_iconic_icon(:check).with_color(:blue) }
36
+ it { should render_iconic_icon(:check).with_color('#fff') }
37
+ end
38
+
39
+ context "with size" do
40
+ it { should render_iconic_icon(:check).with_size(10) }
41
+ it { should render_iconic_icon(:check).with_size("10") }
42
+ it { should render_iconic_icon(:check).with_size("10px") }
43
+ it { should render_iconic_icon(:check).with_size("1em") }
44
+ end
45
+
46
+ context "with Bootstrap style" do
47
+ it { should render_iconic_icon(:check).with_bs_style(:muted) }
48
+ it { should render_iconic_icon(:check).with_bs_style(:success) }
49
+ it { should render_iconic_icon(:check).with_bs_style(:foo) }
50
+ end
51
+
52
+ context "with action link style" do
53
+ it { should render_iconic_icon(:check).with_action_style(:default) }
54
+ it { should render_iconic_icon(:check).with_action_style(:success) }
55
+ it { should render_iconic_icon(:check).with_action_style(:foo) }
56
+ end
57
+
58
+ context "with tooltip" do
59
+ it { should render_iconic_icon(:check).with_tooltip("foo") }
60
+ end
17
61
  end
18
62
  end
@@ -1,6 +1,12 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe RailsBootstrapHelpers::Helpers::ButtonHelper do
4
+ let(:html_attributes) do
5
+ attributes.map{ |k, v| "#{k}=\"#{v}\"" }.join(" ")
6
+ end
7
+
8
+ let(:html) { "<a #{html_attributes}>foo</a>" }
9
+
4
10
  describe "bs_button_to" do
5
11
  context "with url" do
6
12
  it { should render_bs_button_to("foo").to("bar") }
@@ -41,6 +47,15 @@ describe RailsBootstrapHelpers::Helpers::ButtonHelper do
41
47
  it { should render_bs_button_to("foo").with_icon_position(:left) }
42
48
  it { should render_bs_button_to("foo").with_icon_position(:right) }
43
49
  end
50
+
51
+ context "with custom class attribute" do
52
+ it { should render_bs_button_to("foo").with_class("bar") }
53
+ end
54
+
55
+ context "with tooltip" do
56
+ it { should render_bs_button_to("foo").with_tooltip("asd") }
57
+ it { should render_bs_button_to("foo").with_tooltip("asd").with_tooltip_position(:left) }
58
+ end
44
59
  end
45
60
 
46
61
  describe "bs_inline_button_to" do
@@ -64,20 +79,12 @@ describe RailsBootstrapHelpers::Helpers::ButtonHelper do
64
79
  }
65
80
  end
66
81
 
67
- let(:html_attributes) do
68
- attributes.map{ |k, v| "#{k}=\"#{v}\"" }.join(" ")
69
- end
70
-
71
82
  it "should render a button with a popover" do
72
- html = "<a #{html_attributes}>foo</a>"
73
-
74
83
  helper.bs_popover_button("foo", "bar").should == html
75
84
  end
76
85
 
77
86
  context "render popover using block" do
78
87
  it "should render a button with a popover" do
79
- html = "<a #{html_attributes}>foo</a>"
80
-
81
88
  helper.bs_popover_button("foo") { "bar" }.should == html
82
89
  end
83
90
  end
@@ -85,10 +92,208 @@ describe RailsBootstrapHelpers::Helpers::ButtonHelper do
85
92
  context "with custom placement" do
86
93
  it "should render a button with a popover" do
87
94
  attributes[:"data-placement"] = "top"
88
- html = "<a #{html_attributes}>foo</a>"
95
+ helper.bs_popover_button("foo", "bar", position: "top").should == html
96
+ end
97
+ end
89
98
 
99
+ context "with deprecated options" do
100
+ it "should render a button with a popover" do
101
+ attributes[:"data-placement"] = "top"
90
102
  helper.bs_popover_button("foo", "bar", placement: "top").should == html
91
103
  end
92
104
  end
93
105
  end
106
+
107
+ describe "bs_collapsible_button" do
108
+ let(:attributes) do
109
+ {
110
+ class: "btn",
111
+ :"data-target" => "bar",
112
+ :"data-toggle" => "collapse",
113
+ name: "button",
114
+ type: "button"
115
+ }
116
+ end
117
+
118
+ let(:html) { "<button #{html_attributes}>foo</button>" }
119
+
120
+ it "should render a button with a collapsible" do
121
+ helper.bs_collapsible_button("foo", "bar").should == html
122
+ end
123
+
124
+ context "with style" do
125
+ it "should render a collapsible button with the proper style" do
126
+ attributes[:class] = "btn btn-primary"
127
+ helper.bs_collapsible_button("foo", "bar", style: "primary").should == html
128
+ end
129
+ end
130
+ end
131
+
132
+ describe "button_group" do
133
+ it "should render a button group" do
134
+ content = helper.button_group do
135
+ "asd"
136
+ end
137
+
138
+ content.should == '<div class="btn-group">asd</div>'
139
+ end
140
+
141
+ context "vertical button group" do
142
+ it "should render a vertical button group" do
143
+ content = helper.button_group vertical: true do
144
+ "asd"
145
+ end
146
+
147
+ content.should == '<div class="btn-group btn-group-vertical">asd</div>'
148
+ end
149
+ end
150
+
151
+ context "toolbar button group" do
152
+ it "should render a toolbar button group" do
153
+ content = helper.button_group toolbar: true do
154
+ "asd"
155
+ end
156
+
157
+ content.should == '<div class="btn-toolbar">asd</div>'
158
+ end
159
+ end
160
+ end
161
+
162
+ describe "bs_dropdown_button_to" do
163
+ let(:expected_html) do
164
+ html = <<-eos
165
+ <div class="btn-group">
166
+ <button class="dropdown-toggle btn" data-toggle="dropdown" name="button">
167
+ foo <span class="caret"></span>
168
+ </button>
169
+ <ul class="dropdown-menu">
170
+ <li><a href="http://www.google.com">bar</a></li>
171
+ <li><a href="http://www.wikipedia.org">baz</a></li>
172
+ </ul>
173
+ </div>
174
+ eos
175
+
176
+ strip_expected(html)
177
+ end
178
+
179
+ it "should render a dropdown button" do
180
+ html = bs_dropdown_button_to "foo" do
181
+ content_tag(:li, link_to("bar", "http://www.google.com")) +
182
+ content_tag(:li, link_to("baz", "http://www.wikipedia.org"))
183
+ end
184
+
185
+ strip(html).should == expected_html
186
+ end
187
+
188
+ context "with link" do
189
+ let(:expected_html) do
190
+ html = <<-eos
191
+ <div class="btn-group">
192
+ <a href="https://github.com" class="btn">foo</a>
193
+ <button class="dropdown-toggle btn" data-toggle="dropdown" name="button">
194
+ <span class="caret"></span>
195
+ </button>
196
+ <ul class="dropdown-menu">
197
+ <li><a href="http://www.google.com">bar</a></li>
198
+ <li><a href="http://www.wikipedia.org">baz</a></li>
199
+ </ul>
200
+ </div>
201
+ eos
202
+
203
+ strip_expected(html)
204
+ end
205
+
206
+ it "should render a split dropdown button" do
207
+ html = bs_dropdown_button_to "foo", "https://github.com" do
208
+ content_tag(:li, link_to("bar", "http://www.google.com")) +
209
+ content_tag(:li, link_to("baz", "http://www.wikipedia.org"))
210
+ end
211
+
212
+ strip(html).should == expected_html
213
+ end
214
+ end
215
+
216
+ context "with icon" do
217
+ let(:expected_html) do
218
+ html = <<-eos
219
+ <div class="btn-group">
220
+ <button class="dropdown-toggle btn" data-toggle="dropdown" name="button">
221
+ <i class="icon-search"></i> foo <span class="caret"></span>
222
+ </button>
223
+ <ul class="dropdown-menu">
224
+ <li><a href="http://www.google.com">bar</a></li>
225
+ <li><a href="http://www.wikipedia.org">baz</a></li>
226
+ </ul>
227
+ </div>
228
+ eos
229
+
230
+ strip_expected(html)
231
+ end
232
+
233
+ it "should render a dropdown button with an icon" do
234
+ html = bs_dropdown_button_to "foo", icon: "search" do
235
+ content_tag(:li, link_to("bar", "http://www.google.com")) +
236
+ content_tag(:li, link_to("baz", "http://www.wikipedia.org"))
237
+ end
238
+
239
+ strip(html).should == expected_html
240
+ end
241
+ end
242
+
243
+ context "with link and icon" do
244
+ let(:expected_html) do
245
+ html = <<-eos
246
+ <div class="btn-group">
247
+ <a href="https://github.com" class="btn"><i class="icon-search"></i> foo</a>
248
+ <button class="dropdown-toggle btn" data-toggle="dropdown" name="button">
249
+ <span class="caret"></span>
250
+ </button>
251
+ <ul class="dropdown-menu">
252
+ <li><a href="http://www.google.com">bar</a></li>
253
+ <li><a href="http://www.wikipedia.org">baz</a></li>
254
+ </ul>
255
+ </div>
256
+ eos
257
+
258
+ strip_expected(html)
259
+ end
260
+
261
+ it "should render a split dropdown button with an icon" do
262
+ html = bs_dropdown_button_to "foo", "https://github.com", icon: "search" do
263
+ content_tag(:li, link_to("bar", "http://www.google.com")) +
264
+ content_tag(:li, link_to("baz", "http://www.wikipedia.org"))
265
+ end
266
+
267
+ strip(html).should == expected_html
268
+ end
269
+ end
270
+
271
+ context "with link and style" do
272
+ let(:expected_html) do
273
+ html = <<-eos
274
+ <div class="btn-group">
275
+ <a href="https://github.com" class="btn btn-success">foo</a>
276
+ <button class="dropdown-toggle btn-success btn" data-toggle="dropdown" name="button">
277
+ <span class="caret"></span>
278
+ </button>
279
+ <ul class="dropdown-menu">
280
+ <li><a href="http://www.google.com">bar</a></li>
281
+ <li><a href="http://www.wikipedia.org">baz</a></li>
282
+ </ul>
283
+ </div>
284
+ eos
285
+
286
+ strip_expected(html)
287
+ end
288
+
289
+ it "should render a split dropdown button with the success style" do
290
+ html = bs_dropdown_button_to "foo", "https://github.com", style: "success" do
291
+ content_tag(:li, link_to("bar", "http://www.google.com")) +
292
+ content_tag(:li, link_to("baz", "http://www.wikipedia.org"))
293
+ end
294
+
295
+ strip(html).should == expected_html
296
+ end
297
+ end
298
+ end
94
299
  end
@@ -39,5 +39,32 @@ describe RailsBootstrapHelpers::Helpers::FormTagHelper do
39
39
  it { should render_bs_button_tag("foo", :submit).with_icon_position(:left) }
40
40
  it { should render_bs_button_tag("foo", :submit).with_icon_position(:right) }
41
41
  end
42
+
43
+ context "with tooltip" do
44
+ it { should render_bs_button_tag("foo", :submit).with_tooltip("asd") }
45
+ it { should render_bs_button_tag("foo", :submit).with_tooltip("asd").with_tooltip_position(:left) }
46
+ end
47
+ end
48
+
49
+ describe "bs_submit_tag" do
50
+ it { should render_bs_submit_tag("foo") }
51
+
52
+ context "with style" do
53
+ it { should render_bs_submit_tag("foo").with_style(:default) }
54
+ it { should render_bs_submit_tag("foo").with_style(:primary) }
55
+ it { should render_bs_submit_tag("foo").with_style(:info) }
56
+ it { should render_bs_submit_tag("foo").with_style(:success) }
57
+ it { should render_bs_submit_tag("foo").with_style(:warning) }
58
+ it { should render_bs_submit_tag("foo").with_style(:danger) }
59
+ it { should render_bs_submit_tag("foo").with_style(:inverse) }
60
+ it { should render_bs_submit_tag("foo").with_style(:link) }
61
+ end
62
+
63
+ context "with size" do
64
+ it { should render_bs_submit_tag("foo").with_size(:default) }
65
+ it { should render_bs_submit_tag("foo").with_size(:large) }
66
+ it { should render_bs_submit_tag("foo").with_size(:small) }
67
+ it { should render_bs_submit_tag("foo").with_size(:mini) }
68
+ end
42
69
  end
43
70
  end
@@ -0,0 +1,228 @@
1
+ require "spec_helper"
2
+
3
+ describe RailsBootstrapHelpers::Helpers::NavigationHelper do
4
+ let(:foo_tab_text) { "foo" }
5
+ let(:bar_tab_text) { "bar" }
6
+
7
+ let(:foo_tab_id) { "tab_pane_0_#{foo_tab_text.object_id}" }
8
+ let(:bar_tab_id) { "tab_pane_1_#{bar_tab_text.object_id}" }
9
+
10
+ let(:block) do
11
+ lambda do |bar|
12
+ bar.tab bar_tab_text
13
+
14
+ bar.tab_pane do
15
+ "foo content"
16
+ end
17
+
18
+ bar.tab_pane do
19
+ "bar content"
20
+ end
21
+ end
22
+ end
23
+
24
+ let(:html_class) { "tabbable" }
25
+ let(:expected_html) do
26
+ html = <<-eos
27
+ <div class="#{html_class}">
28
+ <ul class="nav nav-tabs">
29
+ <li class="active"><a href="##{foo_tab_id}" data-toggle="tab">foo</a></li>
30
+ <li><a href="##{bar_tab_id}" data-toggle="tab">bar</a></li>
31
+ </ul>
32
+
33
+ <div class="tab-content">
34
+ <div class="tab-pane active" id="#{foo_tab_id}">
35
+ foo content
36
+ </div>
37
+
38
+ <div class="tab-pane" id="#{bar_tab_id}">
39
+ bar content
40
+ </div>
41
+ </div>
42
+ </div>
43
+ eos
44
+
45
+ strip_expected(html)
46
+ end
47
+
48
+ describe "tabbable" do
49
+ it "should render an tabbable navigation" do
50
+ html = tabbable(foo_tab_text, &block)
51
+ strip(html).should == expected_html
52
+ end
53
+
54
+ context "unmatching tabs and panes" do
55
+ let(:errro_message) { "Unmatching tabs and panes. 0 tabs were given and 1 pane was given" }
56
+
57
+ it "should raise an unmatching error" do
58
+ ->() { tabbable { |bar| bar.tab_pane { "foo" } } }.should raise_error(errro_message)
59
+ end
60
+ end
61
+
62
+ context "options" do
63
+ context "with bordered style" do
64
+ let(:html_class) { "tabbable tabbable-bordered" }
65
+
66
+ it "should render a tabbable navigation with a border" do
67
+ html = tabbable(foo_tab_text, bordered: true, &block)
68
+ strip(html).should == expected_html
69
+ end
70
+ end
71
+
72
+ context "with fade" do
73
+ let(:expected_html) do
74
+ html = <<-eos
75
+ <div class="tabbable">
76
+ <ul class="nav nav-tabs">
77
+ <li class="active"><a href="##{foo_tab_id}" data-toggle="tab">foo</a></li>
78
+ <li><a href="##{bar_tab_id}" data-toggle="tab">bar</a></li>
79
+ </ul>
80
+
81
+ <div class="tab-content">
82
+ <div class="tab-pane active fade in" id="#{foo_tab_id}">
83
+ foo content
84
+ </div>
85
+
86
+ <div class="tab-pane fade in" id="#{bar_tab_id}">
87
+ bar content
88
+ </div>
89
+ </div>
90
+ </div>
91
+ eos
92
+
93
+ strip_expected(html)
94
+ end
95
+
96
+ it "should render a tabbable navigation with fade" do
97
+ html = tabbable(foo_tab_text, fade: true, &block)
98
+ strip(html).should == expected_html
99
+ end
100
+ end
101
+
102
+ context "with active" do
103
+ it "should render the specified tabs and tab panes as active" do
104
+ expected_html = <<-eos
105
+ <div class="tabbable">
106
+ <ul class="nav nav-tabs">
107
+ <li><a href="##{foo_tab_id}" data-toggle="tab">foo</a></li>
108
+ <li class="active"><a href="##{bar_tab_id}" data-toggle="tab">bar</a></li>
109
+ </ul>
110
+
111
+ <div class="tab-content">
112
+ <div class="tab-pane" id="#{foo_tab_id}">
113
+ foo content
114
+ </div>
115
+
116
+ <div class="tab-pane active" id="#{bar_tab_id}">
117
+ bar content
118
+ </div>
119
+ </div>
120
+ </div>
121
+ eos
122
+
123
+ expected_html = strip_expected(expected_html)
124
+
125
+ html = tabbable do |bar|
126
+ bar.tab foo_tab_text
127
+ bar.tab bar_tab_text, active: true
128
+
129
+ bar.tab_pane do
130
+ "foo content"
131
+ end
132
+
133
+ bar.tab_pane active: true do
134
+ "bar content"
135
+ end
136
+ end
137
+
138
+ strip(html).should == expected_html
139
+ end
140
+
141
+ it "should render none of the tabs or tab panes as active if ':active' is set to 'false'" do
142
+ expected_html = <<-eos
143
+ <div class="tabbable">
144
+ <ul class="nav nav-tabs">
145
+ <li><a href="##{foo_tab_id}" data-toggle="tab">foo</a></li>
146
+ <li><a href="##{bar_tab_id}" data-toggle="tab">bar</a></li>
147
+ </ul>
148
+
149
+ <div class="tab-content">
150
+ <div class="tab-pane" id="#{foo_tab_id}">
151
+ foo content
152
+ </div>
153
+
154
+ <div class="tab-pane" id="#{bar_tab_id}">
155
+ bar content
156
+ </div>
157
+ </div>
158
+ </div>
159
+ eos
160
+
161
+ expected_html = strip_expected(expected_html)
162
+
163
+ html = tabbable do |bar|
164
+ bar.tab foo_tab_text
165
+ bar.tab bar_tab_text, active: false
166
+
167
+ bar.tab_pane do
168
+ "foo content"
169
+ end
170
+
171
+ bar.tab_pane active: false do
172
+ "bar content"
173
+ end
174
+ end
175
+
176
+ strip(html).should == expected_html
177
+ end
178
+ end
179
+
180
+ context "with direction" do
181
+ context "unspecified" do
182
+ let(:html_class) { "tabbable" }
183
+
184
+ it "should render a tabbable navigation with the tabs on top" do
185
+ html = tabbable(foo_tab_text, &block)
186
+ strip(html).should == expected_html
187
+ end
188
+ end
189
+
190
+ context "top" do
191
+ let(:html_class) { "tabbable" }
192
+
193
+ it "should render a tabbable navigation with the tabs on top" do
194
+ html = tabbable(foo_tab_text, direction: "top", &block)
195
+ strip(html).should == expected_html
196
+ end
197
+ end
198
+
199
+ context "bottom" do
200
+ let(:html_class) { "tabbable tabs-below" }
201
+
202
+ it "should render a tabbable navigation with the tabs on the bottom" do
203
+ html = tabbable(foo_tab_text, direction: "below", &block)
204
+ strip(html).should == expected_html
205
+ end
206
+ end
207
+
208
+ context "left" do
209
+ let(:html_class) { "tabbable tabs-left" }
210
+
211
+ it "should render a tabbable navigation with the tabs on the left" do
212
+ html = tabbable(foo_tab_text, direction: "left", &block)
213
+ strip(html).should == expected_html
214
+ end
215
+ end
216
+
217
+ context "right" do
218
+ let(:html_class) { "tabbable tabs-right" }
219
+
220
+ it "should render a tabbable navigation with the tabs on the right" do
221
+ html = tabbable(foo_tab_text, direction: "right", &block)
222
+ strip(html).should == expected_html
223
+ end
224
+ end
225
+ end
226
+ end
227
+ end
228
+ end