diff --git a/test/bootstrap_checkbox_test.rb b/test/bootstrap_checkbox_test.rb
index 78f192831..0993a6ca5 100644
--- a/test/bootstrap_checkbox_test.rb
+++ b/test/bootstrap_checkbox_test.rb
@@ -1,81 +1,204 @@
-require 'test_helper'
+require_relative "./test_helper"
class BootstrapCheckboxTest < ActionView::TestCase
include BootstrapForm::Helper
- def setup
- setup_test_fixture
- end
+ setup :setup_test_fixture
test "check_box is wrapped correctly" do
- expected = %{
}
+ expected = <<-HTML.strip_heredoc
+
+
+
+ HTML
assert_equivalent_xml expected, @builder.check_box(:terms, label: 'I agree to the terms')
end
test "disabled check_box has proper wrapper classes" do
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+
+
+ HTML
assert_equivalent_xml expected, @builder.check_box(:terms, label: 'I agree to the terms', disabled: true)
end
test "check_box label allows html" do
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+
+
+ HTML
assert_equivalent_xml expected, @builder.check_box(:terms, label: %{I agree to the terms}.html_safe)
end
test "check_box accepts a block to define the label" do
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+
+
+ HTML
assert_equivalent_xml expected, @builder.check_box(:terms) { "I agree to the terms" }
end
test "check_box accepts a custom label class" do
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+
+
+ HTML
assert_equivalent_xml expected, @builder.check_box(:terms, label_class: 'btn')
end
test "check_box responds to checked_value and unchecked_value arguments" do
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+
+
+ HTML
assert_equivalent_xml expected, @builder.check_box(:terms, {label: 'I agree to the terms'}, 'yes', 'no')
end
test "inline checkboxes" do
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+ HTML
assert_equivalent_xml expected, @builder.check_box(:terms, label: 'I agree to the terms', inline: true)
end
test "disabled inline check_box" do
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+ HTML
assert_equivalent_xml expected, @builder.check_box(:terms, label: 'I agree to the terms', inline: true, disabled: true)
end
test "inline checkboxes with custom label class" do
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+ HTML
assert_equivalent_xml expected, @builder.check_box(:terms, inline: true, label_class: 'btn')
end
test 'collection_check_boxes renders the form_group correctly' do
collection = [Address.new(id: 1, street: 'Foobar')]
- expected = %{
With a help!
}
+ expected = <<-HTML.strip_heredoc
+
+
+
+
+
+
+ With a help!
+
+ HTML
assert_equivalent_xml expected, @builder.collection_check_boxes(:misc, collection, :id, :street, label: 'This is a checkbox collection', help: 'With a help!')
end
test 'collection_check_boxes renders multiple checkboxes correctly' do
collection = [Address.new(id: 1, street: 'Foo'), Address.new(id: 2, street: 'Bar')]
- expected = %{
}
+ expected = <<-HTML.strip_heredoc
+
+
+
+
+
+
+
+
+
+
+ HTML
assert_equivalent_xml expected, @builder.collection_check_boxes(:misc, collection, :id, :street)
end
test 'collection_check_boxes renders inline checkboxes correctly' do
collection = [Address.new(id: 1, street: 'Foo'), Address.new(id: 2, street: 'Bar')]
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+
+
+
+
+
+ HTML
assert_equivalent_xml expected, @builder.collection_check_boxes(:misc, collection, :id, :street, inline: true)
end
test 'collection_check_boxes renders with checked option correctly' do
collection = [Address.new(id: 1, street: 'Foo'), Address.new(id: 2, street: 'Bar')]
- expected = %{
+ HTML
assert_equivalent_xml expected, @builder.collection_check_boxes(:misc, collection, lambda { |a| "address_#{a.id}" }, :street, checked: ["address_1", "address_2"])
assert_equivalent_xml expected, @builder.collection_check_boxes(:misc, collection, lambda { |a| "address_#{a.id}" }, :street, checked: collection)
end
test "check_box is wrapped correctly with custom option set" do
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+
+
+
+
+ HTML
assert_equivalent_xml expected, @builder.check_box(:terms, {label: 'I agree to the terms', custom: true})
end
test "check_box is wrapped correctly with custom and inline options set" do
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+
+
+
+
+ HTML
assert_equivalent_xml expected, @builder.check_box(:terms, {label: 'I agree to the terms', inline: true, custom: true})
end
test "check_box is wrapped correctly with custom and disabled options set" do
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+
+
+
+
+ HTML
assert_equivalent_xml expected, @builder.check_box(:terms, {label: 'I agree to the terms', disabled: true, custom: true})
end
test "check_box is wrapped correctly with custom, inline and disabled options set" do
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+
+
+
+
+ HTML
assert_equivalent_xml expected, @builder.check_box(:terms, {label: 'I agree to the terms', inline: true, disabled: true, custom: true})
end
end
diff --git a/test/bootstrap_fields_test.rb b/test/bootstrap_fields_test.rb
index 021c8a0e5..dcba190b9 100644
--- a/test/bootstrap_fields_test.rb
+++ b/test/bootstrap_fields_test.rb
@@ -1,39 +1,67 @@
-require 'test_helper'
+require_relative "./test_helper"
class BootstrapFieldsTest < ActionView::TestCase
include BootstrapForm::Helper
- def setup
- setup_test_fixture
- end
+ setup :setup_test_fixture
test "color fields are wrapped correctly" do
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+
+
+
+ HTML
assert_equivalent_xml expected, @builder.color_field(:misc)
end
test "date fields are wrapped correctly" do
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+
+
+
+ HTML
assert_equivalent_xml expected, @builder.date_field(:misc)
end
test "date time fields are wrapped correctly" do
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+
+
+
+ HTML
assert_equivalent_xml expected, @builder.datetime_field(:misc)
end
test "date time local fields are wrapped correctly" do
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+
+
+
+ HTML
assert_equivalent_xml expected, @builder.datetime_local_field(:misc)
end
test "email fields are wrapped correctly" do
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+
+
+
+ HTML
assert_equivalent_xml expected, @builder.email_field(:misc)
end
test "file fields are wrapped correctly" do
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+
+
+
+ HTML
assert_equivalent_xml expected, @builder.file_field(:misc)
end
@@ -43,58 +71,114 @@ def setup
end
test "month local fields are wrapped correctly" do
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+
+
+
+ HTML
assert_equivalent_xml expected, @builder.month_field(:misc)
end
test "number fields are wrapped correctly" do
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+
+
+
+ HTML
assert_equivalent_xml expected, @builder.number_field(:misc)
end
test "password fields are wrapped correctly" do
- expected = %{
A good password should be at least six characters long
}
+ expected = <<-HTML.strip_heredoc
+
+
+
+ A good password should be at least six characters long
+
+ HTML
assert_equivalent_xml expected, @builder.password_field(:password)
end
test "phone/telephone fields are wrapped correctly" do
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+
+
+
+ HTML
assert_equivalent_xml expected, @builder.phone_field(:misc)
assert_equivalent_xml expected, @builder.telephone_field(:misc)
end
test "range fields are wrapped correctly" do
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+
+
+
+ HTML
assert_equivalent_xml expected, @builder.range_field(:misc)
end
test "search fields are wrapped correctly" do
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+
+
+
+ HTML
assert_equivalent_xml expected, @builder.search_field(:misc)
end
test "text areas are wrapped correctly" do
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+
+
+
+ HTML
assert_equivalent_xml expected, @builder.text_area(:comments)
end
test "text fields are wrapped correctly" do
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+
+
+
+ HTML
assert_equivalent_xml expected, @builder.text_field(:email)
end
test "time fields are wrapped correctly" do
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+
+
+
+ HTML
assert_equivalent_xml expected, @builder.time_field(:misc)
end
test "url fields are wrapped correctly" do
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+
+
+
+ HTML
assert_equivalent_xml expected, @builder.url_field(:misc)
end
test "week fields are wrapped correctly" do
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+
+
+
+ HTML
assert_equivalent_xml expected, @builder.week_field(:misc)
end
@@ -107,7 +191,15 @@ def setup
end
end
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+ HTML
assert_equivalent_xml expected, output
end
@@ -120,7 +212,15 @@ def setup
end
end
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+ HTML
assert_equivalent_xml expected, output
end
@@ -133,7 +233,17 @@ def setup
end
end
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+ HTML
assert_equivalent_xml expected, output
end
@@ -146,7 +256,15 @@ def setup
end
end
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+ HTML
assert_equivalent_xml expected, output
end
end
diff --git a/test/bootstrap_form_group_test.rb b/test/bootstrap_form_group_test.rb
index b41407e54..d0332578c 100644
--- a/test/bootstrap_form_group_test.rb
+++ b/test/bootstrap_form_group_test.rb
@@ -1,59 +1,116 @@
-require 'test_helper'
+require_relative "./test_helper"
class BootstrapFormGroupTest < ActionView::TestCase
include BootstrapForm::Helper
- def setup
- setup_test_fixture
- end
+ setup :setup_test_fixture
test "changing the label text via the label option parameter" do
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+
+
+
+ HTML
assert_equivalent_xml expected, @builder.text_field(:email, label: 'Email Address')
end
test "changing the label text via the html_options label hash" do
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+
+
+
+ HTML
assert_equivalent_xml expected, @builder.text_field(:email, label: {text: 'Email Address'})
end
test "hiding a label" do
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+
+
+
+ HTML
assert_equivalent_xml expected, @builder.text_field(:email, hide_label: true)
end
test "adding a custom label class via the label_class parameter" do
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+
+
+
+ HTML
assert_equivalent_xml expected, @builder.text_field(:email, label_class: 'btn')
end
test "adding a custom label class via the html_options label hash" do
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+
+
+
+ HTML
assert_equivalent_xml expected, @builder.text_field(:email, label: {class: 'btn'})
end
test "adding a custom label and changing the label text via the html_options label hash" do
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+
+
+
+ HTML
assert_equivalent_xml expected, @builder.text_field(:email, label: {class: 'btn', text: "Email Address"})
end
test "skipping a label" do
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+
+
+ HTML
assert_equivalent_xml expected, @builder.text_field(:email, skip_label: true)
end
test "preventing a label from having the required class" do
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+
+
+
+ HTML
assert_equivalent_xml expected, @builder.text_field(:email, skip_required: true)
end
test "adding prepend text" do
- expected = %{
@
}
+ expected = <<-HTML.strip_heredoc
+
+
+
+
+ @
+
+
+
+
+ HTML
assert_equivalent_xml expected, @builder.text_field(:email, prepend: '@')
end
test "adding append text" do
- expected = %{
.00
}
+ expected = <<-HTML.strip_heredoc
+
+
+
+
+
+ .00
+
+
+
+ HTML
assert_equivalent_xml expected, @builder.text_field(:email, append: '.00')
end
@@ -73,22 +130,55 @@ def setup
end
test "adding both prepend and append text" do
- expected = %{
$
.00
}
+ expected = <<-HTML.strip_heredoc
+
+
+
+
+ $
+
+
+
+ .00
+
+
+
+ HTML
assert_equivalent_xml expected, @builder.text_field(:email, prepend: '$', append: '.00')
end
test "help messages for default forms" do
- expected = %{
This is required
}
+ expected = <<-HTML.strip_heredoc
+
+
+
+ This is required
+
+ HTML
assert_equivalent_xml expected, @builder.text_field(:email, help: 'This is required')
end
test "help messages for horizontal forms" do
- expected = %{
This is required
}
+ expected = <<-HTML.strip_heredoc
+
+
+
+
+ This is required
+
+
+ HTML
assert_equivalent_xml expected, @horizontal_builder.text_field(:email, help: "This is required")
end
test "help messages to look up I18n automatically" do
- expected = %{
A good password should be at least six characters long
}
+ expected = <<-HTML.strip_heredoc
+
+
+
+ A good password should be at least six characters long
+
+ HTML
assert_equivalent_xml expected, @builder.text_field(:password)
end
@@ -111,7 +201,12 @@ def setup
end
test "help messages to ignore translation when user disables help" do
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+
+
+
+ HTML
assert_equivalent_xml expected, @builder.text_field(:password, help: false)
end
@@ -120,7 +215,14 @@ def setup
%{
Bar
}.html_safe
end
- expected = %{
Bar
}
+ expected = <<-HTML.strip_heredoc
+
+
+
+
Bar
+
+
+ HTML
assert_equivalent_xml expected, output
end
@@ -129,7 +231,13 @@ def setup
%{
Bar
}.html_safe
end
- expected = %{
Bar
}
+ expected = <<-HTML.strip_heredoc
+
+
+
Bar
+
+
+ HTML
assert_equivalent_xml expected, output
end
@@ -138,7 +246,14 @@ def setup
%{
Bar
}.html_safe
end
- expected = %{
Bar
}
+ expected = <<-HTML.strip_heredoc
+
+
+
+
Bar
+
+
+ HTML
assert_equivalent_xml expected, output
end
@@ -147,7 +262,13 @@ def setup
%{
Bar
}.html_safe
end
- expected = %{
Bar
}
+ expected = <<-HTML.strip_heredoc
+
+
+
Bar
+
+
+ HTML
assert_equivalent_xml expected, output
end
@@ -156,7 +277,13 @@ def setup
%{
Bar
}.html_safe
end
- expected = %{
Bar
}
+ expected = <<-HTML.strip_heredoc
+
+
+
Bar
+
+
+ HTML
assert_equivalent_xml expected, output
end
@@ -165,7 +292,14 @@ def setup
%{
Bar
}.html_safe
end
- expected = %{
Bar
}
+ expected = <<-HTML.strip_heredoc
+
+
+
+
Bar
+
+
+ HTML
assert_equivalent_xml expected, output
end
@@ -177,12 +311,22 @@ def setup
%{
Bar
}.html_safe
end
- expected = %{
Bar
can't be blank, is too short (minimum is 5 characters)
}
+ expected = <<-HTML.strip_heredoc
+
+
Bar
+
can't be blank, is too short (minimum is 5 characters)
+
+ HTML
assert_equivalent_xml expected, output
end
test "adds class to wrapped form_group by a field" do
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+ HTML
assert_equivalent_xml expected, output
end
test "adds data-attributes (or any other options) to wrapper" do
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+
+
+
+ HTML
assert_equivalent_xml expected, @builder.search_field(:misc, wrapper: { data: { foo: 'bar' } })
end
test "passing options to a form control get passed through" do
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+
+
+
+ HTML
assert_equivalent_xml expected, @builder.text_field(:email, autofocus: true)
end
@@ -256,12 +457,24 @@ def setup
nil
end
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+
+
+ HTML
assert_equivalent_xml expected, output
end
test "custom form group layout option" do
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+ HTML
assert_equivalent_xml expected, bootstrap_form_for(@user, layout: :horizontal) { |f| f.email_field :email, layout: :inline }
end
@@ -271,7 +484,13 @@ def setup
%{
Bar
}.html_safe
end
- expected = %{
Bar
}
+ expected = <<-HTML.strip_heredoc
+
+
+
Bar
+
+
+ HTML
assert_equivalent_xml expected, output
end
@@ -284,7 +503,17 @@ def setup
end
test ":input_group_class should apply to input-group" do
- expected = %{
}
+ expected = <<-HTML.strip_heredoc
+
+
+
+
+
+
+
+
+
+ HTML
assert_equivalent_xml expected, @builder.email_field(:email, append: @builder.primary('Subscribe'), input_group_class: 'input-group-lg')
end
end
diff --git a/test/bootstrap_form_test.rb b/test/bootstrap_form_test.rb
index cf4fb5c60..b96850b2a 100644
--- a/test/bootstrap_form_test.rb
+++ b/test/bootstrap_form_test.rb
@@ -1,47 +1,94 @@
-require 'test_helper'
+require_relative "./test_helper"
class BootstrapFormTest < ActionView::TestCase
include BootstrapForm::Helper
- def setup
- setup_test_fixture
- end
+ setup :setup_test_fixture
test "default-style forms" do
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+ HTML
assert_equivalent_xml expected, bootstrap_form_for(@user) { |f| nil }
end
test "inline-style forms" do
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+ HTML
assert_equivalent_xml expected, bootstrap_form_for(@user, layout: :inline) { |f| nil }
end
test "horizontal-style forms" do
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+ HTML
assert_equivalent_xml expected, bootstrap_form_for(@user, layout: :horizontal) { |f| f.email_field :email }
end
test "existing styles aren't clobbered when specifying a form style" do
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+ HTML
assert_equivalent_xml expected, bootstrap_form_for(@user, layout: :horizontal, html: { class: "my-style" }) { |f| f.email_field :email }
end
test "given role attribute should not be covered by default role attribute" do
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+ HTML
assert_equivalent_xml expected, bootstrap_form_for(@user, html: { role: 'not-a-form'}) {|f| nil}
end
test "bootstrap_form_tag acts like a form tag" do
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+ HTML
assert_equivalent_xml expected, bootstrap_form_tag(url: '/users') { |f| f.text_field :email, label: "Your Email" }
end
test "bootstrap_form_tag does not clobber custom options" do
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+ HTML
assert_equivalent_xml expected, bootstrap_form_tag(url: '/users') { |f| f.text_field :email, name: 'NAME', id: "ID" }
end
+ # TODO: difference in rendering between 5.0 and 5.1?
test "bootstrap_form_tag allows an empty name for checkboxes" do
checkbox = if ::Rails::VERSION::STRING >= '5.1'
%{}
@@ -56,7 +103,15 @@ def setup
@user.email = nil
@user.valid?
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+
+ HTML
assert_equivalent_xml expected, bootstrap_form_for(@user, label_errors: true) { |f| f.text_field :email }
end
@@ -64,33 +119,72 @@ def setup
@user.email = nil
@user.valid?
- expected = %{}
+ expected = <<-HTML.strip_heredoc
+