Sha256: eca5a791ac52b1ef2156071c52ec37f0bcf6c3214253899d7c67d66b791bbe82

Contents?: true

Size: 662 Bytes

Versions: 4

Compression:

Stored size: 662 Bytes

Contents

require 'shell_mock/monkey_patch'
require 'shell_mock/stub_registry'
require 'shell_mock/no_stub_specified'

module ShellMock
  class BacktickMonkeyPatch < MonkeyPatch
    def method_name
      "`"
    end

    def interpolatable_name
      :backtick
    end

    def override(command)
      stub = StubRegistry.stub_matching({}, command, {})

      if stub
        stub.ran

        stub.side_effect.call

        __un_shell_mocked_backtick(stub.to_oneliner)
      else
        if ShellMock.let_commands_run?
          __un_shell_mocked_backtick(command)
        else
          raise NoStubSpecified.new({}, command, {})
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
shell_mock-0.7.2 lib/shell_mock/backtick_monkey_patch.rb
shell_mock-0.7.1 lib/shell_mock/backtick_monkey_patch.rb
shell_mock-0.7.0 lib/shell_mock/backtick_monkey_patch.rb
shell_mock-0.6.0 lib/shell_mock/backtick_monkey_patch.rb