bootstrap_it 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +6 -1
  3. data/bootstrap_it.gemspec +9 -8
  4. data/lib/bootstrap_it/config.rb +1 -1
  5. data/lib/bootstrap_it/engine.rb +1 -1
  6. data/lib/bootstrap_it/version.rb +1 -1
  7. data/lib/bootstrap_it/view_helpers.rb +4 -1
  8. data/lib/bootstrap_it/view_helpers/breadcrumb.rb +3 -2
  9. data/lib/bootstrap_it/view_helpers/button.rb +47 -39
  10. data/lib/bootstrap_it/view_helpers/button_group.rb +23 -4
  11. data/lib/bootstrap_it/view_helpers/dropdown_menu.rb +6 -5
  12. data/lib/bootstrap_it/view_helpers/form.rb +40 -41
  13. data/lib/bootstrap_it/view_helpers/grid.rb +9 -5
  14. data/lib/bootstrap_it/view_helpers/icon.rb +4 -2
  15. data/lib/bootstrap_it/view_helpers/list.rb +5 -5
  16. data/lib/bootstrap_it/view_helpers/misc.rb +37 -36
  17. data/lib/bootstrap_it/view_helpers/mixin.rb +16 -24
  18. data/lib/bootstrap_it/view_helpers/nav.rb +23 -21
  19. data/lib/bootstrap_it/view_helpers/pagination.rb +8 -6
  20. data/lib/bootstrap_it/view_helpers/table.rb +6 -10
  21. data/lib/bootstrap_it/view_helpers/text.rb +10 -8
  22. data/spec/spec_helper.rb +5 -2
  23. data/spec/support/example_groups/view_helpers_example_group.rb +4 -5
  24. data/spec/view_helpers/breadcrumb_spec.rb +8 -4
  25. data/spec/view_helpers/button_group_spec.rb +4 -4
  26. data/spec/view_helpers/button_spec.rb +25 -23
  27. data/spec/view_helpers/button_toolbar_spec.rb +3 -3
  28. data/spec/view_helpers/dropdown_menu_spec.rb +9 -9
  29. data/spec/view_helpers/form_spec.rb +4 -4
  30. data/spec/view_helpers/grid_spec.rb +5 -5
  31. data/spec/view_helpers/icon_spec.rb +2 -2
  32. data/spec/view_helpers/list_spec.rb +9 -9
  33. data/spec/view_helpers/misc_spec.rb +11 -11
  34. data/spec/view_helpers/mixin_spec.rb +49 -38
  35. data/spec/view_helpers/nav_spec.rb +14 -10
  36. data/spec/view_helpers/pagination_spec.rb +6 -6
  37. data/spec/view_helpers/table_spec.rb +9 -10
  38. data/spec/view_helpers/text_spec.rb +3 -3
  39. data/spec/views/examples_spec.rb +49 -36
  40. metadata +31 -32
  41. data/lib/bootstrap_it/view_helpers/button_toolbar.rb +0 -21
@@ -4,8 +4,9 @@ module BootstrapIt
4
4
  #
5
5
  # Pagination
6
6
  #
7
- # @author [alexiss]
7
+ # @author Alexey Ovchinnikov <alexiss@cybernetlab.ru>
8
8
  #
9
+ # @see http://getbootstrap.com/components/#pagination Bootstrap docs
9
10
  class Pagination < WrapIt::Container
10
11
  include Sizable
11
12
 
@@ -18,17 +19,18 @@ module BootstrapIt
18
19
  #
19
20
  # Pager
20
21
  #
21
- # @author [alexiss]
22
+ # @author Alexey Ovchinnikov <alexiss@cybernetlab.ru>
22
23
  #
24
+ # @see http://getbootstrap.com/components/#pagination-pager Bootstrap docs
23
25
  class Pager < WrapIt::Container
24
26
  default_tag 'ul'
25
27
  html_class 'pager'
26
28
  child :link_item, ListLinkItem
