',
bootstrap_alert_tag(:warning, 'Apples', dismissible: false, id: 'apple_123')
assert bootstrap_alert_tag(:warning, unsafe_string).html_safe?,
'bootstrap_alert_tag is not html_safe'
end
test 'bootstrap_alert_tag with message block' do
assert_dom_equal '
',
bootstrap_alert_tag(:warning, dismissible: false, id: 'pear_123') {
'Pears'
}
html = bootstrap_alert_tag(:info, id: 'pear_123') { unsafe_string }
assert html.html_safe?, 'bootstrap_alert_tag is not html_safe'
end
test 'bootstrap_label_tag with message parameter' do
assert_dom_equal 'Pears',
bootstrap_label_tag(:default, 'Pears')
assert_dom_equal 'Pears',
bootstrap_label_tag(:success, 'Pears')
assert_dom_equal 'Pears',
bootstrap_label_tag(:warning, 'Pears')
assert_dom_equal 'Pears',
bootstrap_label_tag(:danger, 'Pears')
assert_dom_equal 'Pears',
bootstrap_label_tag(:info, 'Pears')
assert_dom_equal 'Pears',
bootstrap_label_tag(:primary, 'Pears')
assert bootstrap_label_tag(:warning, unsafe_string).html_safe?,
'bootstrap_label_tag is not html_safe'
end
test 'bootstrap_badge_tag with message parameter' do
assert_dom_equal 'Pears', bootstrap_badge_tag(:default, 'Pears')
assert_dom_equal 'Pears', bootstrap_badge_tag(:success, 'Pears')
assert_dom_equal 'Pears', bootstrap_badge_tag(:warning, 'Pears')
assert_dom_equal 'Pears', bootstrap_badge_tag(:important, 'Pears')
assert_dom_equal 'Pears', bootstrap_badge_tag(:info, 'Pears')
assert_dom_equal 'Pears', bootstrap_badge_tag(:inverse, 'Pears')
assert bootstrap_badge_tag(:warning, unsafe_string).html_safe?,
'bootstrap_badge_tag is not html_safe'
end
test 'bootstrap_caret_tag' do
assert_dom_equal '', bootstrap_caret_tag
assert bootstrap_caret_tag.html_safe?, 'bootstrap_caret_tag is not html_safe'
end
test 'bootstrap_dropdown_toggle_tag' do
assert_dom_equal 'Apples ' \
"#{bootstrap_caret_tag}",
bootstrap_dropdown_toggle_tag('Apples')
assert bootstrap_dropdown_toggle_tag(unsafe_string).html_safe?,
'bootstrap_dropdown_toggle_tag is not html_safe'
end
test 'bootstrap_icon_tag' do
assert_dom_equal '',
bootstrap_icon_tag(:search)
assert bootstrap_icon_tag(:search).html_safe?, 'bootstrap_caret_tag is not html_safe'
end
# TODO: bootstrap_icon_spinner(type = :default)
test 'bootstrap_tab_nav_tag' do
assert_dom_equal '
',
bootstrap_tab_nav_tag('Fruits', '#fruits', true)
end
test 'bootstrap_list_badge_and_link_to' do
stubs(:inbox_path).returns('/inbox')
stubs(:current_page?).returns(false)
refute current_page?(inbox_path)
html = content_tag(:div, bootstrap_badge_tag(:important, 99), class: 'pull-right') + 'Inbox'
assert_dom_equal "
#{link_to(html, inbox_path)}
",
bootstrap_list_badge_and_link_to(:important, 99, 'Inbox', inbox_path)
end
# TODO: list_group_link_to(*args, &block)
test 'bootstrap_abbreviation_tag' do
assert_dom_equal 'NPI',
bootstrap_abbreviation_tag('NPI', 'Nottingham Prognostic Index')
assert_dom_equal 'abbr',
bootstrap_abbreviation_tag('abbr', 'Abbreviation')
end
test 'bootstrap_form_for' do
@output_buffer = bootstrap_form_for(
:post,
url: posts_path,
html: { id: 'preserve_me' }
) do |form|
assert_kind_of BootstrapBuilder, form
end
assert_select 'form#preserve_me[autocomplete=off][action="/posts"]'
@output_buffer = bootstrap_form_for(
:post,
url: posts_path,
html: { id: 'preserve_me', class: 'form-inline' }
) do |form|
assert_kind_of BootstrapBuilder, form
end
assert_select 'form#preserve_me.form-inline[autocomplete=off][action="/posts"]'
@output_buffer = bootstrap_form_for(
:post,
url: posts_path,
horizontal: true, html: { id: 'preserve_me' }
) do |form|
assert_kind_of BootstrapBuilder, form
end
assert_select 'form#preserve_me.form-horizontal[autocomplete=off][action="/posts"]'
end
test 'bootstrap_form_for invalid autocomplete option' do
assert_raise RuntimeError do
bootstrap_form_for(:post, url: posts_path, autocomplete: 'on') do |form|
assert_kind_of BootstrapBuilder, form
end
end
end
# TODO: bootstrap_pagination_tag(*args, &block)
test 'button_control_group' do
assert_dom_equal '
' \
'Apples
',
button_control_group('Apples')
html = button_control_group(class: 'some_class') do
'Pears'
end
assert_dom_equal '
' \
'
Pears
',
html
html = button_control_group(horizontal: false, class: 'some_class') do
'Pears'
end
assert_dom_equal '
Pears
', html
end
test 'bootstrap_progressbar_tag' do
assert_dom_equal '
',
bootstrap_progressbar_tag(40, type: :success)
end
# TODO: bootstrap_form_div_start_tag
# TODO: bootstrap_form_div_end_tag
test 'bootstrap_horizontal_form_group' do
# Test with standard columns:
actual = bootstrap_horizontal_form_group('The Label') { 'This is the content' }
expected = '
This is the content
'
assert_dom_equal expected, actual
# Test with different columns:
actual = bootstrap_horizontal_form_group('The Label', [3, 9]) { 'This is the content' }
expected = '
This is the content
'
assert_dom_equal expected, actual
# Test with no label:
actual = bootstrap_horizontal_form_group { 'This is the content' }
expected = '
' \
'This is the content
'
assert_dom_equal expected, actual
# Test with no label and different columns:
actual = bootstrap_horizontal_form_group([1, 11]) { 'This is the content' }
expected = '
' \
'This is the content
'
assert_dom_equal expected, actual
end
test 'description_list_name_value_pair' do
assert_dom_equal '
',
description_list_name_value_pair('Pear', nil, '[none]')
end
test 'bootstrap_button_toolbar' do
actual = button_toolbar do
link_to('Hello World', '#')
end
expected = '
'
assert_dom_equal expected, actual
end
test 'bootstrap_details_link' do
actual = details_link('#')
expected = '' \
''
assert_dom_equal expected, actual
end
test 'bootstrap_edit_link' do
actual = edit_link('#')
expected = '' \
''
assert_dom_equal expected, actual
end
test 'bootstrap_delete_link' do
actual = delete_link('#')
expected = '' \
''
assert_dom_equal expected, actual
end
test 'bootstrap_link_to_with_icon' do
actual = link_to_with_icon(icon: 'trash icon-white', title: 'Delete', path: '#')
expected = '' \
''
assert_dom_equal expected, actual
end
# TODO: bootstrap_will_paginate(collection = nil, options = {})
end
end