From ada85688f9b3f0d4a1b3876bdd8669d31ece305f Mon Sep 17 00:00:00 2001 From: Sebastian van Hesteren Date: Thu, 5 Sep 2024 13:23:43 +0200 Subject: [PATCH] Update pbbuilder and fix show_exceptions? errors. --- .ruby-version | 2 +- Gemfile | 2 +- Rakefile | 23 +++++++++++++++++++++-- lib/rails_twirp/exception_handling.rb | 2 +- lib/rails_twirp/version.rb | 2 +- rails_twirp.gemspec | 9 ++++----- test/test_helper.rb | 1 + 7 files changed, 30 insertions(+), 11 deletions(-) diff --git a/.ruby-version b/.ruby-version index 15a2799..619b537 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.3.0 +3.3.3 diff --git a/Gemfile b/Gemfile index 734075a..20123d1 100644 --- a/Gemfile +++ b/Gemfile @@ -6,7 +6,7 @@ source "https://rubygems.org" gemspec gem "sqlite3" -gem "pbbuilder" +gem "pbbuilder", github: "cheddar-me/pbbuilder", branch: "use-system-basic-object" gem "standard" gem "pry" diff --git a/Rakefile b/Rakefile index bb704a1..0e9ea47 100644 --- a/Rakefile +++ b/Rakefile @@ -6,8 +6,27 @@ require "rake/testtask" Rake::TestTask.new(:test) do |t| t.libs << "test" - t.pattern = "test/**/*_test.rb" - t.verbose = false + t.libs << "lib" + + # Running specific tests with line numbers, like with rails test, is not supported by default in rake. + # By setting the TESTOPS env var we can however specify the name of a single test with underscores instead of spaces. + # So run your single test by calling for ex: + # + # rake test /Users/sebastian/projects/cheddar/rails-twirp/test/ping_controller_test.rb "uncaught errors should bubble up to the test" + + file_name = ARGV[1] + test_name = ARGV[2]&.tr(" ", "_") + + ENV["TESTOPTS"] = "--verbose" + + t.test_files = if file_name + if test_name + ENV["TESTOPTS"] = ENV["TESTOPTS"] + " --name=#{test_name}" + end + [file_name] + else + FileList["test/**/*_test.rb"] + end end task default: :test diff --git a/lib/rails_twirp/exception_handling.rb b/lib/rails_twirp/exception_handling.rb index 4920c96..a0775ef 100644 --- a/lib/rails_twirp/exception_handling.rb +++ b/lib/rails_twirp/exception_handling.rb @@ -20,7 +20,7 @@ def process_action(*) # 1. When we 'show exceptions' we make the exception bubble up—this is useful for testing # If the exception gets raised here error reporting will happen in the middleware of the APM package # higher in the call stack. - raise e unless http_request.show_exceptions? + raise e unless http_request.get_header("action_dispatch.show_exceptions") # 2. We report the error to the error tracking service, this needs to be configured. RailsTwirp.unhandled_exception_handler&.call(e) diff --git a/lib/rails_twirp/version.rb b/lib/rails_twirp/version.rb index 38df953..924bb85 100644 --- a/lib/rails_twirp/version.rb +++ b/lib/rails_twirp/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module RailsTwirp - VERSION = "0.16" + VERSION = "0.17" end diff --git a/rails_twirp.gemspec b/rails_twirp.gemspec index 557eea1..f31a6e8 100644 --- a/rails_twirp.gemspec +++ b/rails_twirp.gemspec @@ -13,10 +13,9 @@ Gem::Specification.new do |spec| spec.files = `git ls-files`.split("\n") - # Rails has shipped an incompatible change in ActiveView, that was reverted in later versions - # but at this time has not been released as a 7.x version - # @see https://github.com/rails/rails/pull/51023 - spec.add_runtime_dependency "rails", ">= 6.1.3", " < 7.1" - spec.add_runtime_dependency "twirp", ">= 1.9", "< 1.11" + spec.add_runtime_dependency "rails", ">= 6.1.3", "!= 7.1" + spec.add_runtime_dependency "twirp", ">= 1.9" + spec.add_development_dependency "pry" + spec.required_ruby_version = ">= 3" end diff --git a/test/test_helper.rb b/test/test_helper.rb index 27888ff..d5bdfb8 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -7,6 +7,7 @@ ActiveRecord::Migrator.migrations_paths = [File.expand_path("../test/dummy/db/migrate", __dir__)] require "rails/test_help" require "rails/test_unit/reporter" +require "pry" Rails::TestUnitReporter.executable = "bin/test" # Load fixtures from the engine