Skip to content

Commit

Permalink
use file base name if available for minitest
Browse files Browse the repository at this point in the history
  • Loading branch information
stephsachrajda committed Jan 4, 2024
1 parent b4d3f39 commit b931f8f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/deprecation_toolkit/read_write_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,12 @@ def recorded_deprecations_path(test)
if DeprecationToolkit::Configuration.test_runner == :rspec
test.example_group.file_path.sub(%r{^./spec/}, "").sub(/_spec.rb$/, "")
else
test.class.name.underscore
test_path = test_location(test)
if test_path == "unknown"
test.class.name.underscore
else
File.dirname(test.class.name.underscore) + "/" + File.basename(test_path, ".*")
end
end

Pathname(deprecation_folder).join("#{path}.yml")
Expand Down
17 changes: 17 additions & 0 deletions test/deprecation_toolkit/behaviors/record_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,23 @@ class RecordTest < ActiveSupport::TestCase
end
end

class TestClass < RecordTest
test ".trigger record deprecations using correct filename in subclasses" do
assert_deprecations_recorded("Foo", "Bar") do
deprecator.warn("Foo")
deprecator.warn("Bar")

trigger_deprecation_toolkit_behavior
end
end

private

def recorded_deprecations(to: @deprecation_path)
YAML.load_file("#{to}/deprecation_toolkit/behaviors/record_test/record_test.yml").fetch(name)
end
end

test ".trigger record deprecations for proc path" do
Configuration.deprecation_path = proc do
File.join(@deprecation_path, "prefix")
Expand Down

0 comments on commit b931f8f

Please sign in to comment.