Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions lib/react_on_rails/dev/pack_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

require "English"
require "stringio"
require_relative "../packer_utils"

module ReactOnRails
module Dev
Expand Down
1 change: 1 addition & 0 deletions lib/react_on_rails/dev/server_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require "English"
require "open3"
require "rainbow"
require_relative "../packer_utils"

module ReactOnRails
module Dev
Expand Down
25 changes: 25 additions & 0 deletions spec/react_on_rails/binstubs/dev_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

RSpec.describe "bin/dev script" do
let(:script_path) { "lib/generators/react_on_rails/templates/base/base/bin/dev" }
let(:dummy_dev_path) { "spec/dummy/bin/dev" }

# To suppress stdout during tests
original_stderr = $stderr
Expand Down Expand Up @@ -58,4 +59,28 @@ def setup_script_execution_for_tool_tests

load script_path
end

# Integration test: verify bin/dev can load without NameError
describe "integration test" do
it "spec/dummy/bin/dev can load the template script without errors" do
# This test verifies that all required dependencies are properly loaded
# when bin/dev is executed, catching issues like missing require statements
expect(File.exist?(dummy_dev_path)).to be true
expect(File.exist?(script_path)).to be true

# Verify the dummy script references the template
dummy_content = File.read(dummy_dev_path)
expect(dummy_content).to include(script_path)
end

it "can require react_on_rails/dev and access all necessary modules" do
# This catches missing require statements in pack_generator.rb and other files
# If PackerUtils isn't required, this would fail with NameError
require "react_on_rails/dev"

expect { ReactOnRails::Dev::ServerManager }.not_to raise_error
expect { ReactOnRails::Dev::PackGenerator }.not_to raise_error
expect { ReactOnRails::PackerUtils }.not_to raise_error
end
end
end
9 changes: 9 additions & 0 deletions spec/react_on_rails/dev/pack_generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@
require "react_on_rails/dev/pack_generator"

RSpec.describe ReactOnRails::Dev::PackGenerator do
# Integration test: verify PackerUtils is properly required
describe "module dependencies" do
it "can access ReactOnRails::PackerUtils without errors" do
# This test ensures the require statement is present in pack_generator.rb
# If the require is missing, this will raise NameError: uninitialized constant
expect { ReactOnRails::PackerUtils }.not_to raise_error
end
end

describe ".generate" do
context "when shakapacker precompile hook is configured" do
before do
Expand Down
Loading