Class: Rspec::Bash::CallConfiguration
- Inherits:
-
Object
- Object
- Rspec::Bash::CallConfiguration
- Defined in:
- lib/rspec/bash/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
Returns a new instance of CallConfiguration.
9 10 11 12 13 |
# File 'lib/rspec/bash/call_configuration.rb', line 9 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.
7 8 9 |
# File 'lib/rspec/bash/call_configuration.rb', line 7 def command @command end |
Instance Method Details
#set_exitcode(statuscode, args = []) ⇒ Object
15 16 17 18 |
# File 'lib/rspec/bash/call_configuration.rb', line 15 def set_exitcode(statuscode, args = []) @configuration[args] ||= {} @configuration[args][:statuscode] = statuscode end |
#set_output(content, target, args = []) ⇒ Object
20 21 22 23 24 |
# File 'lib/rspec/bash/call_configuration.rb', line 20 def set_output(content, target, args = []) @configuration[args] ||= {} @configuration[args][:outputs] ||= [] @configuration[args][:outputs] << { target: target, content: content } end |
#write ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/rspec/bash/call_configuration.rb', line 26 def write structure = @configuration.map do |args, results| { args: args }.merge results end @config_path.open('w') do |f| f.puts structure.to_yaml end end |