class Rspec::Shell::Expectations::CallConfiguration

Configuration of a stubbed command

Attributes

command[R]

Public Class Methods

new(config_path, command) click to toggle source
# File lib/rspec/shell/expectations/call_configuration.rb, line 10
def initialize(config_path, command)
  @config_path = config_path
  @configuration = {}
  @command = command
end

Public Instance Methods

set_exitcode(statuscode, args = []) click to toggle source
# File lib/rspec/shell/expectations/call_configuration.rb, line 16
def set_exitcode(statuscode, args = [])
  @configuration[args] ||= {}
  @configuration[args][:statuscode] = statuscode
end
set_output(content, target, args = []) click to toggle source
# File lib/rspec/shell/expectations/call_configuration.rb, line 21
def set_output(content, target, args = [])
  @configuration[args] ||= {}
  @configuration[args][:outputs] ||= []
  @configuration[args][:outputs] << { target: target, content: content }
end
write() click to toggle source
# File lib/rspec/shell/expectations/call_configuration.rb, line 27
def write
  structure = []
  @configuration.each do |args, results|
    call = {
      args: args
    }.merge results
    structure << call
  end

  @config_path.open('w') do |f|
    f.puts structure.to_yaml
  end
end