From bb20083050c47fbc171704d8f4aaa2473e4d743a Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Fri, 15 Nov 2024 09:56:53 +0900 Subject: [PATCH] Port test_warn_dependency.rb to RSpec example --- spec/bundler/bundled_gems_spec.rb | 21 +++++++++++++++++++ tool/test_for_warn_bundled_gems/test.sh | 4 ---- .../test_warn_dependency.rb | 11 ---------- 3 files changed, 21 insertions(+), 15 deletions(-) delete mode 100644 tool/test_for_warn_bundled_gems/test_warn_dependency.rb diff --git a/spec/bundler/bundled_gems_spec.rb b/spec/bundler/bundled_gems_spec.rb index 90efd28194..f097429c7e 100644 --- a/spec/bundler/bundled_gems_spec.rb +++ b/spec/bundler/bundled_gems_spec.rb @@ -25,6 +25,27 @@ RSpec.describe "bundled_gems.rb" do expect(err).to include(/ostruct was loaded from (.*) from Ruby 3.5.0/) end + it "Show warning when bundled gems called as dependency" do + build_lib "activesupport", "7.0.7.2" do |s| + s.write "lib/active_support/all.rb", "require 'ostruct'" + end + + script <<-RUBY, env: { "BUNDLER_SPEC_GEM_REPO" => gem_repo1.to_s } + gemfile do + source "https://gem.repo1" + path "#{lib_path}" do + gem "activesupport", "7.0.7.2" + end + end + + require "active_support/all" + RUBY + + expect(err).to include(/ostruct was loaded from (.*) from Ruby 3.5.0/) + # TODO: We should assert caller location like below: + # $GEM_HOME/gems/activesupport-7.0.7.2/lib/active_support/core_ext/big_decimal.rb:3: warning: bigdecimal ... + end + it "Show warning dash gem like net/smtp" do script <<-RUBY gemfile do diff --git a/tool/test_for_warn_bundled_gems/test.sh b/tool/test_for_warn_bundled_gems/test.sh index 748b5159bd..4997bd0386 100755 --- a/tool/test_for_warn_bundled_gems/test.sh +++ b/tool/test_for_warn_bundled_gems/test.sh @@ -1,9 +1,5 @@ #!/bin/bash -echo "* Show warning when bundled gems called as dependency" -ruby test_warn_dependency.rb -echo - echo "* Show warning sub-feature like bigdecimal/util" ruby test_warn_sub_feature.rb echo diff --git a/tool/test_for_warn_bundled_gems/test_warn_dependency.rb b/tool/test_for_warn_bundled_gems/test_warn_dependency.rb deleted file mode 100644 index 31e416624c..0000000000 --- a/tool/test_for_warn_bundled_gems/test_warn_dependency.rb +++ /dev/null @@ -1,11 +0,0 @@ -require "bundler" -Bundler::Definition.no_lock = true - -require "bundler/inline" - -gemfile do - source "https://rubygems.org" - gem "activesupport", "7.0.7.2" -end - -require "active_support/all"