27
- child :previous, ListLinkItem, [li_class: 'previous']
28
- child :next, ListLinkItem, [li_class: 'next']
29
+ child :previous, ListLinkItem, li_class: 'previous'
30
+ child :next, ListLinkItem, li_class: 'next'
29
31
  end
30
32
 
31
- WrapIt.register :pagination, 'BootstrapIt::ViewHelpers::Pagination'
32
- WrapIt.register :pager, 'BootstrapIt::ViewHelpers::Pager'
33
+ register :pagination, 'BootstrapIt::ViewHelpers::Pagination'
34
+ register :pager, 'BootstrapIt::ViewHelpers::Pager'
33
35
  end
34
36
  end
@@ -4,8 +4,9 @@ module BootstrapIt
4
4
  #
5
5
  # Table
6
6
  #
7
- # @author [alexiss]
7
+ # @author Alexey Ovchinnikov <alexiss@cybernetlab.ru>
8
8
  #
9
+ # @see http://getbootstrap.com/css/#tables Bootstrap docs
9
10
  class Table < WrapIt::Container
10
11
  html_class 'table'
11
12
  html_class_prefix 'table-'
@@ -21,17 +22,12 @@ module BootstrapIt
21
22
  child :row, 'BootstrapIt::ViewHelpers::TableRow'
22
23
 
23
24
  after_initialize { @tag = 'table' }
24
-
25
- # TODO: remove it since WrapIt 0.1.5
26
- def unwrap
27
- @wrapper = nil
28
- end
29
25
  end
30
26
 
31
27
  #
32
28
  # TableRow
33
29
  #
34
- # @author [alexiss]
30
+ # @author Alexey Ovchinnikov <alexiss@cybernetlab.ru>
35
31
  #
36
32
  class TableRow < WrapIt::Container
37
33
  include Contextual
@@ -39,7 +35,7 @@ module BootstrapIt
39
35
  child :cell, 'BootstrapIt::ViewHelpers::TableCell'
40
36
  alias_method :td, :cell
41
37
 
42
- child :head, 'BootstrapIt::ViewHelpers::TableCell', [tag: 'th']
38
+ child :head, 'BootstrapIt::ViewHelpers::TableCell', tag: 'th'
43
39
  alias_method :th, :head
44
40
  alias_method :header, :head
45
41
 
@@ -49,7 +45,7 @@ module BootstrapIt
49
45
  #
50
46
  # TableCell
51
47
  #
52
- # @author [alexiss]
48
+ # @author Alexey Ovchinnikov <alexiss@cybernetlab.ru>
53
49
  #
54
50
  class TableCell < WrapIt::Base
55
51
  include WrapIt::TextContainer
@@ -67,6 +63,6 @@ module BootstrapIt
67
63
  end
68
64
  end
69
65
 
70
- WrapIt.register :table, 'BootstrapIt::ViewHelpers::Table'
66
+ register :table, 'BootstrapIt::ViewHelpers::Table'
71
67
  end
72
68
  end
@@ -4,7 +4,7 @@ module BootstrapIt
4
4
  #
5
5
  # Text
6
6
  #
7
- # @author [alexiss]
7
+ # @author Alexey Ovchinnikov <alexiss@cybernetlab.ru>
8
8
  #
9
9
  class Text < WrapIt::Base
10
10
  include WrapIt::TextContainer
@@ -16,8 +16,9 @@ module BootstrapIt
16
16
  #
17
17
  # Label
18
18
  #
19
- # @author [alexiss]
19
+ # @author Alexey Ovchinnikov <alexiss@cybernetlab.ru>
20
20
  #
21
+ # @see http://getbootstrap.com/components/#labels Bootstrap docs
21
22
  class Label < Text
22
23
  default_tag 'span'
23
24
  html_class 'label'
@@ -29,18 +30,19 @@ module BootstrapIt
29
30
  #
30
31
  # Badge
31
32
  #
32
- # @author [alexiss]
33
+ # @author Alexey Ovchinnikov <alexiss@cybernetlab.ru>
33
34
  #
35
+ # @see http://getbootstrap.com/components/#badges Bootstrap docs
34
36
  # TODO: right-alignment
