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
-
#audit ⇒ true/false
“audit” enables step auditing mode.
-
#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.
-
#fail_fast ⇒ true/false
The “fail_fast” determines if the suite run should exit when encountering a failure/error.
-
#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
-
#orderer_class ⇒ orderer object
The “orderer class” holds the orderer class name Defaults to Spinach::Orderers::Default.
-
#reporter_classes ⇒ Array<reporter object>
The “reporter classes” holds an array of reporter class name Default to [“Spinach::Reporter::Stdout”].
-
#reporter_options ⇒ Object
The “reporter_options” holds the options passed to reporter_classes.
-
#save_and_open_page_on_failure ⇒ Object
When using capybara, it automatically shows the current page when there’s a failure.
-
#seed ⇒ Object
A randomization seed.
-
#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
#audit ⇒ true/false
“audit” enables step auditing mode
178 179 180 |
# File 'lib/spinach/config.rb', line 178 def audit @audit || false end |
#config_path ⇒ String
It allows you to set a config file to parse for all the other options to be set
187 188 189 |
# File 'lib/spinach/config.rb', line 187 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 |
#fail_fast ⇒ true/false
The “fail_fast” determines if the suite run should exit when encountering a failure/error
168 169 170 |
# File 'lib/spinach/config.rb', line 168 def fail_fast @fail_fast end |
#failure_exceptions ⇒ Array<Exception>
The failure exceptions return an array of exceptions to be captured and considered as failures (as opposite of errors)
157 158 159 |
# File 'lib/spinach/config.rb', line 157 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’
49 50 51 |
# File 'lib/spinach/config.rb', line 49 def features_path @features_path || 'features' end |
#generate ⇒ Object
116 117 118 |
# File 'lib/spinach/config.rb', line 116 def generate @generate || false end |
#orderer_class ⇒ orderer object
The “orderer class” holds the orderer class name Defaults to Spinach::Orderers::Default
78 79 80 |
# File 'lib/spinach/config.rb', line 78 def orderer_class @orderer_class || "Spinach::Orderers::Default" end |
#reporter_classes ⇒ Array<reporter object>
The “reporter classes” holds an array of reporter class name Default to [“Spinach::Reporter::Stdout”]
60 61 62 |
# File 'lib/spinach/config.rb', line 60 def reporter_classes @reporter_classes || ["Spinach::Reporter::Stdout"] end |
#reporter_options ⇒ Object
The “reporter_options” holds the options passed to reporter_classes
67 68 69 |
# File 'lib/spinach/config.rb', line 67 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
194 195 196 |
# File 'lib/spinach/config.rb', line 194 def save_and_open_page_on_failure @save_and_open_page_on_failure ||= false end |
#seed ⇒ Object
A randomization seed. This is what spinach uses for test run randomization, so if you call ‘Kernel.srand(Spinach.config.seed)` in your support environment file, not only will the test run order be guaranteed to be stable under a specific seed, all the Ruby-generated random numbers produced during your test run will also be stable under that seed.
90 91 92 |
# File 'lib/spinach/config.rb', line 90 def seed @seed ||= rand(0xFFFF) 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’
101 102 103 |
# File 'lib/spinach/config.rb', line 101 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’
112 113 114 |
# File 'lib/spinach/config.rb', line 112 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.
204 205 206 |
# File 'lib/spinach/config.rb', line 204 def @tags ||= [] end |
Instance Method Details
#[](attribute) ⇒ Object
Allows you to read the config object using a hash-like syntax.
130 131 132 |
# File 'lib/spinach/config.rb', line 130 def [](attribute) self.send(attribute) end |
#[]=(attribute, value) ⇒ Object
Allows you to set config properties using a hash-like syntax.
147 148 149 |
# File 'lib/spinach/config.rb', line 147 def []=(attribute, value) self.send("#{attribute}=", value) end |
#parse_from_file ⇒ Boolean
Parse options from the config file
213 214 215 216 217 218 219 220 |
# File 'lib/spinach/config.rb', line 213 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 |