Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -3717,12 +3717,20 @@ class ActiveSupport::TestCase
it "does not read the copied Redux Tailwind entry in pretend mode" do
redux_generator = redux_generator_fixture(pretend: true, tailwind: true)
client_entry = "app/javascript/src/HelloWorldApp/ror_components/HelloWorldApp.client.jsx"
simulate_existing_file("config/shakapacker.yml", <<~YAML)
default: &default
source_path: app/javascript

development:
<<: *default
YAML

allow(redux_generator).to receive(:copy_file)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The minimal YAML here (only source_path, no source_entry_path or other keys) is intentional and correct for this test — only the source path lookup is exercised. For reference, simulate_preinstalled_shakapacker in the support helper uses a full fixture with all keys. The difference is fine here since copy_base_files in pretend mode only needs to resolve the source path.

allow(redux_generator).to receive(:gsub_file)
allow(redux_generator).to receive(:prepend_to_file)
allow(File).to receive(:read).and_call_original

expect(File).not_to receive(:read)
expect(File).not_to receive(:read).with(File.join(destination_root, client_entry))
expect(redux_generator).to receive(:say_status)
.with(:pretend, "Would add Tailwind stylesheet import to #{client_entry}", :yellow)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the key correctness fix: and_call_original lets File.read work normally for any path, while the expect(...).not_to receive(:read).with(...) below still catches accidental reads of the specific client entry. Previously the blanket not_to receive(:read) over-specified the test and conflated "shakapacker config reads" (legitimate) with "not-yet-copied client entry reads" (the actual invariant being guarded).

Expand Down
Loading