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 Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
Instance Method Summary collapse
-
#initialize(config_path, command) ⇒ 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, command) ⇒ CallConfiguration
10 11 12 13 14 |
# File 'lib/rspec/shell/expectations/call_configuration.rb', line 10 def initialize(config_path, command) @config_path = config_path @configuration = {} @command = command end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
8 9 10 |
# File 'lib/rspec/shell/expectations/call_configuration.rb', line 8 def command @command end |
Instance Method Details
#set_exitcode(statuscode, args = []) ⇒ Object
16 17 18 19 |
# 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 = []) ⇒ Object
21 22 23 24 25 |
# 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 ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# 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 |