Class: Rspec::Shell::Expectations::StubbedCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/shell/expectations/stubbed_command.rb

Overview

Command that produces specific output and monitors input

Instance Method Summary collapse

Constructor Details

#initialize(command, dir) ⇒ StubbedCommand

Returns a new instance of StubbedCommand.



7
8
9
10
11
12
13
14
15
16
# File 'lib/rspec/shell/expectations/stubbed_command.rb', line 7

def initialize(command, dir)
  @dir, @command = dir, command
  FileUtils.cp(stub_filepath, File.join(dir, command))
  @call_configuration = CallConfiguration.new(
    Pathname.new(dir).join("#{command}_stub.yml")
  )
  @call_log = CallLog.new(
    Pathname.new(dir).join("#{command}_calls.yml")
  )
end

Instance Method Details

#called?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/rspec/shell/expectations/stubbed_command.rb', line 22

def called?
  with_args.called?
end

#called_with_args?(*args) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/rspec/shell/expectations/stubbed_command.rb', line 26

def called_with_args?(*args)
  with_args.called_with_args?(*args)
end

#outputs(contents, to: :stdout) ⇒ Object



38
39
40
# File 'lib/rspec/shell/expectations/stubbed_command.rb', line 38

def outputs(contents, to: :stdout)
  with_args.outputs(contents, to: to)
end

#returns_exitstatus(statuscode) ⇒ Object



30
31
32
# File 'lib/rspec/shell/expectations/stubbed_command.rb', line 30

def returns_exitstatus(statuscode)
  with_args.returns_exitstatus(statuscode)
end

#stdinObject



34
35
36
# File 'lib/rspec/shell/expectations/stubbed_command.rb', line 34

def stdin
  with_args.stdin
end

#with_args(*args) ⇒ Object



18
19
20
# File 'lib/rspec/shell/expectations/stubbed_command.rb', line 18

def with_args(*args)
  StubbedCall.new(@call_configuration, @call_log, args)
end