35
37
  class Badge < Text
36
38
  default_tag 'span'
37
39
  html_class 'badge'
38
40
  end
39
41
 
40
- WrapIt.register :text, 'BootstrapIt::ViewHelpers::Text'
41
- WrapIt.register :p, 'BootstrapIt::ViewHelpers::Text'
42
- WrapIt.register :span, 'BootstrapIt::ViewHelpers::Text'
43
- WrapIt.register :label, 'BootstrapIt::ViewHelpers::Label'
44
- WrapIt.register :badge, 'BootstrapIt::ViewHelpers::Badge'
42
+ register :text, 'BootstrapIt::ViewHelpers::Text'
43
+ register :p, 'BootstrapIt::ViewHelpers::Text'
44
+ register :span, 'BootstrapIt::ViewHelpers::Text'
45
+ register :label, 'BootstrapIt::ViewHelpers::Label'
46
+ register :badge, 'BootstrapIt::ViewHelpers::Badge'
45
47
  end
46
48
  end
@@ -1,11 +1,14 @@
1
1
  require 'rubygems'
2
2
  require 'bundler'
3
+
4
+ require 'rspec-html-matchers'
5
+
3
6
  #Bundler.require :default, :development
4
7
  #Bundler.require :development
5
8
  #puts "--- #{Object.constants}"
6
9
 
7
10
  require 'combustion'
8
- require 'capybara/rspec'
11
+ # require 'capybara/rspec'
9
12
 
10
13
  Dir[File.join File.dirname(__FILE__), 'support', '**', '*.rb'].each {|file| require file}
11
14
 
@@ -14,7 +17,7 @@ Combustion.initialize! :action_controller, :action_view, :sprockets do |app|
14
17
  # app.config.sass.cache = false
15
18
  end
16
19
 
17
- Capybara.app = Combustion::Application
20
+ # Capybara.app = Combustion::Application
18
21
 
19
22
  require 'rspec/rails'
20
23
  #require 'capybara/rails'
@@ -41,15 +41,14 @@ module ViewHelpersExampleGroup
41
41
  end
42
42
  end
43
43
 
44
+ =begin
44
45
  RSpec::Matchers.define :render_with do |selector, options = {}|
45
46
  match_for_should do |actual|
46
- Capybara::Node::Simple.new(actual.render)
47
- .has_selector?(selector, options)
47
+ actual.render.has_tag?(selector, options)
48
48
  end
49
49
 
50
50
  match_for_should_not do |actual|
51
- Capybara::Node::Simple.new(actual.render)
52
- .has_no_selector?(selector, options)
51
+ actual.render.has_no_tag?(selector, options)
53
52
  end
54
53
 
55
54
  failure_message_for_should do |actual|
@@ -60,7 +59,7 @@ module ViewHelpersExampleGroup
60
59
  "expected that #{actual.render} would not have selector #{selector}"
61
60
  end
62
61
  end
63
-
62
+ =end
64
63
  RSpec::Matchers.define :have_flag do |flag|
65
64
  chain :with do |options|
66
65
  @options = options
@@ -1,12 +1,16 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe BootstrapIt::ViewHelpers::Breadcrumb do
4
- it { expect(helper).to render_with 'ol.breadcrumb' }
4
+ it { expect(helper.render).to have_tag 'ol.breadcrumb' }
5
5
  it { expect(helper).to be_kind_of WrapIt::Container }
6
- it { expect(helper { |h| h.item :active }).to render_with 'ol > li.active' }
6
+
7
+ it 'renders active items' do
8
+ expect(helper { |h| h.item :active }.render).to have_tag 'ol > li.active'
9
+ end
10
+
7
11
  it 'reders links' do
8
12
  expect(
9
- helper { |h| h.link_item 'test', 'http://url' }
10
- ).to render_with 'ol > li > a[@href="http://url"][text()="test"]'
13
+ helper { |h| h.link_item 'test', 'http://url' }.render
14
+ ).to have_tag 'ol > li > a[@href="http://url"][text()="test"]'
11
15
  end
