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.
- #generate ⇒ Object
-
#reporter_class ⇒ reporter object
The “reporter class” holds the reporter class name Default to Spinach::Reporter::Stdout.
-
#reporter_options ⇒ Object
The “reporter_options” holds the options of reporter_class.
-
#save_and_open_page_on_failure ⇒ Object
When using capybara, it automatically shows the current page when there’s a failure.
-
#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.
-
#tags ⇒ Array
Tags to tell Spinach that you only want to run scenarios that have (or don’t have) certain tags.
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
139 140 141 |
# File 'lib/spinach/config.rb', line 139 def config_path @config_path ||= 'config/spinach.yml' end |
#default_reporter=(value) ⇒ Object (writeonly)
Sets the attribute default_reporter
25 26 27 |
# File 'lib/spinach/config.rb', line 25 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)
130 131 132 |
# File 'lib/spinach/config.rb', line 130 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’
45 46 47 |
# File 'lib/spinach/config.rb', line 45 def features_path @features_path || 'features' end |
#generate ⇒ Object
89 90 91 |
# File 'lib/spinach/config.rb', line 89 def generate @generate || false end |
#reporter_class ⇒ reporter object
The “reporter class” holds the reporter class name Default to Spinach::Reporter::Stdout
56 57 58 |
# File 'lib/spinach/config.rb', line 56 def reporter_class @reporter_class || "Spinach::Reporter::Stdout" end |
#reporter_options ⇒ Object
The “reporter_options” holds the options of reporter_class
63 64 65 |
# File 'lib/spinach/config.rb', line 63 def @reporter_options || {} end |
#save_and_open_page_on_failure ⇒ Object
When using capybara, it automatically shows the current page when there’s a failure
146 147 148 |
# File 'lib/spinach/config.rb', line 146 def save_and_open_page_on_failure @save_and_open_page_on_failure ||= false 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’
74 75 76 |
# File 'lib/spinach/config.rb', line 74 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’
85 86 87 |
# File 'lib/spinach/config.rb', line 85 def support_path @support_path || "#{self.features_path}/support" end |
#tags ⇒ Array
Tags to tell Spinach that you only want to run scenarios that have (or don’t have) certain tags.
156 157 158 |
# File 'lib/spinach/config.rb', line 156 def @tags ||= [] end |
Instance Method Details
#[](attribute) ⇒ Object
Allows you to read the config object using a hash-like syntax.
103 104 105 |
# File 'lib/spinach/config.rb', line 103 def [](attribute) self.send(attribute) end |
#[]=(attribute, value) ⇒ Object
Allows you to set config properties using a hash-like syntax.
120 121 122 |
# File 'lib/spinach/config.rb', line 120 def []=(attribute, value) self.send("#{attribute}=", value) end |
#parse_from_file ⇒ Boolean
Parse options from the config file
165 166 167 168 169 170 171 172 |
# File 'lib/spinach/config.rb', line 165 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 |