diff options
author | Kyrylo Silin <silin@kyrylo.org> | 2019-04-14 13:27:25 +0300 |
---|---|---|
committer | Kyrylo Silin <silin@kyrylo.org> | 2019-04-14 13:27:25 +0300 |
commit | 5c3253339cee785ec04c4f4dc8b4fea889e969c6 (patch) | |
tree | 1f32d284af270cc1dbde4cfa2335ce9dae125e8e /spec | |
parent | acf213773d6d6c589e3f97b78a0b04fa07eb249a (diff) | |
download | pry-5c3253339cee785ec04c4f4dc8b4fea889e969c6.tar.gz |
config: factor out default hook definition to Pry::Hooks
Diffstat (limited to 'spec')
-rw-r--r-- | spec/hooks_spec.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/spec/hooks_spec.rb b/spec/hooks_spec.rb index dd0f7d60..5ee30b80 100644 --- a/spec/hooks_spec.rb +++ b/spec/hooks_spec.rb @@ -3,6 +3,34 @@ describe Pry::Hooks do @hooks = Pry::Hooks.new end + describe ".default" do + it "returns hooks with default before_session hook" do + hooks = described_class.default + expect(hooks.hook_exists?('before_session', :default)).to be_truthy + end + + context "when pry instance is quiet" do + let(:pry_instance) { Pry.new(quiet: true) } + + it "doesn't run the whereami command" do + expect(pry_instance).not_to receive(:run_command) + hooks = described_class.default + hooks.exec_hook(:before_session, StringIO.new, {}, pry_instance) + end + end + + context "when pry instance is not quiet" do + let(:pry_instance) { Pry.new(quiet: false) } + let(:output) { StringIO.new } + + it "runs the whereami command" do + expect(pry_instance).to receive(:run_command).with('whereami --quiet') + hooks = described_class.default + hooks.exec_hook(:before_session, StringIO.new, {}, pry_instance) + end + end + end + describe "adding a new hook" do it 'should not execute hook while adding it' do run = false |