Class: Rspec::Shell::Expectations::CallConfiguration
- Inherits:
-
Object
- Object
- Rspec::Shell::Expectations::CallConfiguration
- Defined in:
- lib/rspec/shell/expectations/call_configuration.rb
Overview
Configuration of a stubbed command
Instance Method Summary collapse
-
#initialize(config_path) ⇒ CallConfiguration
constructor
A new instance of CallConfiguration.
- #set_exitcode(statuscode, args = []) ⇒ Object
- #set_output(content, target, args = []) ⇒ Object
- #write ⇒ Object
Constructor Details
#initialize(config_path) ⇒ CallConfiguration
Returns a new instance of CallConfiguration.
8 9 10 11 |
# File 'lib/rspec/shell/expectations/call_configuration.rb', line 8 def initialize(config_path) @config_path = config_path @configuration = {} end |
Instance Method Details
#set_exitcode(statuscode, args = []) ⇒ Object
13 14 15 16 |
# File 'lib/rspec/shell/expectations/call_configuration.rb', line 13 def set_exitcode(statuscode, args = []) @configuration[args] ||= {} @configuration[args][:statuscode] = statuscode end |
#set_output(content, target, args = []) ⇒ Object
18 19 20 21 22 |
# File 'lib/rspec/shell/expectations/call_configuration.rb', line 18 def set_output(content, target, args = []) @configuration[args] ||= {} @configuration[args][:outputs] ||= [] @configuration[args][:outputs] << { target: target, content: content } end |
#write ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/rspec/shell/expectations/call_configuration.rb', line 24 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 |