Skip to content

Use file_fixture for file fixtures #75

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
14 changes: 7 additions & 7 deletions test/purger_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Tailwindcss::PurgerTest < ActiveSupport::TestCase

test "extract class names from erb file" do
assert_equal %w[ div class max-w-7xl mx-auto my-1.5 px-4 sm:px-6 lg:px-8 sm:py-0.5 translate-x-1/2 ].sort,
Tailwindcss::Purger.extract_class_names_from(Pathname.new(__dir__).join("fixtures/simple.html.erb"))
Tailwindcss::Purger.extract_class_names_from(file_fixture("simple.html.erb"))
end

test "extract class names from haml string" do
Expand All @@ -18,7 +18,7 @@ class Tailwindcss::PurgerTest < ActiveSupport::TestCase

test "extract class names from haml file" do
assert_equal %w[ class max-w-7xl mx-auto my-1.5 px-4 sm:px-6 lg:px-8 sm:py-0.5 translate-x-1/2 ].sort,
Tailwindcss::Purger.extract_class_names_from(Pathname.new(__dir__).join("fixtures/simple.html.haml"))
Tailwindcss::Purger.extract_class_names_from(file_fixture("simple.html.haml"))
end

test "extract class names from slim string" do
Expand All @@ -28,7 +28,7 @@ class Tailwindcss::PurgerTest < ActiveSupport::TestCase

test "extract class names from slim file" do
assert_equal %w[ class max-w-7xl mx-auto my-1.5 px-4 sm:px-6 lg:px-8 sm:py-0.5 translate-x-1/2 ].sort,
Tailwindcss::Purger.extract_class_names_from(Pathname.new(__dir__).join("fixtures/simple.html.slim"))
Tailwindcss::Purger.extract_class_names_from(file_fixture("simple.html.slim"))
end

test "basic purge" do
Expand Down Expand Up @@ -104,7 +104,7 @@ class Tailwindcss::PurgerTest < ActiveSupport::TestCase
end

test "purge shouldn't remove placeholder selectors" do
purged = purged_tailwind_from Pathname(__dir__).join("fixtures/placeholders.html.erb")
purged = purged_tailwind_from file_fixture("placeholders.html.erb")

assert purged =~ /.placeholder-transparent\:\:-moz-placeholder \{/
assert purged =~ /.placeholder-transparent\:-ms-input-placeholder \{/
Expand Down Expand Up @@ -189,15 +189,15 @@ def purged_tailwind(keep_these_class_names:)
end

def purged_tailwind_from_erb_fixtures
$purged_tailwind_from_erb_fixtures ||= purged_tailwind_from Pathname(__dir__).glob("fixtures/*.html.erb")
$purged_tailwind_from_erb_fixtures ||= purged_tailwind_from Pathname(__dir__).glob("fixtures/files/*.html.erb")
end

def purged_tailwind_from_haml_fixtures
$purged_tailwind_from_haml_fixtures ||= purged_tailwind_from Pathname(__dir__).glob("fixtures/*.html.haml")
$purged_tailwind_from_haml_fixtures ||= purged_tailwind_from Pathname(__dir__).glob("fixtures/files/*.html.haml")
end

def purged_tailwind_from_slim_fixtures
$purged_tailwind_from_haml_fixtures ||= purged_tailwind_from Pathname(__dir__).glob("fixtures/*.html.slim")
$purged_tailwind_from_haml_fixtures ||= purged_tailwind_from Pathname(__dir__).glob("fixtures/files/*.html.slim")
end

def purged_tailwind_from files
Expand Down
3 changes: 3 additions & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@
require "rails/test_unit/reporter"
Rails::TestUnitReporter.executable = 'bin/test'

class ActiveSupport::TestCase
self.file_fixture_path = File.expand_path("fixtures/files", __dir__)
end