Class: ShellMock::BacktickMonkeyPatch

Inherits:
MonkeyPatch show all
Defined in:
lib/shell_mock/backtick_monkey_patch.rb

Instance Method Summary collapse

Methods inherited from MonkeyPatch

#disable, #enable

Instance Method Details

#interpolatable_nameObject



11
12
13
# File 'lib/shell_mock/backtick_monkey_patch.rb', line 11

def interpolatable_name
  :backtick
end

#method_nameObject



7
8
9
# File 'lib/shell_mock/backtick_monkey_patch.rb', line 7

def method_name
  "`"
end

#override(command) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/shell_mock/backtick_monkey_patch.rb', line 15

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

  if stub
    stub.called_with({}, command, {})

    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