class Cucumber::Configuration
The base class for configuring settings for a Cucumber run.
def self.default
def self.default new end
def all_files_to_load
def all_files_to_load files = require_dirs.map do |path| path = path.tr('\\', '/') # In case we're on windows. Globs don't work with backslashes. path = path.gsub(/\/$/, '') # Strip trailing slash. File.directory?(path) ? Dir["#{path}/**/*"] : path end.flatten.uniq remove_excluded_files_from(files) files.select! { |f| File.file?(f) } files.reject! { |f| File.extname(f) == '.feature' } files.reject! { |f| f =~ /^http/ } files.sort end
def autoload_code_paths
def autoload_code_paths @options[:autoload_code_paths] end
def custom_profiles
def custom_profiles profiles - [@options[:default_profile]] end
def default_features_paths
def default_features_paths ['features'] end
def default_options
def default_options { autoload_code_paths: ['features/support', 'features/step_definitions'], filters: [], strict: Cucumber::Core::Test::Result::StrictConfiguration.new, require: [], dry_run: false, publish_quiet: false, fail_fast: false, formats: [], excludes: [], tag_expressions: [], name_regexps: [], env_vars: {}, diff_enabled: true, snippets: true, source: true, duration: true, event_bus: Cucumber::Events.make_event_bus, retry_total: Float::INFINITY } end
def dry_run?
def dry_run? @options[:dry_run] end
def duration?
def duration? @options[:duration] end
def error_stream
def error_stream @options[:error_stream] end
def event_bus
def event_bus @options[:event_bus] end
def expand?
def expand? @options[:expand] end
def fail_fast?
def fail_fast? @options[:fail_fast] end
def feature_dirs
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
def feature_files
def feature_files potential_feature_files = with_default_features_path(paths).map do |path| path = path.tr('\\', '/') # In case we're on windows. Globs don't work with backslashes. path = path.chomp('/') # TODO: Move to using feature loading strategies stored in # options[:feature_loaders] 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
def filters
def filters @options[:filters] end
def formats
def formats @options[:formats] end
def formatter_class(format)
def formatter_class(format) if (builtin = Cli::Options::BUILTIN_FORMATS[format]) constantize(builtin[0]) else constantize(format) end end
def formatter_factories
def formatter_factories formats.map do |format, formatter_options, path_or_io| factory = formatter_class(format) yield factory, formatter_options, path_or_io rescue Exception => e raise e, "#{e.message}\nError creating formatter: #{format}", e.backtrace end end
def guess?
def guess? @options[:guess] end
def id_generator
def id_generator @id_generator ||= Cucumber::Messages::Helpers::IdGenerator::UUID.new end
def initialize(user_options = {})
def initialize(user_options = {}) @options = default_options.merge(Hash(user_options)) end
def name_regexps
def name_regexps @options[:name_regexps] end
def notify(message, *args)
- Private: -
def notify(message, *args) event_bus.send(message, *args) end
def out_stream
def out_stream @options[:out_stream] end
def paths
def paths @options[:paths] end
def profiles
def profiles @options[:profiles] || [] end
def publish_enabled?
def publish_enabled? @options[:publish_enabled] end
def publish_quiet?
def publish_quiet? @options[:publish_quiet] end
def randomize?
def randomize? @options[:order] == 'random' end
def register_snippet_generator(generator)
def register_snippet_generator(generator) snippet_generators << generator self end
def remove_excluded_files_from(files)
def remove_excluded_files_from(files) files.reject! { |path| @options[:excludes].detect { |pattern| path =~ pattern } } end
def require_dirs
def require_dirs if @options[:require].empty? default_features_paths + Dir['vendor/{gems,plugins}/*/cucumber'] else @options[:require] end end
def retry_attempts
def retry_attempts @options[:retry] end
def retry_total_tests
def retry_total_tests @options[:retry_total] end
def seed
def seed @options[:seed] end
def skip_profile_information?
def skip_profile_information? @options[:skip_profile_information] end
def snippet_generators
- snippet type
- multiline argument
- step text
- keyword
Each proc should take the following arguments:
formatter wants to display snippets to the user.
An array of procs that can generate snippets for undefined steps. These procs may be called if a
def snippet_generators @options[:snippet_generators] ||= [] end
def snippet_type
def snippet_type @options[:snippet_type] end
def snippets?
def snippets? @options[:snippets] end
def source?
def source? @options[:source] end
def step_defs_to_load
def step_defs_to_load all_files_to_load.reject { |f| f =~ /\/support\// } end
def strict
def strict @options[:strict] end
def support_to_load
def support_to_load support_files = all_files_to_load.select { |f| f =~ /\/support\// } # env_files are separated from other_files so we can ensure env files # load first. # env_files = support_files.select { |f| f =~ /\/support\/env\..*/ } other_files = support_files - env_files env_files.reverse + other_files.reverse end
def tag_expressions
def tag_expressions @options[:tag_expressions] end
def tag_limits
def tag_limits @options[:tag_limits] end
def to_hash
def to_hash @options end
def wip?
def wip? @options[:wip] end
def with_default_features_path(paths)
def with_default_features_path(paths) return default_features_paths if paths.empty? paths end
def with_options(new_options)
def with_options(new_options) self.class.new(@options.merge(new_options)) end