Skip to content
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
7 changes: 5 additions & 2 deletions lib/react_on_rails/dev/pack_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,12 @@ def handle_rake_error(error, _silent)

def run_via_bundle_exec(silent: false)
if silent
system "bundle exec rake react_on_rails:generate_packs > /dev/null 2>&1"
system(
"bundle", "exec", "rake", "react_on_rails:generate_packs",
out: File::NULL, err: File::NULL
)
else
system "bundle exec rake react_on_rails:generate_packs"
system("bundle", "exec", "rake", "react_on_rails:generate_packs")
end
end
end
Expand Down
15 changes: 9 additions & 6 deletions spec/react_on_rails/dev/pack_generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,27 @@
RSpec.describe ReactOnRails::Dev::PackGenerator do
describe ".generate" do
it "runs pack generation successfully in verbose mode" do
command = "bundle exec rake react_on_rails:generate_packs"
allow(described_class).to receive(:system).with(command).and_return(true)
allow(described_class).to receive(:system)
.with("bundle", "exec", "rake", "react_on_rails:generate_packs")
.and_return(true)

expect { described_class.generate(verbose: true) }
.to output(/📦 Generating React on Rails packs.../).to_stdout_from_any_process
end

it "runs pack generation successfully in quiet mode" do
command = "bundle exec rake react_on_rails:generate_packs > /dev/null 2>&1"
allow(described_class).to receive(:system).with(command).and_return(true)
allow(described_class).to receive(:system)
.with("bundle", "exec", "rake", "react_on_rails:generate_packs", out: File::NULL, err: File::NULL)
.and_return(true)

expect { described_class.generate(verbose: false) }
.to output(/📦 Generating packs\.\.\. ✅/).to_stdout_from_any_process
end

it "exits with error when pack generation fails" do
command = "bundle exec rake react_on_rails:generate_packs > /dev/null 2>&1"
allow(described_class).to receive(:system).with(command).and_return(false)
allow(described_class).to receive(:system)
.with("bundle", "exec", "rake", "react_on_rails:generate_packs", out: File::NULL, err: File::NULL)
.and_return(false)

expect { described_class.generate(verbose: false) }.to raise_error(SystemExit)
end
Expand Down
Loading