Class: Spinach::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/spinach/config.rb

Overview

The config object holds all the runtime configurations needed for spinach to run.

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Instance Attribute Details

- (String) config_path

It allows you to set a config file to parse for all the other options to be set



151
152
153
# File 'lib/spinach/config.rb', line 151

def config_path
  @config_path ||= 'config/spinach.yml'
end

- (Object) default_reporter=(value) (writeonly)

Sets the attribute default_reporter



25
26
27
# File 'lib/spinach/config.rb', line 25

def default_reporter=(value)
  @default_reporter = value
end

- (true/false) fail_fast

The “fail_fast” determines if the suite run should exit when encountering a failure/error



142
143
144
# File 'lib/spinach/config.rb', line 142

def fail_fast
  @fail_fast
end

- (Array<Exception>) failure_exceptions

The failure exceptions return an array of exceptions to be captured and considered as failures (as opposite of errors)



131
132
133
# File 'lib/spinach/config.rb', line 131

def failure_exceptions
  @failure_exceptions ||= []
end

- (String) features_path

The “features path” holds the place where your features will be searched for. Defaults to 'features'



46
47
48
# File 'lib/spinach/config.rb', line 46

def features_path
  @features_path || 'features'
end

- (Object) generate



90
91
92
# File 'lib/spinach/config.rb', line 90

def generate
  @generate || false
end

- (reporter object) reporter_class

The “reporter class” holds the reporter class name Default to Spinach::Reporter::Stdout



57
58
59
# File 'lib/spinach/config.rb', line 57

def reporter_class
  @reporter_class || "Spinach::Reporter::Stdout"
end

- (Object) reporter_options

The “reporter_options” holds the options of reporter_class



64
65
66
# File 'lib/spinach/config.rb', line 64

def reporter_options
  @reporter_options || {}
end

- (Object) save_and_open_page_on_failure

When using capybara, it automatically shows the current page when there's a failure



158
159
160
# File 'lib/spinach/config.rb', line 158

def save_and_open_page_on_failure
  @save_and_open_page_on_failure ||= false
end

- (String) step_definitions_path

The “step definitions path” holds the place where your feature step classes will be searched for. Defaults to '#features_path/steps'



75
76
77
# File 'lib/spinach/config.rb', line 75

def step_definitions_path
  @step_definitions_path || "#{self.features_path}/steps"
end

- (String) support_path

The “support path” helds the place where you can put your configuration files. Defaults to '#features_path/support'



86
87
88
# File 'lib/spinach/config.rb', line 86

def support_path
  @support_path || "#{self.features_path}/support"
end

- (Array) tags

Tags to tell Spinach that you only want to run scenarios that have (or don't have) certain tags.



168
169
170
# File 'lib/spinach/config.rb', line 168

def tags
  @tags ||= []
end

Instance Method Details

- (Object) [](attribute)

Allows you to read the config object using a hash-like syntax.

Examples:

Spinach.config[:step_definitions_path]
# => 'features/steps'


104
105
106
# File 'lib/spinach/config.rb', line 104

def [](attribute)
  self.send(attribute)
end

- (Object) []=(attribute, value)

Allows you to set config properties using a hash-like syntax.

Examples:

Spinach.config[:step_definitions_path] = 'integration/steps'
  # => 'integration/steps'


121
122
123
# File 'lib/spinach/config.rb', line 121

def []=(attribute, value)
  self.send("#{attribute}=", value)
end

- (Boolean) parse_from_file

Parse options from the config file



177
178
179
180
181
182
183
184
# File 'lib/spinach/config.rb', line 177

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