From c41d4376e5f4d3ced536d9fb9563fd8b573a9b1e Mon Sep 17 00:00:00 2001 From: Konstantin Tennhard Date: Tue, 26 Dec 2023 16:15:01 +0100 Subject: [PATCH 1/6] Update ActionView dependency Version 5 of ActionView introduced a breaking change to `ActionView::Base.new`. The initializer now expects several arguments. However, `ActionView::Base` provides several convenience initializers that make it easy to instantiate a view context without any arguments. --- action_widget.gemspec | 2 +- spec/action_widget_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/action_widget.gemspec b/action_widget.gemspec index 94dfdfe..21b83f5 100644 --- a/action_widget.gemspec +++ b/action_widget.gemspec @@ -20,5 +20,5 @@ Gem::Specification.new do |gem| gem.add_development_dependency 'pry' gem.add_development_dependency 'rake', '~> 10.0' gem.add_development_dependency 'rspec', '~> 3.3' - gem.add_development_dependency 'actionview', '~> 4.0' + gem.add_development_dependency 'actionview', '>= 6.0' end diff --git a/spec/action_widget_spec.rb b/spec/action_widget_spec.rb index fd812ed..3b7d3c9 100644 --- a/spec/action_widget_spec.rb +++ b/spec/action_widget_spec.rb @@ -18,14 +18,14 @@ class ViewContext < ActionView::Base end RSpec.describe ViewContext do - subject(:view_context) { described_class.new } + subject(:view_context) { described_class.empty } it 'should implement #respond_to_missing?' do expect(view_context.send(:respond_to_missing?, :dummy_widget)).to eq(true) end end RSpec.describe DummyWidget do - let(:view) { ViewContext.new } + let(:view) { ViewContext.empty } it "should delegate unknown method calls to the view context" do expect(described_class.new(view).render).to eq("

") From d56a1da69e8f91b2a2f33bab5edf760244b81998 Mon Sep 17 00:00:00 2001 From: Konstantin Tennhard Date: Tue, 26 Dec 2023 16:15:44 +0100 Subject: [PATCH 2/6] Update Rake dependency Rake is no longer constrained to a particular version. --- action_widget.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action_widget.gemspec b/action_widget.gemspec index 21b83f5..c3c287d 100644 --- a/action_widget.gemspec +++ b/action_widget.gemspec @@ -18,7 +18,7 @@ Gem::Specification.new do |gem| gem.add_dependency 'activesupport', '> 2.2' gem.add_development_dependency 'pry' - gem.add_development_dependency 'rake', '~> 10.0' + gem.add_development_dependency 'rake' gem.add_development_dependency 'rspec', '~> 3.3' gem.add_development_dependency 'actionview', '>= 6.0' end From 1515dc6a8b9c33bc38a7762e2234dc42577a3a78 Mon Sep 17 00:00:00 2001 From: Konstantin Tennhard Date: Tue, 26 Dec 2023 16:33:40 +0100 Subject: [PATCH 3/6] New development dependecy: ruby-lsp Applies rubocop fixes --- action_widget.gemspec | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/action_widget.gemspec b/action_widget.gemspec index c3c287d..4c50c58 100644 --- a/action_widget.gemspec +++ b/action_widget.gemspec @@ -1,24 +1,27 @@ -# -*- encoding: utf-8 -*- -require File.expand_path('../lib/action_widget/version.rb', __FILE__) +# frozen_string_literal: true + +require File.expand_path('lib/action_widget/version.rb', __dir__) Gem::Specification.new do |gem| - gem.authors = ["Konstantin Tennhard"] - gem.email = ["me@t6d.de"] - gem.summary = %q{Reusable view components for your Ruby web application} - gem.homepage = "http://github.com/t6d/action_widget" + gem.authors = ['Konstantin Tennhard'] + gem.email = ['me@t6d.de'] + gem.summary = 'Reusable view components for your Ruby web application' + gem.homepage = 'http://github.com/t6d/action_widget' - gem.files = `git ls-files`.split($\) - gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) } - gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) - gem.name = "action_widget" - gem.require_paths = ["lib"] - gem.version = ActionWidget::VERSION + gem.files = `git ls-files`.split($\) + gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) } + gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) + gem.name = 'action_widget' + gem.require_paths = ['lib'] + gem.version = ActionWidget::VERSION + gem.required_ruby_version = '>= 2.7.0' - gem.add_dependency 'smart_properties', '~> 1.10' gem.add_dependency 'activesupport', '> 2.2' + gem.add_dependency 'smart_properties', '~> 1.10' + gem.add_development_dependency 'actionview', '>= 6.0' gem.add_development_dependency 'pry' gem.add_development_dependency 'rake' gem.add_development_dependency 'rspec', '~> 3.3' - gem.add_development_dependency 'actionview', '>= 6.0' + gem.add_development_dependency 'ruby-lsp' end From f86ab56986dde1b88e3ce820b5ba09409b179e47 Mon Sep 17 00:00:00 2001 From: Konstantin Tennhard Date: Sun, 9 Mar 2025 22:25:22 -0400 Subject: [PATCH 4/6] Update Railtie and configuration defaults for better integration Refactor the Railtie initializer to use `ActiveSupport.on_load` for cleaner and more compliant integration with ActionView. Adjust the default `directory` property to automatically pluralize the generated directory name for improved consistency and usability. --- lib/action_widget/configuration.rb | 2 +- lib/action_widget/extensions/rails/railtie.rb | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/action_widget/configuration.rb b/lib/action_widget/configuration.rb index 18f4861..6d1e2a6 100644 --- a/lib/action_widget/configuration.rb +++ b/lib/action_widget/configuration.rb @@ -4,7 +4,7 @@ class Configuration property :prefix property :suffix property :superclass, required: true, default: -> { ActionWidget::Base } - property :directory, required: true, converts: :to_s, accepts: ->(string) { !string.empty? }, default: -> { [underscored_prefix, underscored_suffix].compact.join("_") } + property :directory, required: true, converts: :to_s, accepts: ->(string) { !string.empty? }, default: -> { [underscored_prefix, underscored_suffix].compact.join("_").pluralize } property :minitest_superclass attr_reader :pattern diff --git a/lib/action_widget/extensions/rails/railtie.rb b/lib/action_widget/extensions/rails/railtie.rb index 9d19c3b..7e2ed6d 100644 --- a/lib/action_widget/extensions/rails/railtie.rb +++ b/lib/action_widget/extensions/rails/railtie.rb @@ -5,7 +5,9 @@ module Extensions module Rails class Railtie < ::Rails::Railtie initializer "action_widget.helper" do - ActionView::Base.send(:include, ::ActionWidget::ViewHelper) + ActiveSupport.on_load(:action_view) do + include ActionWidget::ViewHelper + end end end end From 06fc59c695721fa0ac90613fb6bfc05cb9514ce4 Mon Sep 17 00:00:00 2001 From: Konstantin Tennhard Date: Sun, 9 Mar 2025 22:44:21 -0400 Subject: [PATCH 5/6] Update gemspec dependencies for development Upgraded RSpec to version ~> 3.13 and added new development dependencies: ostruct, mutex_m, base64, and bigdecimal. These changes ensure compatibility with the latest Ruby version. --- action_widget.gemspec | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/action_widget.gemspec b/action_widget.gemspec index 4c50c58..55462da 100644 --- a/action_widget.gemspec +++ b/action_widget.gemspec @@ -22,6 +22,10 @@ Gem::Specification.new do |gem| gem.add_development_dependency 'actionview', '>= 6.0' gem.add_development_dependency 'pry' gem.add_development_dependency 'rake' - gem.add_development_dependency 'rspec', '~> 3.3' + gem.add_development_dependency 'rspec', '~> 3.13' gem.add_development_dependency 'ruby-lsp' + gem.add_development_dependency 'ostruct' + gem.add_development_dependency 'mutex_m' + gem.add_development_dependency 'base64' + gem.add_development_dependency 'bigdecimal' end From ad4c75552959745abec091dc22916fcad95335ca Mon Sep 17 00:00:00 2001 From: Konstantin Tennhard Date: Sun, 9 Mar 2025 22:46:37 -0400 Subject: [PATCH 6/6] Add GitHub Actions workflow for automated testing This commit introduces a workflow to run tests automatically on pushes and pull requests to the master branch. It sets up a job to test the codebase using Ruby version 3.4.1 on an Ubuntu environment, installs dependencies, and executes test cases. This ensures consistent and automated validation of code changes. --- .github/workflows/testing.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/testing.yml diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml new file mode 100644 index 0000000..c80b8a8 --- /dev/null +++ b/.github/workflows/testing.yml @@ -0,0 +1,26 @@ +name: Testing + +on: + push: + branches: [master] + pull_request: + branches: [master] + workflow_dispatch: + +jobs: + test: + name: Ruby v${{ matrix.ruby_version}} + runs-on: ubuntu-latest + strategy: + matrix: + ruby_version: [3.4.1] + steps: + - uses: actions/checkout@v2 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby_version }} + - name: Install dependencies + run: bundle install + - name: Run tests + run: bundle exec rake spec \ No newline at end of file