mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
36 lines
1,011 B
Ruby
36 lines
1,011 B
Ruby
# frozen_string_literal: true
|
|
|
|
require 'stringio'
|
|
|
|
RSpec.describe Pry::SystemCommandHandler do
|
|
describe ".default" do
|
|
let(:output) { StringIO.new }
|
|
let(:pry_instance) { Pry.new }
|
|
|
|
before { allow(Kernel).to receive(:system) }
|
|
|
|
context "when command exists" do
|
|
before do
|
|
expect(Kernel).to receive(:system).with('test-command').and_return(true)
|
|
end
|
|
|
|
it "executes the command without printing the warning" do
|
|
described_class.default(output, 'test-command', pry_instance)
|
|
expect(output.string).to be_empty
|
|
end
|
|
end
|
|
|
|
context "when doesn't exist" do
|
|
before do
|
|
allow(Kernel).to receive(:system).with('test-command').and_return(nil)
|
|
end
|
|
|
|
it "executes the command without printing the warning" do
|
|
described_class.default(output, 'test-command', pry_instance)
|
|
expect(output.string).to eq(
|
|
"Error: there was a problem executing system command: test-command\n"
|
|
)
|
|
end
|
|
end
|
|
end
|
|
end
|