1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Move dependency tracker tests shared examples

The bulk of these tests should be run using both the ERBTracker and the RipperTracker until ERBTracker is eventually removed.
This commit is contained in:
Matt-Yorkley 2021-08-08 12:40:20 +01:00
parent caac7313c5
commit 73b3772e49

View file

@ -55,11 +55,8 @@ class DependencyTrackerTest < ActionView::TestCase
end
end
class RipperTrackerTest < Minitest::Test
def make_tracker(name, template)
ActionView::DependencyTracker::RipperTracker.new(name, template)
end
# Tests run with both ERBTracker and RipperTracker
module SharedTrackerTests
def test_dependency_of_erb_template_with_number_in_filename
template = FakeTemplate.new("<%= render 'messages/message123' %>", :erb)
tracker = make_tracker("messages/_message123", template)
@ -71,7 +68,7 @@ class RipperTrackerTest < Minitest::Test
template = FakeTemplate.new("<%= render partial: 'messages/show', layout: 'messages/layout' %>", :erb)
tracker = make_tracker("multiple/_dependencies", template)
assert_equal ["messages/show", "messages/layout"], tracker.dependencies
assert_equal ["messages/layout", "messages/show"], tracker.dependencies.sort
end
def test_dependency_of_template_layout_standalone
@ -209,6 +206,22 @@ class RipperTrackerTest < Minitest::Test
assert_equal ["single/\#{quote}"], tracker.dependencies
end
end
class ERBTrackerTest < Minitest::Test
include SharedTrackerTests
def make_tracker(name, template)
ActionView::DependencyTracker::ERBTracker.new(name, template)
end
end
class RipperTrackerTest < Minitest::Test
include SharedTrackerTests
def make_tracker(name, template)
ActionView::DependencyTracker::RipperTracker.new(name, template)
end
def test_dependencies_skip_unknown_options
template = FakeTemplate.new(%{