12
16
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe BootstrapIt::ViewHelpers::ButtonGroup do
4
- it { expect(helper).to render_with 'div.btn-group' }
4
+ it { expect(helper.render).to have_tag 'div.btn-group' }
5
5
 
6
6
  # behaviour
7
7
  it { expect(helper).to be_kind_of BootstrapIt::ViewHelpers::Sizable }
@@ -16,20 +16,20 @@ describe BootstrapIt::ViewHelpers::ButtonGroup do
16
16
 
17
17
  # buttons
18
18
  it 'renders buttons' do
19
- expect(helper { |h| h.button 'test' }).to render_with(
19
+ expect(helper { |h| h.button 'test' }.render).to have_tag(
20
20
  'div.btn-group > button.btn.btn-default[text()="test"]'
21
21
  )
22
22
  end
23
23
 
24
24
  it 'renders radios' do
25
- expect(helper { |h| h.radio 'test' }).to render_with(
25
+ expect(helper { |h| h.radio 'test' }.render).to have_tag(
26
26
  'div.btn-group[@data-toggle="buttons"]' \
27
27
  ' > label.btn.btn-default[text()="test"] > input[@type="radio"]'
28
28
  )
29
29
  end
30
30
 
31
31
  it 'renders checkboxes' do
32
- expect(helper { |h| h.checkbox 'test' }).to render_with(
32
+ expect(helper { |h| h.checkbox 'test' }.render).to have_tag(
33
33
  'div.btn-group[@data-toggle="buttons"]' \
34
34
  ' > label.btn.btn-default[text()="test"] > input[@type="checkbox"]'
35
35
  )
@@ -1,32 +1,32 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe BootstrapIt::ViewHelpers::Button do
4
- it { expect(helper).to render_with 'button.btn.btn-default[@type="button"]' }
4
+ it { expect(helper.render).to have_tag 'button.btn.btn-default[@type="button"]' }
5
5
 
6
6
  it 'allows `submit` type' do
7
- expect(helper type: 'submit').to render_with(
7
+ expect(helper(type: 'submit').render).to have_tag(
8
8
  'button.btn.btn-default[@type="submit"]'
9
9
  )
10
10
  end
11
11
 
12
12
  it 'allows `a` tag' do
13
- expect(helper tag: :a).to render_with 'a.btn.btn-default[@role="button"]'
13
+ expect(helper(tag: :a).render).to have_tag 'a.btn.btn-default[@role="button"]'
14
14
  end
15
15
 
16
16
  it 'allows `input` tag' do
17
- expect(helper tag: :input).to render_with(
17
+ expect(helper(tag: :input).render).to have_tag(
18
18
  'input.btn.btn-default[@type="button"]'
19
19
  )
20
20
  end
21
21
 
22
22
  it 'allows `input` with `submit` type' do
23
- expect(helper tag: :input, type: :submit).to render_with(
23
+ expect(helper(tag: :input, type: :submit).render).to have_tag(
24
24
  'input.btn.btn-default[@type="submit"]'
25
25
  )
26
26
  end
27
27
 
28
28
  it 'changes custom tags to `button`' do
29
- expect(helper tag: :p).to render_with 'button.btn.btn-default'
29
+ expect(helper(tag: :p).render).to have_tag 'button.btn.btn-default'
30
30
  end
31
31
 
32
32
  # method returns safety
@@ -43,13 +43,13 @@ describe BootstrapIt::ViewHelpers::Button do
43
43
 
44
44
  # icons
45
45
  it 'renders icon throw options' do
46
- expect(helper icon: :bell).to render_with(
46
+ expect(helper(icon: :bell).render).to have_tag(
47
47
  'button.btn.btn-default > i.fa.fa-bell'
48
48
  )
49
49
  end
50
50
 
51
51
  it 'renders icon with helper' do
52
- expect(helper { |b| b.icon :star }).to render_with(
52
+ expect(helper { |b| b.icon :star }.render).to have_tag(
53
53
  'button.btn.btn-default > i.fa.fa-star'
54
54
  )
55
55
  end
@@ -66,7 +66,7 @@ describe BootstrapIt::ViewHelpers::Button do
66
66
  value: 'v1',
67
67
  class: 'someclass',
68
68
  helper_name: 'radio'
69
- )).to render_with(
69
+ ).render).to have_tag(
70
70
  'label.btn.btn-default.someclass[text()="text"][@label_for="option1"]' \
71
71
  ' > input[@type="radio"][@name="group-name"][@id="option1"]' \
72
72
  '[@value="v1"]'
@@ -82,7 +82,7 @@ describe BootstrapIt::ViewHelpers::Button do
82
82
  value: 'v1',
83
83
  class: 'someclass',
84
84
  helper_name: 'checkbox'
85
- )).to render_with(
85
+ ).render).to have_tag(
86
86
  'label.btn.btn-default.someclass[text()="text"] >' \
87
87
  ' input[@type="checkbox"][@name="group-name"]' \
88
88
  '[@id="option1"][@value="v1"]'
@@ -91,11 +91,13 @@ describe BootstrapIt::ViewHelpers::Button do
91
91
 
92
92
  # toggling
93
93
  it { expect(helper).to have_flag :toggle }
94
- it { expect(helper :toggle).to render_with 'button[@data-toggle="button"]' }
94
+ it 'renders button with toggle data' do
95
+ expect(helper(:toggle).render).to have_tag 'button[@data-toggle="button"]'
96
+ end
95
97
 
96
98
  # state text
97
99
  it 'extracts state text from options' do
98
- expect(helper loading_text: 'text').to render_with(
100
+ expect(helper(loading_text: 'text').render).to have_tag(
99
101
  'button[@data-loading-text="text"]'
100
102
  )
101
103
  end
@@ -122,14 +124,14 @@ describe BootstrapIt::ViewHelpers::DropdownButton do
122
124
 
123
125
  # dropdown
124
126
  it 'renders dropdown toggle' do
125
- expect(helper('action text') { |b| b.divider }).to render_with(
127
+ expect(helper('action text') { |b| b.divider }.render).to have_tag(
126
128
  'div.btn-group > button.dropdown-toggle[@data-toggle="dropdown"]' \
127
- '[text()="action text"] > span.caret'
129
+ '[text()="action text "] > span.caret'
128
130
  )
129
131
  end
130
132
 
131
133
  it 'renders dropdown menu' do
132
- expect(helper('action text') { |b| b.divider }).to render_with(
134
+ expect(helper('action text') { |b| b.divider }.render).to have_tag(
133
135
  'div.btn-group > button + ul.dropdown-menu > li.divider'
134
136
  )
135
137
  end
@@ -138,14 +140,14 @@ describe BootstrapIt::ViewHelpers::DropdownButton do
138
140
 
139
141
  it 'renders splitted toggle button' do
140
142
  expect(
141
- helper(:splitted, :danger, 'action') { |b| b.divider }
142
- ).to render_with 'div.btn-group > button.btn-danger[text()="action"]'
143
+ helper(:splitted, :danger, 'action') { |b| b.divider }.render
144
+ ).to have_tag 'div.btn-group > button.btn-danger[text()="action"]'
143
145
  end
144
146
 
145
147
  it 'renders spliited toggle' do
146
148
  expect(
147
- helper(:splitted, :danger, 'action') { |b| b.divider }
148
- ).to render_with(
149
+ helper(:splitted, :danger, 'action') { |b| b.divider }.render
150
+ ).to have_tag(
149
151
  'div.btn-group' \
150
152
  ' > button.btn-danger.dropdown-toggle[@data-toggle="dropdown"]' \
151
153
  ' > span.caret'
@@ -154,8 +156,8 @@ describe BootstrapIt::ViewHelpers::DropdownButton do
154
156
 
155
157
  it 'renders splitted dropdown menu' do
156
158
  expect(
157
- helper(:splitted, :danger, 'action') { |b| b.divider }
158
- ).to render_with 'div.btn-group > ul.dropdown-menu > li.divider'
159
+ helper(:splitted, :danger, 'action') { |b| b.divider }.render
160
+ ).to have_tag 'div.btn-group > ul.dropdown-menu > li.divider'
159
161
  end
160
162
 
161
163
  # dropup
@@ -163,7 +165,7 @@ describe BootstrapIt::ViewHelpers::DropdownButton do
163
165
 
164
166
  it 'renders dropup' do
165
167
  expect(
166
- helper(:dropup) { |b| b.divider }
167
- ).to render_with 'div.btn-group.dropup'
168
+ helper(:dropup) { |b| b.divider }.render
169
+ ).to have_tag 'div.btn-group.dropup'
168
170
  end
169
171
  end
@@ -1,12 +1,12 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe BootstrapIt::ViewHelpers::ButtonToolbar do
4
- it { expect(helper).to render_with 'div.btn-toolbar[@role="toolbar"]' }
4
+ it { expect(helper.render).to have_tag 'div.btn-toolbar[@role="toolbar"]' }
5
5
 
6
6
  it 'reders button group' do
7
7
  expect(
8
- helper { |h| h.button_group { |g| g.button 'test' } }
9
- ).to render_with(
8
+ helper { |h| h.button_group { |g| g.button 'test' } }.render
9
+ ).to have_tag(
10
10
  'div.btn-toolbar > div.btn-group' \
11
11
  ' > button.btn.btn-default[text()="test"]'
12
12
  )
@@ -1,22 +1,22 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe BootstrapIt::ViewHelpers::DropdownMenu do
4
- it { expect(helper).to render_with 'ul.dropdown-menu[@role="menu"]' }
4
+ it { expect(helper.render).to have_tag 'ul.dropdown-menu[@role="menu"]' }
5
5
 
6
6
  it 'reders devider' do
7
- expect(helper { |h| h.divider }).to render_with(
7
+ expect(helper { |h| h.divider }.render).to have_tag(
8
8
  'ul > li.divider[@role="presentation"]'
9
9
  )
10
10
  end
11
11
 
12
12
  it 'renders header' do
13
- expect(helper { |h| h.header 'test' }).to render_with(
13
+ expect(helper { |h| h.header 'test' }.render).to have_tag(
14
14
  'ul > li.dropdown-header[@role="presentation"]'
15
15
  )
16
16
  end
17
17
 
18
18
  it 'renders link item' do
19
- expect(helper { |h| h.link_item 'test', 'http://url' }).to render_with(
19
+ expect(helper { |h| h.link_item 'test', 'http://url' }.render).to have_tag(
20
20
  'ul > li[@role="presentation"]' \
21
21
  ' > a[@href="http://url"][@role="menuitem"][@tabindex="-1"]'
22
22
  )
@@ -24,18 +24,18 @@ describe BootstrapIt::ViewHelpers::DropdownMenu do
24
24
 
25
25
  it 'renders disabled link item' do
26
26
  expect(
27
- helper { |h| h.link_item 'test', :disabled, 'http://url' }
28
- ).to render_with(
27
+ helper { |h| h.link_item 'test', :disabled, 'http://url' }.render
28
+ ).to have_tag(
29
29
  'ul > li.disabled[@role="presentation"]' \
30
30
  ' > a[@href="http://url"][@role="menuitem"][@tabindex="-1"]'
31
31
  )
32
32
  end
33
33
 
34
34
  it 'supports right-align' do
35
- expect(helper align: :right).to render_with 'ul.dropdown-menu.pull-right'
35
+ expect(helper(align: :right).render).to have_tag 'ul.dropdown-menu.pull-right'
36
36
  end
37
37
 
38
38
  # options cleaning
39
- it { expect(helper align: 'right').to_not have_option :align }
40
- it { expect(helper align: :none).to_not have_option :align }
39
+ it { expect(helper(align: 'right')).to_not have_option :align }
40
+ it { expect(helper(align: :none)).to_not have_option :align }
41
41
  end