diff options
author | Kyrylo Silin <silin@kyrylo.org> | 2019-04-15 02:34:44 +0300 |
---|---|---|
committer | Kyrylo Silin <silin@kyrylo.org> | 2019-04-15 02:36:01 +0300 |
commit | f89d0eccacd7f6a20f9ee3ca9b47a5d90e0c06e3 (patch) | |
tree | 5ce380d497ba3fb9558e738203514ad7c28851ae /spec | |
parent | 95d3a74e9b22c44ea48ce870171640f0471db09b (diff) | |
download | pry-f89d0eccacd7f6a20f9ee3ca9b47a5d90e0c06e3.tar.gz |
config: factor out 'system' to SystemCommandHandler
Diffstat (limited to 'spec')
-rw-r--r-- | spec/system_command_handler_spec.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/system_command_handler_spec.rb b/spec/system_command_handler_spec.rb new file mode 100644 index 00000000..810fd606 --- /dev/null +++ b/spec/system_command_handler_spec.rb @@ -0,0 +1,34 @@ +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 |