Class: Cucumber::Configuration
- Inherits:
-
Object
- Object
- Cucumber::Configuration
show all
- Extended by:
- Forwardable
- Includes:
- Constantize
- Defined in:
- lib/cucumber/configuration.rb
Overview
The base class for configuring settings for a Cucumber run.
Class Method Summary
collapse
Instance Method Summary
collapse
#constantize, #underscore
Constructor Details
#initialize(user_options = {}) ⇒ Configuration
Returns a new instance of Configuration.
35
36
37
|
# File 'lib/cucumber/configuration.rb', line 35
def initialize(user_options = {})
@options = default_options.merge(Hash(user_options))
end
|
Class Method Details
.default ⇒ Object
16
17
18
|
# File 'lib/cucumber/configuration.rb', line 16
def self.default
new
end
|
Instance Method Details
#all_files_to_load ⇒ Object
175
176
177
178
179
180
181
182
183
184
185
186
|
# File 'lib/cucumber/configuration.rb', line 175
def all_files_to_load
files = require_dirs.map do |path|
path = path.tr('\\', '/') path = path.gsub(/\/$/, '') File.directory?(path) ? Dir["#{path}/**/*"] : path
end.flatten.uniq
remove_excluded_files_from(files)
files.reject! {|f| !File.file?(f)}
files.reject! {|f| File.extname(f) == '.feature' }
files.reject! {|f| f =~ /^http/}
files.sort
end
|
#autoload_code_paths ⇒ Object
119
120
121
|
# File 'lib/cucumber/configuration.rb', line 119
def autoload_code_paths
@options[:autoload_code_paths]
end
|
#custom_profiles ⇒ Object
107
108
109
|
# File 'lib/cucumber/configuration.rb', line 107
def custom_profiles
profiles - [@options[:default_profile]]
end
|
#dry_run? ⇒ Boolean
59
60
61
|
# File 'lib/cucumber/configuration.rb', line 59
def dry_run?
@options[:dry_run]
end
|
#duration? ⇒ Boolean
91
92
93
|
# File 'lib/cucumber/configuration.rb', line 91
def duration?
@options[:duration]
end
|
#error_stream ⇒ Object
47
48
49
|
# File 'lib/cucumber/configuration.rb', line 47
def error_stream
@options[:error_stream]
end
|
#event_bus ⇒ Object
237
238
239
|
# File 'lib/cucumber/configuration.rb', line 237
def event_bus
@options[:event_bus]
end
|
#expand? ⇒ Boolean
83
84
85
|
# File 'lib/cucumber/configuration.rb', line 83
def expand?
@options[:expand]
end
|
#fail_fast? ⇒ Boolean
63
64
65
|
# File 'lib/cucumber/configuration.rb', line 63
def fail_fast?
@options[:fail_fast]
end
|
#feature_dirs ⇒ Object
127
128
129
130
131
|
# File 'lib/cucumber/configuration.rb', line 127
def feature_dirs
dirs = paths.map { |f| File.directory?(f) ? f : File.dirname(f) }.uniq
dirs.delete('.') unless paths.include?('.')
with_default_features_path(dirs)
end
|
#feature_files ⇒ Object
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
# File 'lib/cucumber/configuration.rb', line 149
def feature_files
potential_feature_files = with_default_features_path(paths).map do |path|
path = path.tr('\\', '/') path = path.chomp('/')
if File.directory?(path)
Dir["#{path}/**/*.feature"].sort
elsif Cli::RerunFile.can_read?(path)
Cli::RerunFile.new(path).features
else
path
end
end.flatten.uniq
remove_excluded_files_from(potential_feature_files)
potential_feature_files
end
|
#filters ⇒ Object
145
146
147
|
# File 'lib/cucumber/configuration.rb', line 145
def filters
@options[:filters]
end
|
115
116
117
|
# File 'lib/cucumber/configuration.rb', line 115
def formats
@options[:formats]
end
|
206
207
208
209
210
211
212
|
# File 'lib/cucumber/configuration.rb', line 206
def formatter_class(format)
if (builtin = Cli::Options::BUILTIN_FORMATS[format])
constantize(builtin[0])
else
constantize(format)
end
end
|
192
193
194
195
196
197
198
199
200
201
202
203
204
|
# File 'lib/cucumber/configuration.rb', line 192
def formatter_factories
formats.map do |format, formatter_options, path_or_io|
begin
factory = formatter_class(format)
yield factory,
formatter_options,
path_or_io,
Cli::Options.new(STDOUT, STDERR, @options)
rescue Exception => e
raise e, "#{e.message}\nError creating formatter: #{format}", e.backtrace
end
end
end
|
#guess? ⇒ Boolean
71
72
73
|
# File 'lib/cucumber/configuration.rb', line 71
def guess?
@options[:guess]
end
|
#name_regexps ⇒ Object
141
142
143
|
# File 'lib/cucumber/configuration.rb', line 141
def name_regexps
@options[:name_regexps]
end
|
#on_event {|Object| ... } ⇒ Object
Subscribe to an event.
See Events for the list of possible events.
28
|
# File 'lib/cucumber/configuration.rb', line 28
def_instance_delegator :event_bus, :on, :on_event
|
#out_stream ⇒ Object
43
44
45
|
# File 'lib/cucumber/configuration.rb', line 43
def out_stream
@options[:out_stream]
end
|
#paths ⇒ Object
111
112
113
|
# File 'lib/cucumber/configuration.rb', line 111
def paths
@options[:paths]
end
|
#profiles ⇒ Object
103
104
105
|
# File 'lib/cucumber/configuration.rb', line 103
def profiles
@options[:profiles] || []
end
|
#randomize? ⇒ Boolean
51
52
53
|
# File 'lib/cucumber/configuration.rb', line 51
def randomize?
@options[:order] == 'random'
end
|
#register_snippet_generator(generator) ⇒ Object
232
233
234
235
|
# File 'lib/cucumber/configuration.rb', line 232
def register_snippet_generator(generator)
snippet_generators << generator
self
end
|
#retry_attempts ⇒ Object
67
68
69
|
# File 'lib/cucumber/configuration.rb', line 67
def retry_attempts
@options[:retry]
end
|
#seed ⇒ Object
55
56
57
|
# File 'lib/cucumber/configuration.rb', line 55
def seed
Integer(@options[:seed] || rand(0xFFFF))
end
|
99
100
101
|
# File 'lib/cucumber/configuration.rb', line 99
def skip_profile_information?
@options[:skip_profile_information]
end
|
#snippet_generators ⇒ Object
An array of procs that can generate snippets for undefined steps. These procs may be called if a formatter wants to display snippets to the user.
Each proc should take the following arguments:
- keyword
- step text
- multiline argument
- snippet type
228
229
230
|
# File 'lib/cucumber/configuration.rb', line 228
def snippet_generators
@options[:snippet_generators] ||= []
end
|
#snippet_type ⇒ Object
123
124
125
|
# File 'lib/cucumber/configuration.rb', line 123
def snippet_type
@options[:snippet_type]
end
|
#snippets? ⇒ Boolean
95
96
97
|
# File 'lib/cucumber/configuration.rb', line 95
def snippets?
@options[:snippets]
end
|
#source? ⇒ Boolean
87
88
89
|
# File 'lib/cucumber/configuration.rb', line 87
def source?
@options[:source]
end
|
#step_defs_to_load ⇒ Object
188
189
190
|
# File 'lib/cucumber/configuration.rb', line 188
def step_defs_to_load
all_files_to_load.reject {|f| f =~ %r{/support/} }
end
|
#strict ⇒ Object
75
76
77
|
# File 'lib/cucumber/configuration.rb', line 75
def strict
@options[:strict]
end
|
#support_to_load ⇒ Object
168
169
170
171
172
173
|
# File 'lib/cucumber/configuration.rb', line 168
def support_to_load
support_files = all_files_to_load.select {|f| f =~ %r{/support/} }
env_files = support_files.select {|f| f =~ %r{/support/env\..*} }
other_files = support_files - env_files
@options[:dry_run] ? other_files : env_files + other_files
end
|
#tag_expressions ⇒ Object
137
138
139
|
# File 'lib/cucumber/configuration.rb', line 137
def tag_expressions
@options[:tag_expressions]
end
|
#tag_limits ⇒ Object
133
134
135
|
# File 'lib/cucumber/configuration.rb', line 133
def tag_limits
@options[:tag_limits]
end
|
#to_hash ⇒ Object
214
215
216
|
# File 'lib/cucumber/configuration.rb', line 214
def to_hash
@options
end
|
#wip? ⇒ Boolean
79
80
81
|
# File 'lib/cucumber/configuration.rb', line 79
def wip?
@options[:wip]
end
|
#with_options(new_options) ⇒ Object
39
40
41
|
# File 'lib/cucumber/configuration.rb', line 39
def with_options(new_options)
self.class.new(@options.merge(new_options))
end
|