From 8db9ea3e6fc1e9e4b2e4e2aca2fe3a1d16bde3fd Mon Sep 17 00:00:00 2001 From: Uwe Kubosch Date: Wed, 13 Jan 2021 19:12:46 +0100 Subject: [PATCH 01/20] Ignore RubyMine config directory --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index e7bb8f752..f32d43a11 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .bundle/ +.idea log/*.log pkg/ demo/db/*.sqlite3 @@ -13,7 +14,7 @@ test/gemfiles/*.lock Vagrantfile .vagrant -// For the demo app. +# For the demo app. # Ignore uploaded files in development. demo/storage/* From 46cf6df43550d45dd5e20256b2281d39db9ef78d Mon Sep 17 00:00:00 2001 From: Uwe Kubosch Date: Wed, 13 Jan 2021 19:43:07 +0100 Subject: [PATCH 02/20] Initial setup of GitHb Actions --- .github/workflows/ruby.yml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/ruby.yml diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml new file mode 100644 index 000000000..e26f6edf7 --- /dev/null +++ b/.github/workflows/ruby.yml @@ -0,0 +1,35 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. +# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake +# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby + +name: Ruby + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + test: + + runs-on: ubuntu-latest + strategy: + matrix: + ruby-version: ['2.6', '2.7', '3.0'] + + steps: + - uses: actions/checkout@v2 + - name: Set up Ruby + # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby, + # change this to (see https://github.com/ruby/setup-ruby#versioning): + # uses: ruby/setup-ruby@v1 + uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e + with: + ruby-version: ${{ matrix.ruby-version }} + bundler-cache: true # runs 'bundle install' and caches installed gems automatically + - name: Run tests + run: bundle exec rake From 344588102be45f7206966308961f6dc8ada6f86c Mon Sep 17 00:00:00 2001 From: Uwe Kubosch Date: Wed, 13 Jan 2021 19:59:25 +0100 Subject: [PATCH 03/20] Run tests for rails 5 and rails 6 --- .github/workflows/ruby.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index e26f6edf7..4ad84d718 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -18,9 +18,12 @@ jobs: runs-on: ubuntu-latest strategy: + fail-fast: false matrix: ruby-version: ['2.6', '2.7', '3.0'] - + gemfile: ['5.2.gemfile', '6.0.gemfile', 'edge.gemfile'] + env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps + BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile steps: - uses: actions/checkout@v2 - name: Set up Ruby From 22e8f99c92a04283415ac297ede57d53bfed4c5f Mon Sep 17 00:00:00 2001 From: Uwe Kubosch Date: Wed, 13 Jan 2021 20:07:54 +0100 Subject: [PATCH 04/20] Run tests for rails 5 and rails 6 + run lint job --- .github/workflows/ruby.yml | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 4ad84d718..50e40a3df 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -1,10 +1,3 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. -# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake -# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby - name: Ruby on: @@ -14,25 +7,36 @@ on: branches: [ master ] jobs: + lint: + runs-on: ubuntu-latest + env: + BUNDLE_GEMFILE: gemfiles/6.0.gemfile + steps: + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.7.2 + bundler-cache: true + - name: Run tests + run: | + gem install danger + danger + bundle exec rake rubocop test: - runs-on: ubuntu-latest strategy: fail-fast: false matrix: ruby-version: ['2.6', '2.7', '3.0'] gemfile: ['5.2.gemfile', '6.0.gemfile', 'edge.gemfile'] - env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps + env: BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile steps: - uses: actions/checkout@v2 - name: Set up Ruby - # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby, - # change this to (see https://github.com/ruby/setup-ruby#versioning): - # uses: ruby/setup-ruby@v1 - uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e + uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby-version }} - bundler-cache: true # runs 'bundle install' and caches installed gems automatically + bundler-cache: true - name: Run tests run: bundle exec rake From 0b8974883f7677859de004d9bed5fa967038ca1a Mon Sep 17 00:00:00 2001 From: Uwe Kubosch Date: Wed, 13 Jan 2021 20:11:17 +0100 Subject: [PATCH 05/20] GH Actions: Correct gemfile names --- .github/workflows/ruby.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 50e40a3df..91e6deb41 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -7,7 +7,7 @@ on: branches: [ master ] jobs: - lint: + Lint: runs-on: ubuntu-latest env: BUNDLE_GEMFILE: gemfiles/6.0.gemfile @@ -22,13 +22,13 @@ jobs: gem install danger danger bundle exec rake rubocop - test: + Test: runs-on: ubuntu-latest strategy: fail-fast: false matrix: ruby-version: ['2.6', '2.7', '3.0'] - gemfile: ['5.2.gemfile', '6.0.gemfile', 'edge.gemfile'] + gemfile: ['5.2', '6.0', 'edge'] env: BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile steps: From 62b1b466363260cec3d006e1f2d489506e4c2923 Mon Sep 17 00:00:00 2001 From: Uwe Kubosch Date: Wed, 13 Jan 2021 20:24:41 +0100 Subject: [PATCH 06/20] GH Actions: Only run the test task in the matrix. rubocop is run in the separate Lint job. --- .github/workflows/ruby.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 91e6deb41..e4dade333 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -39,4 +39,4 @@ jobs: ruby-version: ${{ matrix.ruby-version }} bundler-cache: true - name: Run tests - run: bundle exec rake + run: bundle exec rake test From cf8f2a50b93a06d410eed3ec2703cadc1297abde Mon Sep 17 00:00:00 2001 From: Uwe Kubosch Date: Wed, 13 Jan 2021 20:29:39 +0100 Subject: [PATCH 07/20] GH Actions: Separate the Danger run for better output --- .github/workflows/ruby.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index e4dade333..6f7b8e3fe 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -17,11 +17,12 @@ jobs: with: ruby-version: 2.7.2 bundler-cache: true - - name: Run tests + - name: Danger run: | gem install danger danger - bundle exec rake rubocop + - name: Rubocop + run: bundle exec rake rubocop Test: runs-on: ubuntu-latest strategy: From f221574043a9cd589eab2fc54b4134f3a90ca020 Mon Sep 17 00:00:00 2001 From: Uwe Kubosch Date: Wed, 13 Jan 2021 20:34:12 +0100 Subject: [PATCH 08/20] GH Actions: Run rubocop directly instead of as a Rake task. Allow autocorrectable offences. --- .github/workflows/ruby.yml | 2 +- .rubocop.yml | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 6f7b8e3fe..3b7c8405e 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -22,7 +22,7 @@ jobs: gem install danger danger - name: Rubocop - run: bundle exec rake rubocop + run: bundle exec rubocop --auto-correct Test: runs-on: ubuntu-latest strategy: diff --git a/.rubocop.yml b/.rubocop.yml index 88cc286dc..1d53b80cc 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -26,6 +26,12 @@ AllCops: - Guardfile - Rakefile +Layout/LineLength: + Max: 132 + Exclude: + - "demo/config/**/*" + - "demo/db/**/*" + Layout/SpaceAroundEqualsInParameterDefault: EnforcedStyle: no_space @@ -45,12 +51,6 @@ Metrics/ClassLength: - "demo/test/**/*" - "test/**/*" -Metrics/LineLength: - Max: 132 - Exclude: - - "demo/config/**/*" - - "demo/db/**/*" - Metrics/MethodLength: Max: 12 Exclude: From 97d92ae1635e781e60a914c071e2f76de53caf35 Mon Sep 17 00:00:00 2001 From: Uwe Kubosch Date: Wed, 13 Jan 2021 20:37:49 +0100 Subject: [PATCH 09/20] GH Actions: Only run Danger for pull requests --- .github/workflows/ruby.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 3b7c8405e..e116d255a 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -18,6 +18,7 @@ jobs: ruby-version: 2.7.2 bundler-cache: true - name: Danger + if: ${{ github.event_name == 'pull_request' }} run: | gem install danger danger From 212a5c3ee8ec9e78d60110e6153f66f877912183 Mon Sep 17 00:00:00 2001 From: Uwe Kubosch Date: Wed, 13 Jan 2021 20:42:21 +0100 Subject: [PATCH 10/20] GH Actions: Try to calm RuboCop --- .rubocop.yml | 5 ++- .rubocop_todo.yml | 81 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 .rubocop_todo.yml diff --git a/.rubocop.yml b/.rubocop.yml index 1d53b80cc..9eea8cc88 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,5 +1,4 @@ -# Taken from: https://github.com/mattbrictson/rails-template/blob/master/rubocop.yml.tt -# Modified for demo app in `demo/` directory. +inherit_from: .rubocop_todo.yml require: - rubocop-performance - rubocop-rails @@ -7,7 +6,7 @@ require: AllCops: DisplayCopNames: true DisplayStyleGuide: true - TargetRubyVersion: 2.5 + NewCops: enable Exclude: - "bin/*" - Capfile diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 000000000..775bf8161 --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,81 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2021-01-13 19:40:22 UTC using RuboCop version 1.8.1. +# The point is for the user to remove these configuration records +# one by one as the offenses are removed from the code base. +# Note that changes in the inspected code, or installation of new +# versions of RuboCop, may require this file to be generated again. + +# Offense count: 1 +# Configuration parameters: AllowedMethods. +# AllowedMethods: enums +Lint/ConstantDefinitionInBlock: + Exclude: + - 'bootstrap_form.gemspec' + +# Offense count: 2 +# Cop supports --auto-correct. +Lint/RedundantCopDisableDirective: + Exclude: + - 'lib/bootstrap_form/form_builder.rb' + - 'lib/bootstrap_form/helpers/bootstrap.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Performance/BlockGivenWithExplicitBlock: + Exclude: + - 'lib/bootstrap_form/helpers/bootstrap.rb' + - 'lib/bootstrap_form/inputs/check_box.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: IgnoredMethods. +# IgnoredMethods: ==, equal?, eql? +Style/ClassEqualityComparison: + Exclude: + - 'lib/bootstrap_form/components/validation.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/ExplicitBlockArgument: + Exclude: + - 'lib/bootstrap_form/form_group_builder.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/RedundantAssignment: + Exclude: + - 'lib/bootstrap_form/form_group_builder.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: SafeForConstants. +Style/RedundantFetchBlock: + Exclude: + - 'demo/config/puma.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/RedundantFileExtensionInRequire: + Exclude: + - 'test/test_helper.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/RedundantRegexpEscape: + Exclude: + - 'Dangerfile' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: AllowModifier. +Style/SoleNestedConditional: + Exclude: + - 'Dangerfile' + - 'lib/bootstrap_form/form_group_builder.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/StringConcatenation: + Exclude: + - 'lib/bootstrap_form.rb' From ab97b4f9248f388acaffa43adc68bd428216e8d7 Mon Sep 17 00:00:00 2001 From: Uwe Kubosch Date: Wed, 13 Jan 2021 21:20:46 +0100 Subject: [PATCH 11/20] Use the default Gemfile to pick up rubocop.yml --- .github/workflows/ruby.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index e116d255a..6a7bd81a4 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -9,8 +9,6 @@ on: jobs: Lint: runs-on: ubuntu-latest - env: - BUNDLE_GEMFILE: gemfiles/6.0.gemfile steps: - uses: actions/checkout@v2 - uses: ruby/setup-ruby@v1 From 3213d47e0f877848a089844b9b35aff3e6a92b92 Mon Sep 17 00:00:00 2001 From: Uwe Kubosch Date: Wed, 13 Jan 2021 21:28:36 +0100 Subject: [PATCH 12/20] GH Actions: Ignore the vendor directory for rubocop --- .rubocop.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 9eea8cc88..209cc189b 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -8,22 +8,23 @@ AllCops: DisplayStyleGuide: true NewCops: enable Exclude: - - "bin/*" + - bin/* - Capfile - demo/bin/* - - "demo/bower_components/**/*" + - demo/bower_components/**/* - demo/config/boot.rb - demo/config/environment.rb - demo/config/initializers/version.rb - demo/db/schema.rb - - "demo/node_modules/**/*" + - demo/node_modules/**/* - demo/Rakefile - - "demo/tmp/**/*" - - "demo/vendor/**/*" + - demo/tmp/**/* + - demo/vendor/**/* - Gemfile - gemfiles/vendor/bundle/**/* - Guardfile - Rakefile + - vendor/**/* Layout/LineLength: Max: 132 From 5ab399b93c5ee454ebdf1c1328e899ec636e9668 Mon Sep 17 00:00:00 2001 From: Uwe Kubosch Date: Wed, 13 Jan 2021 22:58:00 +0100 Subject: [PATCH 13/20] Forward the options as keyword arguments --- lib/bootstrap_form/form_group.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/bootstrap_form/form_group.rb b/lib/bootstrap_form/form_group.rb index b611323b1..7c1c03664 100644 --- a/lib/bootstrap_form/form_group.rb +++ b/lib/bootstrap_form/form_group.rb @@ -10,7 +10,7 @@ def form_group(*args, &block) options[:class] = form_group_classes(options) - tag.div(options.except(:append, :id, :label, :help, :icon, + tag.div(**options.except(:append, :id, :label, :help, :icon, :input_group_class, :label_col, :control_col, :add_control_col_class, :layout, :prepend)) do form_group_content( From 4d92a8af1dd7b176b0b8e3151c600ce2607722d4 Mon Sep 17 00:00:00 2001 From: Uwe Kubosch Date: Wed, 13 Jan 2021 23:19:12 +0100 Subject: [PATCH 14/20] Test Rails 6.1 and skip Rails 5.2 + Ruby 3.0 --- .github/workflows/ruby.yml | 22 ++++++++++++---------- gemfiles/6.1.gemfile | 4 ++++ 2 files changed, 16 insertions(+), 10 deletions(-) create mode 100644 gemfiles/6.1.gemfile diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 6a7bd81a4..83397ea5b 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -27,16 +27,18 @@ jobs: strategy: fail-fast: false matrix: - ruby-version: ['2.6', '2.7', '3.0'] - gemfile: ['5.2', '6.0', 'edge'] + ruby-version: [ '3.0', '2.7', '2.6' ] + gemfile: [ '6.1', '6.0', '5.2', 'edge' ] + exclude: + - { ruby-version: '3.0', gemfile: "5.2" } env: BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile steps: - - uses: actions/checkout@v2 - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: ${{ matrix.ruby-version }} - bundler-cache: true - - name: Run tests - run: bundle exec rake test + - uses: actions/checkout@v2 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby-version }} + bundler-cache: true + - name: Run tests + run: bundle exec rake test diff --git a/gemfiles/6.1.gemfile b/gemfiles/6.1.gemfile new file mode 100644 index 000000000..a1e06796e --- /dev/null +++ b/gemfiles/6.1.gemfile @@ -0,0 +1,4 @@ +gems = "#{File.dirname __dir__}/Gemfile" +eval File.read(gems), binding, gems # rubocop: disable Security/Eval + +gem "rails", "~> 6.1.0" From 4da475721351bedfb69aa96353d9f86896d78eea Mon Sep 17 00:00:00 2001 From: Thimo Jansen Date: Mon, 12 Apr 2021 16:57:29 +0200 Subject: [PATCH 15/20] Fix Rails 6.1 tests on master (#586) * Fix tests for Rails 6.1 * Fix Rubocop offenses bootstrap_form.gemspec:27:29: C: Gemspec/RequiredRubyVersion: required_ruby_version (2.5, declared in bootstrap_form.gemspec) and TargetRubyVersion (2.7, which may be specified in .rubocop.yml) should be equal. s.required_ruby_version = ">= 2.5" ^^^^^^^^ lib/bootstrap_form/form_group.rb:14:30: C: [Correctable] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line. (https://rubystyle.guide#no-double-indent) :input_group_class, :label_col, :control_col, ^^^^^^^^^^^^^^^^^^ lib/bootstrap_form/form_group.rb:15:30: C: [Correctable] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line. (https://rubystyle.guide#no-double-indent) :add_control_col_class, :layout, :prepend)) do ^^^^^^^^^^^^^^^^^^^^^^ test/bootstrap_form_test.rb:123:103: C: [Correctable] Style/IfUnlessModifier: Modifier form of if makes the line too long. (https://rubystyle.guide#if-as-a-modifier)
^^ test/bootstrap_form_test.rb:123:133: C: [Correctable] Style/StringLiteralsInInterpolation: Prefer single-quoted strings inside interpolations. ^^^^^ test/bootstrap_rich_text_area_test.rb:23:54: C: [Correctable] Style/StringLiteralsInInterpolation: Prefer single-quoted strings inside interpolations. "http://test.host/rails/active_storage/blobs/#{"redirect/" if ::Rails::VERSION::STRING >= "6.1"}:signed_id/:filename" ^^^^^^^^^^^ test/bootstrap_rich_text_area_test.rb:23:97: C: [Correctable] Style/StringLiteralsInInterpolation: Prefer single-quoted strings inside interpolations. "http://test.host/rails/active_storage/blobs/#{"redirect/" if ::Rails::VERSION::STRING >= "6.1"}:signed_id/:filename" ^^^^^ * Include Rails 6.1 in Travis tests + update Ruby versions * Update CHANGELOG * Rails Edge requires Ruby 2.7+ * Remove rubocop_todo and fix Rubocop offenses --- .github/workflows/ruby.yml | 1 + .rubocop.yml | 2 +- .rubocop_todo.yml | 81 --------------------- .travis.yml | 15 ++-- CHANGELOG.md | 2 +- Dangerfile | 12 ++- bootstrap_form.gemspec | 4 +- demo/config/puma.rb | 4 +- lib/bootstrap_form.rb | 3 +- lib/bootstrap_form/components/validation.rb | 2 +- lib/bootstrap_form/form_builder.rb | 2 - lib/bootstrap_form/form_group.rb | 4 +- lib/bootstrap_form/form_group_builder.rb | 11 +-- lib/bootstrap_form/helpers/bootstrap.rb | 4 +- lib/bootstrap_form/inputs/check_box.rb | 2 +- test/bootstrap_form_test.rb | 3 +- test/bootstrap_rich_text_area_test.rb | 6 +- test/bootstrap_selects_test.rb | 48 +++++++----- test/test_helper.rb | 2 +- 19 files changed, 67 insertions(+), 141 deletions(-) delete mode 100644 .rubocop_todo.yml diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 83397ea5b..ffa9fc3ef 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -31,6 +31,7 @@ jobs: gemfile: [ '6.1', '6.0', '5.2', 'edge' ] exclude: - { ruby-version: '3.0', gemfile: "5.2" } + - { ruby-version: '2.6', gemfile: "edge" } env: BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile steps: diff --git a/.rubocop.yml b/.rubocop.yml index 209cc189b..03983762e 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,4 +1,3 @@ -inherit_from: .rubocop_todo.yml require: - rubocop-performance - rubocop-rails @@ -6,6 +5,7 @@ require: AllCops: DisplayCopNames: true DisplayStyleGuide: true + TargetRubyVersion: 2.5 NewCops: enable Exclude: - bin/* diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml deleted file mode 100644 index 775bf8161..000000000 --- a/.rubocop_todo.yml +++ /dev/null @@ -1,81 +0,0 @@ -# This configuration was generated by -# `rubocop --auto-gen-config` -# on 2021-01-13 19:40:22 UTC using RuboCop version 1.8.1. -# The point is for the user to remove these configuration records -# one by one as the offenses are removed from the code base. -# Note that changes in the inspected code, or installation of new -# versions of RuboCop, may require this file to be generated again. - -# Offense count: 1 -# Configuration parameters: AllowedMethods. -# AllowedMethods: enums -Lint/ConstantDefinitionInBlock: - Exclude: - - 'bootstrap_form.gemspec' - -# Offense count: 2 -# Cop supports --auto-correct. -Lint/RedundantCopDisableDirective: - Exclude: - - 'lib/bootstrap_form/form_builder.rb' - - 'lib/bootstrap_form/helpers/bootstrap.rb' - -# Offense count: 2 -# Cop supports --auto-correct. -Performance/BlockGivenWithExplicitBlock: - Exclude: - - 'lib/bootstrap_form/helpers/bootstrap.rb' - - 'lib/bootstrap_form/inputs/check_box.rb' - -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: IgnoredMethods. -# IgnoredMethods: ==, equal?, eql? -Style/ClassEqualityComparison: - Exclude: - - 'lib/bootstrap_form/components/validation.rb' - -# Offense count: 1 -# Cop supports --auto-correct. -Style/ExplicitBlockArgument: - Exclude: - - 'lib/bootstrap_form/form_group_builder.rb' - -# Offense count: 1 -# Cop supports --auto-correct. -Style/RedundantAssignment: - Exclude: - - 'lib/bootstrap_form/form_group_builder.rb' - -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: SafeForConstants. -Style/RedundantFetchBlock: - Exclude: - - 'demo/config/puma.rb' - -# Offense count: 1 -# Cop supports --auto-correct. -Style/RedundantFileExtensionInRequire: - Exclude: - - 'test/test_helper.rb' - -# Offense count: 1 -# Cop supports --auto-correct. -Style/RedundantRegexpEscape: - Exclude: - - 'Dangerfile' - -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: AllowModifier. -Style/SoleNestedConditional: - Exclude: - - 'Dangerfile' - - 'lib/bootstrap_form/form_group_builder.rb' - -# Offense count: 1 -# Cop supports --auto-correct. -Style/StringConcatenation: - Exclude: - - 'lib/bootstrap_form.rb' diff --git a/.travis.yml b/.travis.yml index 6a9867a25..d6c7e1a95 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,10 @@ language: ruby rvm: - - 2.7.1 - - 2.6.5 - - 2.5.7 + - 2.7.2 + - 2.6.6 + - 2.5.8 gemfile: + - gemfiles/6.1.gemfile - gemfiles/6.0.gemfile - gemfiles/5.2.gemfile cache: @@ -18,12 +19,12 @@ matrix: gemfile: gemfiles/edge.gemfile # Next version of Rails - - rvm: 2.7.1 + - rvm: 2.7.2 gemfile: gemfiles/edge.gemfile # Running one job to execute DANGER bot and linting - - rvm: 2.7.1 - gemfile: gemfiles/6.0.gemfile + - rvm: 2.7.2 + gemfile: gemfiles/6.1.gemfile script: - gem install danger - danger @@ -31,5 +32,5 @@ matrix: allow_failures: - rvm: ruby-head - - rvm: 2.7.1 + - rvm: 2.7.2 gemfile: gemfiles/edge.gemfile diff --git a/CHANGELOG.md b/CHANGELOG.md index fe0dff508..94953b0ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ ### Bugfixes -* Your contribution here! +* [#586](https://github.com/bootstrap-ruby/bootstrap_form/pull/586): Fix Rails 6.1 tests on master - [@thimo](https://github.com/thimo). ## [4.5.0][] (2020-04-29) diff --git a/Dangerfile b/Dangerfile index 121167be4..615126bfe 100644 --- a/Dangerfile +++ b/Dangerfile @@ -44,11 +44,9 @@ end # ------------------------------------------------------------------------------ # Did you remove the CHANGELOG's "Your contribution here!" line? # ------------------------------------------------------------------------------ -if has_changelog_changes - if IO.read("CHANGELOG.md").scan(/^\s*[-\*] Your contribution here/i).count < 3 - raise( - "Please put the `- Your contribution here!` line back into CHANGELOG.md.", - sticky: false - ) - end +if has_changelog_changes && (IO.read("CHANGELOG.md").scan(/^\s*[-*] Your contribution here/i).count < 3) + raise( + "Please put the `- Your contribution here!` line back into CHANGELOG.md.", + sticky: false + ) end diff --git a/bootstrap_form.gemspec b/bootstrap_form.gemspec index 7f02f0bc1..874945563 100644 --- a/bootstrap_form.gemspec +++ b/bootstrap_form.gemspec @@ -3,6 +3,8 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require "bootstrap_form/version" +REQUIRED_RAILS_VERSION = ">= 5.2".freeze + Gem::Specification.new do |s| s.name = "bootstrap_form" s.version = BootstrapForm::VERSION @@ -26,8 +28,6 @@ Gem::Specification.new do |s| s.required_ruby_version = ">= 2.5" - REQUIRED_RAILS_VERSION = ">= 5.2".freeze - s.add_dependency("actionpack", REQUIRED_RAILS_VERSION) s.add_dependency("activemodel", REQUIRED_RAILS_VERSION) diff --git a/demo/config/puma.rb b/demo/config/puma.rb index 1e19380dc..44256ac09 100644 --- a/demo/config/puma.rb +++ b/demo/config/puma.rb @@ -4,12 +4,12 @@ # the maximum value specified for Puma. Default is set to 5 threads for minimum # and maximum; this matches the default thread size of Active Record. # -threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } +threads_count = ENV.fetch("RAILS_MAX_THREADS", 5) threads threads_count, threads_count # Specifies the `port` that Puma will listen on to receive requests; default is 3000. # -port ENV.fetch("PORT") { 3000 } +port ENV.fetch("PORT", 3000) # Specifies the `environment` that Puma will run in. # diff --git a/lib/bootstrap_form.rb b/lib/bootstrap_form.rb index 0de892db9..a50d077bd 100644 --- a/lib/bootstrap_form.rb +++ b/lib/bootstrap_form.rb @@ -2,8 +2,7 @@ # name and not in the usual autoload-reachable way. # The following line is definitely need to make `bootstrap_form` work. if ::Rails::VERSION::STRING > "6" - require Gem::Specification.find_by_name("actiontext").gem_dir + - "/app/helpers/action_text/tag_helper" + require "#{Gem::Specification.find_by_name('actiontext').gem_dir}/app/helpers/action_text/tag_helper" end require "action_view" require "action_pack" diff --git a/lib/bootstrap_form/components/validation.rb b/lib/bootstrap_form/components/validation.rb index 1c7facfc4..215d8b76f 100644 --- a/lib/bootstrap_form/components/validation.rb +++ b/lib/bootstrap_form/components/validation.rb @@ -14,7 +14,7 @@ def error?(name) def required_attribute?(obj, attribute) return false unless obj && attribute - target = obj.class == Class ? obj : obj.class + target = obj.instance_of?(Class) ? obj : obj.class target_validators = if target.respond_to? :validators_on target.validators_on(attribute).map(&:class) diff --git a/lib/bootstrap_form/form_builder.rb b/lib/bootstrap_form/form_builder.rb index 429802c78..fae358822 100644 --- a/lib/bootstrap_form/form_builder.rb +++ b/lib/bootstrap_form/form_builder.rb @@ -45,7 +45,6 @@ class FormBuilder < ActionView::Helpers::FormBuilder delegate :content_tag, :capture, :concat, :tag, to: :@template - # rubocop:disable Metrics/AbcSize def initialize(object_name, object, template, options) @layout = options[:layout] || default_layout @label_col = options[:label_col] || default_label_col @@ -61,7 +60,6 @@ def initialize(object_name, object, template, options) add_default_form_attributes_and_form_inline options super end - # rubocop:enable Metrics/AbcSize def add_default_form_attributes_and_form_inline(options) options[:html] ||= {} diff --git a/lib/bootstrap_form/form_group.rb b/lib/bootstrap_form/form_group.rb index 7c1c03664..d300cefc7 100644 --- a/lib/bootstrap_form/form_group.rb +++ b/lib/bootstrap_form/form_group.rb @@ -11,8 +11,8 @@ def form_group(*args, &block) options[:class] = form_group_classes(options) tag.div(**options.except(:append, :id, :label, :help, :icon, - :input_group_class, :label_col, :control_col, - :add_control_col_class, :layout, :prepend)) do + :input_group_class, :label_col, :control_col, + :add_control_col_class, :layout, :prepend)) do form_group_content( generate_label(options[:id], name, options[:label], options[:label_col], options[:layout]), generate_help(name, options[:help]), options, &block diff --git a/lib/bootstrap_form/form_group_builder.rb b/lib/bootstrap_form/form_group_builder.rb index 4407266c0..094011353 100644 --- a/lib/bootstrap_form/form_group_builder.rb +++ b/lib/bootstrap_form/form_group_builder.rb @@ -6,7 +6,7 @@ module FormGroupBuilder private - def form_group_builder(method, options, html_options=nil) + def form_group_builder(method, options, html_options=nil, &block) no_wrapper = options[:wrapper] == false options = form_group_builder_options(options, method) @@ -21,16 +21,14 @@ def form_group_builder(method, options, html_options=nil) if no_wrapper yield else - form_group(method, form_group_options) { yield } + form_group(method, form_group_options, &block) end end def form_group_builder_options(options, method) options.symbolize_keys! options = convert_form_tag_options(method, options) if acts_like_form_tag - unless options[:skip_label] - options[:required] = form_group_required(options) if options.key?(:skip_required) - end + options[:required] = form_group_required(options) if !options[:skip_label] && options.key?(:skip_required) options end @@ -57,12 +55,11 @@ def form_group_opts(options, css_options) end def form_group_label(options, css_options) - hash = { + { text: form_group_label_text(options[:label]), class: form_group_label_class(options), required: options[:required] }.merge(css_options[:id].present? ? { for: css_options[:id] } : {}) - hash end def form_group_label_text(label) diff --git a/lib/bootstrap_form/helpers/bootstrap.rb b/lib/bootstrap_form/helpers/bootstrap.rb index 3e5554632..4a4521764 100644 --- a/lib/bootstrap_form/helpers/bootstrap.rb +++ b/lib/bootstrap_form/helpers/bootstrap.rb @@ -14,7 +14,7 @@ def submit(name=nil, options={}) def primary(name=nil, options={}, &block) setup_css_class "btn btn-primary", options - if options[:render_as_button] || block_given? + if options[:render_as_button] || block options.except! :render_as_button button(name, options, &block) else @@ -22,7 +22,7 @@ def primary(name=nil, options={}, &block) end end - def alert_message(title, options={}) # rubocop:disable Metrics/AbcSize + def alert_message(title, options={}) css = options[:class] || "alert alert-danger" return unless object.respond_to?(:errors) && object.errors.full_messages.any? diff --git a/lib/bootstrap_form/inputs/check_box.rb b/lib/bootstrap_form/inputs/check_box.rb index abfd44bfd..0bff2014c 100644 --- a/lib/bootstrap_form/inputs/check_box.rb +++ b/lib/bootstrap_form/inputs/check_box.rb @@ -38,7 +38,7 @@ def check_box_label(name, options, checked_value, &block) end def check_box_description(name, options, &block) - content = block_given? ? capture(&block) : options[:label] + content = block ? capture(&block) : options[:label] content || object&.class&.human_attribute_name(name) || name.to_s.humanize end diff --git a/test/bootstrap_form_test.rb b/test/bootstrap_form_test.rb index 546f81d1e..f4604d219 100644 --- a/test/bootstrap_form_test.rb +++ b/test/bootstrap_form_test.rb @@ -120,7 +120,8 @@ class BootstrapFormTest < ActionView::TestCase # generate a default ID for the form element. test "default-style forms bootstrap_form_with Rails 5.1+" do expected = <<-HTML.strip_heredoc - + #{'' unless ::Rails::VERSION::STRING >= '6'}
HTML diff --git a/test/bootstrap_rich_text_area_test.rb b/test/bootstrap_rich_text_area_test.rb index 8e3b2aca9..0ed8fe321 100644 --- a/test/bootstrap_rich_text_area_test.rb +++ b/test/bootstrap_rich_text_area_test.rb @@ -12,11 +12,15 @@ class BootstrapRichTextAreaTest < ActionView::TestCase
- +
HTML assert_equivalent_xml expected, form_with_builder.rich_text_area(:life_story) end + + def data_blob_url_template + "http://test.host/rails/active_storage/blobs/#{'redirect/' if ::Rails::VERSION::STRING >= '6.1'}:signed_id/:filename" + end end end diff --git a/test/bootstrap_selects_test.rb b/test/bootstrap_selects_test.rb index e369b04ec..818fb6b96 100644 --- a/test/bootstrap_selects_test.rb +++ b/test/bootstrap_selects_test.rb @@ -398,15 +398,15 @@ def options_range(start: 1, stop: 31, selected: nil, months: false)
@@ -424,15 +424,15 @@ def options_range(start: 1, stop: 31, selected: nil, months: false)
@@ -503,12 +503,12 @@ def options_range(start: 1, stop: 31, selected: nil, months: false) : @@ -528,12 +528,12 @@ def options_range(start: 1, stop: 31, selected: nil, months: false) : @@ -615,25 +615,25 @@ def options_range(start: 1, stop: 31, selected: nil, months: false)
— :
@@ -650,25 +650,25 @@ def options_range(start: 1, stop: 31, selected: nil, months: false)
— :
@@ -697,4 +697,12 @@ def options_range(start: 1, stop: 31, selected: nil, months: false) }, class: "selectpicker") end + + def blank_option + if ::Rails::VERSION::STRING < "6.1" + '' + else + '' + end + end end diff --git a/test/test_helper.rb b/test/test_helper.rb index c7d8c37f8..c6f925643 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -4,7 +4,7 @@ require "nokogiri" require "equivalent-xml" -require_relative "../demo/config/environment.rb" +require_relative "../demo/config/environment" require "rails/test_help" require "mocha/minitest" From b1a246d61a14e8120c811b3d8079029ca5b38b32 Mon Sep 17 00:00:00 2001 From: Thimo Jansen Date: Tue, 13 Apr 2021 16:38:56 +0200 Subject: [PATCH 16/20] Replace strip_heredoc with <<~ (#587) * Replace strip_heredoc with <<~ Also fix newly detected Rubocop offenses on indentation * Update CHANGELOG --- CHANGELOG.md | 1 + test/bootstrap_checkbox_test.rb | 168 +++++++-------- test/bootstrap_fields_test.rb | 98 ++++----- test/bootstrap_form_group_test.rb | 82 +++---- test/bootstrap_form_test.rb | 120 +++++------ test/bootstrap_other_components_test.rb | 22 +- test/bootstrap_radio_button_test.rb | 116 +++++----- test/bootstrap_rich_text_area_test.rb | 14 +- test/bootstrap_selects_test.rb | 274 ++++++++++++------------ test/bootstrap_without_fields_test.rb | 2 +- test/special_form_class_models_test.rb | 6 +- 11 files changed, 452 insertions(+), 451 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 94953b0ef..813e5a016 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ ### Bugfixes * [#586](https://github.com/bootstrap-ruby/bootstrap_form/pull/586): Fix Rails 6.1 tests on master - [@thimo](https://github.com/thimo). +* [#587](https://github.com/bootstrap-ruby/bootstrap_form/pull/587): Replace `strip_heredoc` with `<<~` - [@thimo](https://github.com/thimo). ## [4.5.0][] (2020-04-29) diff --git a/test/bootstrap_checkbox_test.rb b/test/bootstrap_checkbox_test.rb index 8e22ce2c2..fc6d91f31 100644 --- a/test/bootstrap_checkbox_test.rb +++ b/test/bootstrap_checkbox_test.rb @@ -6,7 +6,7 @@ class BootstrapCheckboxTest < ActionView::TestCase setup :setup_test_fixture test "check_box is wrapped correctly" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -19,7 +19,7 @@ class BootstrapCheckboxTest < ActionView::TestCase end test "check_box empty label" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -31,7 +31,7 @@ class BootstrapCheckboxTest < ActionView::TestCase end test "disabled check_box has proper wrapper classes" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -44,7 +44,7 @@ class BootstrapCheckboxTest < ActionView::TestCase end test "check_box label allows html" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -57,7 +57,7 @@ class BootstrapCheckboxTest < ActionView::TestCase end test "check_box accepts a block to define the label" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -70,7 +70,7 @@ class BootstrapCheckboxTest < ActionView::TestCase end test "check_box accepts a custom label class" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -83,7 +83,7 @@ class BootstrapCheckboxTest < ActionView::TestCase end test "check_box 'id' attribute is used to specify label 'for' attribute" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -96,7 +96,7 @@ class BootstrapCheckboxTest < ActionView::TestCase end test "check_box responds to checked_value and unchecked_value arguments" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -109,7 +109,7 @@ class BootstrapCheckboxTest < ActionView::TestCase end test "inline checkboxes" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -122,7 +122,7 @@ class BootstrapCheckboxTest < ActionView::TestCase end test "inline checkboxes from form layout" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
#{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -141,7 +141,7 @@ class BootstrapCheckboxTest < ActionView::TestCase end test "disabled inline check_box" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -155,21 +155,21 @@ class BootstrapCheckboxTest < ActionView::TestCase end test "inline checkboxes with custom label class" do - expected = <<-HTML.strip_heredoc -
- - - -
+ expected = <<~HTML +
+ + + +
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 = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -187,7 +187,7 @@ class BootstrapCheckboxTest < ActionView::TestCase test "collection_check_boxes renders multiple checkboxes correctly" do collection = [Address.new(id: 1, street: "Foo"), Address.new(id: 2, street: "Bar")] - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -212,7 +212,7 @@ class BootstrapCheckboxTest < ActionView::TestCase test "collection_check_boxes renders multiple checkboxes contains unicode characters in IDs correctly" do struct = Struct.new(:id, :name) collection = [struct.new(1, "Foo"), struct.new("二", "Bar")] - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -236,7 +236,7 @@ class BootstrapCheckboxTest < ActionView::TestCase test "collection_check_boxes renders inline checkboxes correctly" do collection = [Address.new(id: 1, street: "Foo"), Address.new(id: 2, street: "Bar")] - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -261,7 +261,7 @@ class BootstrapCheckboxTest < ActionView::TestCase 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.strip_heredoc + expected = <<~HTML
@@ -288,7 +288,7 @@ class BootstrapCheckboxTest < ActionView::TestCase test "collection_check_boxes renders with multiple checked options correctly" do collection = [Address.new(id: 1, street: "Foo"), Address.new(id: 2, street: "Bar")] - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -311,7 +311,7 @@ class BootstrapCheckboxTest < ActionView::TestCase test "collection_check_boxes sanitizes values when generating label `for`" do collection = [Address.new(id: 1, street: "Foo St")] - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -328,7 +328,7 @@ class BootstrapCheckboxTest < ActionView::TestCase test "collection_check_boxes renders multiple checkboxes with labels defined by Proc :text_method correctly" do collection = [Address.new(id: 1, street: "Foo"), Address.new(id: 2, street: "Bar")] - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -352,7 +352,7 @@ class BootstrapCheckboxTest < ActionView::TestCase test "collection_check_boxes renders multiple checkboxes with values defined by Proc :value_method correctly" do collection = [Address.new(id: 1, street: "Foo"), Address.new(id: 2, street: "Bar")] - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -376,7 +376,7 @@ class BootstrapCheckboxTest < ActionView::TestCase test "collection_check_boxes renders multiple checkboxes with labels defined by lambda :text_method correctly" do collection = [Address.new(id: 1, street: "Foo"), Address.new(id: 2, street: "Bar")] - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -400,7 +400,7 @@ class BootstrapCheckboxTest < ActionView::TestCase test "collection_check_boxes renders multiple checkboxes with values defined by lambda :value_method correctly" do collection = [Address.new(id: 1, street: "Foo"), Address.new(id: 2, street: "Bar")] - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -425,7 +425,7 @@ class BootstrapCheckboxTest < ActionView::TestCase test "collection_check_boxes renders with checked option correctly with Proc :value_method" do collection = [Address.new(id: 1, street: "Foo"), Address.new(id: 2, street: "Bar")] - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -452,7 +452,7 @@ class BootstrapCheckboxTest < ActionView::TestCase test "collection_check_boxes renders with multiple checked options correctly with lambda :value_method" do collection = [Address.new(id: 1, street: "Foo"), Address.new(id: 2, street: "Bar")] - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -478,7 +478,7 @@ class BootstrapCheckboxTest < ActionView::TestCase end test "check_box is wrapped correctly with custom option set" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -489,7 +489,7 @@ class BootstrapCheckboxTest < ActionView::TestCase end test "check_box is wrapped correctly with id option and custom option set" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -500,7 +500,7 @@ class BootstrapCheckboxTest < ActionView::TestCase end test "check_box is wrapped correctly with custom and inline options set" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -512,7 +512,7 @@ class BootstrapCheckboxTest < ActionView::TestCase end test "check_box is wrapped correctly with custom and disabled options set" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -523,7 +523,7 @@ class BootstrapCheckboxTest < ActionView::TestCase end test "check_box is wrapped correctly with custom, inline and disabled options set" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -535,7 +535,7 @@ class BootstrapCheckboxTest < ActionView::TestCase end test "check_box skip label" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -545,7 +545,7 @@ class BootstrapCheckboxTest < ActionView::TestCase end test "check_box hide label" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -556,7 +556,7 @@ class BootstrapCheckboxTest < ActionView::TestCase end test "check_box skip label with custom option set" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -566,7 +566,7 @@ class BootstrapCheckboxTest < ActionView::TestCase end test "check_box hide label with custom option set" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -580,23 +580,23 @@ class BootstrapCheckboxTest < ActionView::TestCase collection = [Address.new(id: 1, street: "Foo"), Address.new(id: 2, street: "Bar")] @user.errors.add(:misc, "a box must be checked") - expected = <<-HTML.strip_heredoc - - #{'' unless ::Rails::VERSION::STRING >= '6'} - -
- -
- - -
-
- - -
a box must be checked
+ expected = <<~HTML + + #{'' unless ::Rails::VERSION::STRING >= '6'} + +
+ +
+ + +
+
+ + +
a box must be checked
+
-
- + HTML actual = bootstrap_form_for(@user) do |f| @@ -609,7 +609,7 @@ class BootstrapCheckboxTest < ActionView::TestCase test "collection_check_boxes renders multiple check boxes with error correctly" do @user.errors.add(:misc, "error for test") collection = [Address.new(id: 1, street: "Foo"), Address.new(id: 2, street: "Bar")] - expected = <<-HTML.strip_heredoc + expected = <<~HTML
#{'' unless ::Rails::VERSION::STRING >= '6'} @@ -636,18 +636,18 @@ class BootstrapCheckboxTest < ActionView::TestCase test "check_box renders error when asked" do @user.errors.add(:terms, "You must accept the terms.") - expected = <<-HTML.strip_heredoc - - #{'' unless ::Rails::VERSION::STRING >= '6'} -
- - - -
You must accept the terms.
-
-
+ expected = <<~HTML +
+ #{'' unless ::Rails::VERSION::STRING >= '6'} +
+ + + +
You must accept the terms.
+
+
HTML actual = bootstrap_form_for(@user) do |f| f.check_box(:terms, label: "I agree to the terms", error_message: true) @@ -657,16 +657,16 @@ class BootstrapCheckboxTest < ActionView::TestCase test "check_box with error is wrapped correctly with custom option set" do @user.errors.add(:terms, "You must accept the terms.") - expected = <<-HTML.strip_heredoc -
- #{'' unless ::Rails::VERSION::STRING >= '6'} -
- - - -
You must accept the terms.
-
-
+ expected = <<~HTML +
+ #{'' unless ::Rails::VERSION::STRING >= '6'} +
+ + + +
You must accept the terms.
+
+
HTML actual = bootstrap_form_for(@user) do |f| f.check_box(:terms, label: "I agree to the terms", custom: true, error_message: true) @@ -675,7 +675,7 @@ class BootstrapCheckboxTest < ActionView::TestCase end test "check box with custom wrapper class" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -688,7 +688,7 @@ class BootstrapCheckboxTest < ActionView::TestCase end test "inline check box with custom wrapper class" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -702,7 +702,7 @@ class BootstrapCheckboxTest < ActionView::TestCase end test "custom check box with custom wrapper class" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -714,7 +714,7 @@ class BootstrapCheckboxTest < ActionView::TestCase end test "custom inline check box with custom wrapper class" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
diff --git a/test/bootstrap_fields_test.rb b/test/bootstrap_fields_test.rb index f7ec74d0c..bb6fba80c 100644 --- a/test/bootstrap_fields_test.rb +++ b/test/bootstrap_fields_test.rb @@ -6,7 +6,7 @@ class BootstrapFieldsTest < ActionView::TestCase setup :setup_test_fixture test "color fields are wrapped correctly" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -16,7 +16,7 @@ class BootstrapFieldsTest < ActionView::TestCase end test "date fields are wrapped correctly" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -26,7 +26,7 @@ class BootstrapFieldsTest < ActionView::TestCase end test "date time fields are wrapped correctly" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -36,7 +36,7 @@ class BootstrapFieldsTest < ActionView::TestCase end test "date time local fields are wrapped correctly" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -46,7 +46,7 @@ class BootstrapFieldsTest < ActionView::TestCase end test "email fields are wrapped correctly" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -56,7 +56,7 @@ class BootstrapFieldsTest < ActionView::TestCase end test "file fields are wrapped correctly" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -69,7 +69,7 @@ class BootstrapFieldsTest < ActionView::TestCase end test "file field placeholder can be customized" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -83,7 +83,7 @@ class BootstrapFieldsTest < ActionView::TestCase if ::Rails::VERSION::STRING > "5.1" test "file field placeholder has appropriate `for` attribute when used in form_with" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -98,18 +98,18 @@ class BootstrapFieldsTest < ActionView::TestCase test "file fields are wrapped correctly with error" do @user.errors.add(:misc, "error for test") - expected = <<-HTML.strip_heredoc -
- #{'' unless ::Rails::VERSION::STRING >= '6'} -
- -
- - -
error for test
+ expected = <<~HTML + + #{'' unless ::Rails::VERSION::STRING >= '6'} +
+ +
+ + +
error for test
+
-
- + HTML assert_equivalent_xml expected, bootstrap_form_for(@user) { |f| f.file_field(:misc) } end @@ -120,7 +120,7 @@ class BootstrapFieldsTest < ActionView::TestCase end test "month local fields are wrapped correctly" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -130,7 +130,7 @@ class BootstrapFieldsTest < ActionView::TestCase end test "number fields are wrapped correctly" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -140,7 +140,7 @@ class BootstrapFieldsTest < ActionView::TestCase end test "password fields are wrapped correctly" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -151,7 +151,7 @@ class BootstrapFieldsTest < ActionView::TestCase end test "phone/telephone fields are wrapped correctly" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -162,7 +162,7 @@ class BootstrapFieldsTest < ActionView::TestCase end test "range fields are wrapped correctly" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -172,7 +172,7 @@ class BootstrapFieldsTest < ActionView::TestCase end test "search fields are wrapped correctly" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -182,7 +182,7 @@ class BootstrapFieldsTest < ActionView::TestCase end test "text areas are wrapped correctly" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -193,11 +193,11 @@ class BootstrapFieldsTest < ActionView::TestCase if ::Rails::VERSION::STRING > "5.1" && ::Rails::VERSION::STRING < "5.2" test "text areas are wrapped correctly form_with Rails 5.1" do - expected = <<-HTML.strip_heredoc -
- - -
+ expected = <<~HTML +
+ + +
HTML assert_equivalent_xml expected, form_with_builder.text_area(:comments) end @@ -205,18 +205,18 @@ class BootstrapFieldsTest < ActionView::TestCase if ::Rails::VERSION::STRING > "5.2" test "text areas are wrapped correctly form_with Rails 5.2+" do - expected = <<-HTML.strip_heredoc -
- - -
+ expected = <<~HTML +
+ + +
HTML assert_equivalent_xml expected, form_with_builder.text_area(:comments) end end test "text fields are wrapped correctly" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -226,7 +226,7 @@ class BootstrapFieldsTest < ActionView::TestCase end test "text fields are wrapped correctly when horizontal and form-row given" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -239,7 +239,7 @@ class BootstrapFieldsTest < ActionView::TestCase end test "field 'id' attribute is used to specify label 'for' attribute" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -249,7 +249,7 @@ class BootstrapFieldsTest < ActionView::TestCase end test "time fields are wrapped correctly" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -259,7 +259,7 @@ class BootstrapFieldsTest < ActionView::TestCase end test "url fields are wrapped correctly" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -269,7 +269,7 @@ class BootstrapFieldsTest < ActionView::TestCase end test "check_box fields are wrapped correctly" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -280,7 +280,7 @@ class BootstrapFieldsTest < ActionView::TestCase end test "custom check_box fields are wrapped correctly" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -291,7 +291,7 @@ class BootstrapFieldsTest < ActionView::TestCase end test "switch-style check_box fields are wrapped correctly" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -302,7 +302,7 @@ class BootstrapFieldsTest < ActionView::TestCase end test "week fields are wrapped correctly" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -320,7 +320,7 @@ class BootstrapFieldsTest < ActionView::TestCase end end - expected = <<-HTML.strip_heredoc + expected = <<~HTML
#{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -341,7 +341,7 @@ class BootstrapFieldsTest < ActionView::TestCase end end - expected = <<-HTML.strip_heredoc + expected = <<~HTML #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -362,7 +362,7 @@ class BootstrapFieldsTest < ActionView::TestCase end end - expected = <<-HTML.strip_heredoc + expected = <<~HTML #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -386,7 +386,7 @@ class BootstrapFieldsTest < ActionView::TestCase end end - expected = <<-HTML.strip_heredoc + expected = <<~HTML #{'' unless ::Rails::VERSION::STRING >= '6'}
diff --git a/test/bootstrap_form_group_test.rb b/test/bootstrap_form_group_test.rb index 4e1f23cf6..24a550d2f 100644 --- a/test/bootstrap_form_group_test.rb +++ b/test/bootstrap_form_group_test.rb @@ -6,7 +6,7 @@ class BootstrapFormGroupTest < ActionView::TestCase setup :setup_test_fixture test "changing the label text via the label option parameter" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -16,7 +16,7 @@ class BootstrapFormGroupTest < ActionView::TestCase end test "changing the label text via the html_options label hash" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -26,7 +26,7 @@ class BootstrapFormGroupTest < ActionView::TestCase end test "hiding a label" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -36,7 +36,7 @@ class BootstrapFormGroupTest < ActionView::TestCase end test "adding a custom label class via the label_class parameter" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -46,7 +46,7 @@ class BootstrapFormGroupTest < ActionView::TestCase end test "adding a custom label class via the html_options label hash" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -56,7 +56,7 @@ class BootstrapFormGroupTest < ActionView::TestCase end test "adding a custom label and changing the label text via the html_options label hash" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -66,7 +66,7 @@ class BootstrapFormGroupTest < ActionView::TestCase end test "skipping a label" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -75,7 +75,7 @@ class BootstrapFormGroupTest < ActionView::TestCase end test "preventing a label from having the required class with :skip_required" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -87,7 +87,7 @@ class BootstrapFormGroupTest < ActionView::TestCase end test "preventing a label from having the required class" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -97,7 +97,7 @@ class BootstrapFormGroupTest < ActionView::TestCase end test "forcing a label to have the required class" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -107,7 +107,7 @@ class BootstrapFormGroupTest < ActionView::TestCase end test "label as placeholder" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -117,7 +117,7 @@ class BootstrapFormGroupTest < ActionView::TestCase end test "adding prepend text" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -132,7 +132,7 @@ class BootstrapFormGroupTest < ActionView::TestCase end test "adding append text" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -164,7 +164,7 @@ class BootstrapFormGroupTest < ActionView::TestCase end test "adding both prepend and append text" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -185,7 +185,7 @@ class BootstrapFormGroupTest < ActionView::TestCase @user.email = nil assert @user.invalid? - expected = <<-HTML.strip_heredoc + expected = <<~HTML #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -207,7 +207,7 @@ class BootstrapFormGroupTest < ActionView::TestCase end test "help messages for default forms" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -218,7 +218,7 @@ class BootstrapFormGroupTest < ActionView::TestCase end test "help messages for horizontal forms" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -231,7 +231,7 @@ class BootstrapFormGroupTest < ActionView::TestCase end test "help messages to look up I18n automatically" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -252,7 +252,7 @@ class BootstrapFormGroupTest < ActionView::TestCase } }) - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -281,7 +281,7 @@ class BootstrapFormGroupTest < ActionView::TestCase end test "help messages to ignore translation when user disables help" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -295,7 +295,7 @@ class BootstrapFormGroupTest < ActionView::TestCase ''.html_safe end - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -311,7 +311,7 @@ class BootstrapFormGroupTest < ActionView::TestCase ''.html_safe end - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -326,7 +326,7 @@ class BootstrapFormGroupTest < ActionView::TestCase ''.html_safe end - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -342,7 +342,7 @@ class BootstrapFormGroupTest < ActionView::TestCase ''.html_safe end - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -357,7 +357,7 @@ class BootstrapFormGroupTest < ActionView::TestCase ''.html_safe end - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -372,7 +372,7 @@ class BootstrapFormGroupTest < ActionView::TestCase ''.html_safe end - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -387,7 +387,7 @@ class BootstrapFormGroupTest < ActionView::TestCase ''.html_safe end - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -411,7 +411,7 @@ class BootstrapFormGroupTest < ActionView::TestCase html end - expected = <<-HTML.strip_heredoc + expected = <<~HTML

Bar

can't be blank, is too short (minimum is 5 characters)
@@ -431,7 +431,7 @@ class BootstrapFormGroupTest < ActionView::TestCase end end - expected = <<-HTML.strip_heredoc + expected = <<~HTML #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -455,7 +455,7 @@ class BootstrapFormGroupTest < ActionView::TestCase end test "adds class to wrapped form_group by a field" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -468,7 +468,7 @@ class BootstrapFormGroupTest < ActionView::TestCase @user.email = nil assert @user.invalid? - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -490,7 +490,7 @@ class BootstrapFormGroupTest < ActionView::TestCase f.text_field(:email, help: "This is required", wrapper_class: "none-margin") end - expected = <<-HTML.strip_heredoc + expected = <<~HTML #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -508,7 +508,7 @@ class BootstrapFormGroupTest < ActionView::TestCase @horizontal_builder.submit end - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -523,7 +523,7 @@ class BootstrapFormGroupTest < ActionView::TestCase @horizontal_builder.submit end - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -541,7 +541,7 @@ class BootstrapFormGroupTest < ActionView::TestCase output += @horizontal_builder.text_field(:email) - expected = <<-HTML.strip_heredoc + expected = <<~HTML
Hallo
@@ -556,7 +556,7 @@ class BootstrapFormGroupTest < ActionView::TestCase end test "adds data-attributes (or any other options) to wrapper" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -571,7 +571,7 @@ class BootstrapFormGroupTest < ActionView::TestCase end test "passing options to a form control get passed through" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -585,7 +585,7 @@ class BootstrapFormGroupTest < ActionView::TestCase nil end - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -594,7 +594,7 @@ class BootstrapFormGroupTest < ActionView::TestCase end test "custom form group layout option" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -614,7 +614,7 @@ class BootstrapFormGroupTest < ActionView::TestCase ''.html_safe end - expected = <<-HTML.strip_heredoc + expected = <<~HTML
@@ -635,7 +635,7 @@ class BootstrapFormGroupTest < ActionView::TestCase end test ":input_group_class should apply to input-group" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
diff --git a/test/bootstrap_form_test.rb b/test/bootstrap_form_test.rb index f4604d219..7192ee075 100644 --- a/test/bootstrap_form_test.rb +++ b/test/bootstrap_form_test.rb @@ -6,7 +6,7 @@ class BootstrapFormTest < ActionView::TestCase setup :setup_test_fixture test "default-style forms" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML #{'' unless ::Rails::VERSION::STRING >= '6'} @@ -15,7 +15,7 @@ class BootstrapFormTest < ActionView::TestCase end test "default-style form fields layout horizontal" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
#{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -67,7 +67,7 @@ class BootstrapFormTest < ActionView::TestCase end test "default-style form fields layout inline" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -119,7 +119,7 @@ class BootstrapFormTest < ActionView::TestCase # No need to test 5.2 separately for this case, since 5.2 does *not* # generate a default ID for the form element. test "default-style forms bootstrap_form_with Rails 5.1+" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML #{'' unless ::Rails::VERSION::STRING >= '6'} @@ -130,7 +130,7 @@ class BootstrapFormTest < ActionView::TestCase end test "inline-style forms" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -175,7 +175,7 @@ class BootstrapFormTest < ActionView::TestCase end test "horizontal-style forms" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -226,7 +226,7 @@ class BootstrapFormTest < ActionView::TestCase end test "horizontal-style form fields layout default" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -272,7 +272,7 @@ class BootstrapFormTest < ActionView::TestCase end test "horizontal-style form fields layout inline" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -318,7 +318,7 @@ class BootstrapFormTest < ActionView::TestCase end test "existing styles aren't clobbered when specifying a form style" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -334,7 +334,7 @@ class BootstrapFormTest < ActionView::TestCase end test "given role attribute should not be covered by default role attribute" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML #{'' unless ::Rails::VERSION::STRING >= '6'} @@ -344,7 +344,7 @@ class BootstrapFormTest < ActionView::TestCase test "allows to set blank default form attributes via configuration" do BootstrapForm.config.stubs(:default_form_attributes).returns({}) - expected = <<-HTML.strip_heredoc + expected = <<~HTML
#{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -354,7 +354,7 @@ class BootstrapFormTest < ActionView::TestCase test "allows to set custom default form attributes via configuration" do BootstrapForm.config.stubs(:default_form_attributes).returns(foo: "bar") - expected = <<-HTML.strip_heredoc + expected = <<~HTML
#{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -363,7 +363,7 @@ class BootstrapFormTest < ActionView::TestCase end test "bootstrap_form_tag acts like a form tag" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML
#{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -377,7 +377,7 @@ class BootstrapFormTest < ActionView::TestCase end test "bootstrap_form_for does not clobber custom options" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -390,7 +390,7 @@ class BootstrapFormTest < ActionView::TestCase end test "bootstrap_form_tag does not clobber custom options" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -410,15 +410,15 @@ class BootstrapFormTest < ActionView::TestCase id = "_misc" name = "[misc]" end - expected = <<-HTML.strip_heredoc - - #{'' unless ::Rails::VERSION::STRING >= '6'} -
- - - -
- + expected = <<~HTML +
+ #{'' unless ::Rails::VERSION::STRING >= '6'} +
+ + + +
+
HTML assert_equivalent_xml expected, bootstrap_form_tag(url: "/users") { |f| f.check_box :misc } end @@ -427,7 +427,7 @@ class BootstrapFormTest < ActionView::TestCase @user.email = nil assert @user.invalid? - expected = <<-HTML.strip_heredoc + expected = <<~HTML
#{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -443,7 +443,7 @@ class BootstrapFormTest < ActionView::TestCase @user.email = nil assert @user.invalid? - expected = <<-HTML.strip_heredoc + expected = <<~HTML #{'' unless ::Rails::VERSION::STRING >= '6'}
@@ -462,15 +462,15 @@ class BootstrapFormTest < ActionView::TestCase @user.email = nil assert @user.invalid? - expected = <<-HTML.strip_heredoc - - #{'' unless ::Rails::VERSION::STRING >= '6'} -
- - -
can't be blank, is too short (minimum is 5 characters)
-
- + expected = <<~HTML +
+ #{'' unless ::Rails::VERSION::STRING >= '6'} +
+ + +
can't be blank, is too short (minimum is 5 characters)
+
+
HTML assert_equivalent_xml expected, bootstrap_form_for(@user, label_errors: true, inline_errors: true) { |f| f.text_field :email } ensure @@ -481,7 +481,7 @@ class BootstrapFormTest < ActionView::TestCase @user.email = nil assert @user.invalid? - expected = <<-HTML.strip_heredoc + expected = <<~HTML

Please fix the following errors:

    @@ -498,7 +498,7 @@ class BootstrapFormTest < ActionView::TestCase @user.email = nil assert @user.invalid? - expected = <<-HTML.strip_heredoc + expected = <<~HTML

    Please fix the following errors:

      @@ -519,7 +519,7 @@ class BootstrapFormTest < ActionView::TestCase f.alert_message("Please fix the following errors:") end - expected = <<-HTML.strip_heredoc + expected = <<~HTML
      #{'' unless ::Rails::VERSION::STRING >= '6'}
      @@ -543,7 +543,7 @@ class BootstrapFormTest < ActionView::TestCase f.alert_message("Please fix the following errors:", error_summary: false) end - expected = <<-HTML.strip_heredoc + expected = <<~HTML #{'' unless ::Rails::VERSION::STRING >= '6'}
      @@ -562,7 +562,7 @@ class BootstrapFormTest < ActionView::TestCase f.alert_message("Please fix the following errors:", error_summary: true) end - expected = <<-HTML.strip_heredoc + expected = <<~HTML #{'' unless ::Rails::VERSION::STRING >= '6'}
      @@ -582,7 +582,7 @@ class BootstrapFormTest < ActionView::TestCase @user.email = nil assert @user.invalid? - expected = <<-HTML.strip_heredoc + expected = <<~HTML
      • Email can't be blank
      • Email is too short (minimum is 5 characters)
      • @@ -603,14 +603,14 @@ class BootstrapFormTest < ActionView::TestCase @user.email = nil assert @user.invalid? - expected = <<-HTML.strip_heredoc + expected = <<~HTML
        Email can't be blank, Email is too short (minimum is 5 characters)
        HTML assert_equivalent_xml expected, @builder.errors_on(:email) end test "custom label width for horizontal forms" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML #{'' unless ::Rails::VERSION::STRING >= '6'}
        @@ -626,7 +626,7 @@ class BootstrapFormTest < ActionView::TestCase end test "offset for form group without label respects label width for horizontal forms" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML #{'' unless ::Rails::VERSION::STRING >= '6'}
        @@ -642,7 +642,7 @@ class BootstrapFormTest < ActionView::TestCase end test "offset for form group without label respects multiple label widths for horizontal forms" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML #{'' unless ::Rails::VERSION::STRING >= '6'}
        @@ -658,7 +658,7 @@ class BootstrapFormTest < ActionView::TestCase end test "custom input width for horizontal forms" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML #{'' unless ::Rails::VERSION::STRING >= '6'}
        @@ -674,7 +674,7 @@ class BootstrapFormTest < ActionView::TestCase end test "additional input col class" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML #{'' unless ::Rails::VERSION::STRING >= '6'}
        @@ -698,7 +698,7 @@ class BootstrapFormTest < ActionView::TestCase f.text_field(:email, help: "This is required") end - expected = <<-HTML.strip_heredoc + expected = <<~HTML #{'' unless ::Rails::VERSION::STRING >= '6'}
        @@ -719,7 +719,7 @@ class BootstrapFormTest < ActionView::TestCase f.text_field(:email, help: "This is required") end - expected = <<-HTML.strip_heredoc + expected = <<~HTML #{'' unless ::Rails::VERSION::STRING >= '6'}
        @@ -744,7 +744,7 @@ class BootstrapFormTest < ActionView::TestCase f.text_field(:email, help: "This is required") end - expected = <<-HTML.strip_heredoc + expected = <<~HTML #{'' unless ::Rails::VERSION::STRING >= '6'}
        @@ -764,15 +764,15 @@ class BootstrapFormTest < ActionView::TestCase f.text_field(:email) end - expected = <<-HTML.strip_heredoc - - #{'' unless ::Rails::VERSION::STRING >= '6'} -
        - - - This is useful help -
        - + expected = <<~HTML +
        + #{'' unless ::Rails::VERSION::STRING >= '6'} +
        + + + This is useful help +
        +
        HTML assert_equivalent_xml expected, output ensure @@ -781,7 +781,7 @@ class BootstrapFormTest < ActionView::TestCase test "allows the form object to be nil" do builder = BootstrapForm::FormBuilder.new :other_model, nil, self, {} - expected = <<-HTML.strip_heredoc + expected = <<~HTML
        diff --git a/test/bootstrap_other_components_test.rb b/test/bootstrap_other_components_test.rb index 06a6ce3f9..700c3a5ca 100644 --- a/test/bootstrap_other_components_test.rb +++ b/test/bootstrap_other_components_test.rb @@ -8,7 +8,7 @@ class BootstrapOtherComponentsTest < ActionView::TestCase test "static control" do output = @horizontal_builder.static_control :email - expected = <<-HTML.strip_heredoc + expected = <<~HTML
        @@ -22,7 +22,7 @@ class BootstrapOtherComponentsTest < ActionView::TestCase test "static control can have custom_id" do output = @horizontal_builder.static_control :email, id: "custom_id" - expected = <<-HTML.strip_heredoc + expected = <<~HTML
        @@ -36,7 +36,7 @@ class BootstrapOtherComponentsTest < ActionView::TestCase test "static control doesn't require an actual attribute" do output = @horizontal_builder.static_control nil, label: "My Label", value: "this is a test" - expected = <<-HTML.strip_heredoc + expected = <<~HTML
        @@ -50,7 +50,7 @@ class BootstrapOtherComponentsTest < ActionView::TestCase test "static control doesn't require a name" do output = @horizontal_builder.static_control label: "Custom Label", value: "Custom Control" - expected = <<-HTML.strip_heredoc + expected = <<~HTML
        @@ -64,7 +64,7 @@ class BootstrapOtherComponentsTest < ActionView::TestCase test "static control support a nil value" do output = @horizontal_builder.static_control label: "Custom Label", value: nil - expected = <<-HTML.strip_heredoc + expected = <<~HTML
        @@ -78,7 +78,7 @@ class BootstrapOtherComponentsTest < ActionView::TestCase test "static control won't overwrite a control_class that is passed by the user" do output = @horizontal_builder.static_control :email, control_class: "test_class" - expected = <<-HTML.strip_heredoc + expected = <<~HTML
        @@ -94,7 +94,7 @@ class BootstrapOtherComponentsTest < ActionView::TestCase "this is a test" end - expected = <<-HTML.strip_heredoc + expected = <<~HTML
        this is a test
        @@ -108,7 +108,7 @@ class BootstrapOtherComponentsTest < ActionView::TestCase "this is a test" end - expected = <<-HTML.strip_heredoc + expected = <<~HTML
        this is a test
        @@ -122,7 +122,7 @@ class BootstrapOtherComponentsTest < ActionView::TestCase "Custom Control" end - expected = <<-HTML.strip_heredoc + expected = <<~HTML
        Custom Control
        @@ -132,7 +132,7 @@ class BootstrapOtherComponentsTest < ActionView::TestCase end test "regular button uses proper css classes" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML HTML assert_equivalent_xml expected, @@ -140,7 +140,7 @@ class BootstrapOtherComponentsTest < ActionView::TestCase end test "regular button can have extra css classes" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML HTML assert_equivalent_xml expected, diff --git a/test/bootstrap_radio_button_test.rb b/test/bootstrap_radio_button_test.rb index 9f76172c2..9b41a5ac6 100644 --- a/test/bootstrap_radio_button_test.rb +++ b/test/bootstrap_radio_button_test.rb @@ -6,7 +6,7 @@ class BootstrapRadioButtonTest < ActionView::TestCase setup :setup_test_fixture test "radio_button is wrapped correctly" do - expected = <<-HTML.strip_heredoc + expected = <<~HTML