Class: Spinach::Config
- Inherits:
-
Object
- Object
- Spinach::Config
- Defined in:
- lib/spinach/config.rb
Overview
The config object holds all the runtime configurations needed for spinach to run.
Instance Attribute Summary collapse
-
#config_path ⇒ String
It allows you to set a config file to parse for all the other options to be set.
-
#default_reporter ⇒ Object
writeonly
Sets the attribute default_reporter.
-
#failure_exceptions ⇒ Array<Exception>
The failure exceptions return an array of exceptions to be captured and considered as failures (as opposite of errors).
-
#features_path ⇒ String
The “features path” holds the place where your features will be searched for.
-
#step_definitions_path ⇒ String
The “step definitions path” holds the place where your feature step classes will be searched for.
-
#support_path ⇒ String
The “support path” helds the place where you can put your configuration files.
Instance Method Summary collapse
-
#[](attribute) ⇒ Object
Allows you to read the config object using a hash-like syntax.
-
#[]=(attribute, value) ⇒ Object
Allows you to set config properties using a hash-like syntax.
-
#parse_from_file ⇒ Boolean
Parse options from the config file.
Instance Attribute Details
#config_path ⇒ String
It allows you to set a config file to parse for all the other options to be set
105 106 107 |
# File 'lib/spinach/config.rb', line 105 def config_path @config_path ||= 'config/spinach.yml' end |
#default_reporter=(value) ⇒ Object (writeonly)
Sets the attribute default_reporter
23 24 25 |
# File 'lib/spinach/config.rb', line 23 def default_reporter=(value) @default_reporter = value end |
#failure_exceptions ⇒ Array<Exception>
The failure exceptions return an array of exceptions to be captured and considered as failures (as opposite of errors)
96 97 98 |
# File 'lib/spinach/config.rb', line 96 def failure_exceptions @failure_exceptions ||= [] end |
#features_path ⇒ String
The “features path” holds the place where your features will be searched for. Defaults to ‘features’
33 34 35 |
# File 'lib/spinach/config.rb', line 33 def features_path @features_path || 'features' end |
#step_definitions_path ⇒ String
The “step definitions path” holds the place where your feature step classes will be searched for. Defaults to ‘##features_path/steps’
44 45 46 |
# File 'lib/spinach/config.rb', line 44 def step_definitions_path @step_definitions_path || "#{self.features_path}/steps" end |
#support_path ⇒ String
The “support path” helds the place where you can put your configuration files. Defaults to ‘##features_path/support’
55 56 57 |
# File 'lib/spinach/config.rb', line 55 def support_path @support_path || "#{self.features_path}/support" end |
Instance Method Details
#[](attribute) ⇒ Object
Allows you to read the config object using a hash-like syntax.
69 70 71 |
# File 'lib/spinach/config.rb', line 69 def [](attribute) self.send(attribute) end |
#[]=(attribute, value) ⇒ Object
Allows you to set config properties using a hash-like syntax.
86 87 88 |
# File 'lib/spinach/config.rb', line 86 def []=(attribute, value) self.send("#{attribute}=", value) end |
#parse_from_file ⇒ Boolean
Parse options from the config file
114 115 116 117 118 119 120 121 |
# File 'lib/spinach/config.rb', line 114 def parse_from_file parsed_opts = YAML.load_file(config_path) parsed_opts.delete_if{|k| k.to_s == 'config_path'} parsed_opts.each_pair{|k,v| self[k] = v} true rescue Errno::ENOENT false end |