lib/cucumber/configuration.rb in cucumber-3.0.0.pre.1 vs lib/cucumber/configuration.rb in cucumber-3.0.0.pre.2

- old
+ new

@@ -2,11 +2,10 @@ require 'cucumber/constantize' require 'cucumber/cli/rerun_file' require 'cucumber/events' require 'cucumber/core/event_bus' require 'forwardable' -require 'cucumber/core/gherkin/tag_expression' require 'cucumber' module Cucumber # The base class for configuring settings for a Cucumber run. class Configuration @@ -128,17 +127,12 @@ dirs = paths.map { |f| File.directory?(f) ? f : File.dirname(f) }.uniq dirs.delete('.') unless paths.include?('.') with_default_features_path(dirs) end - # todo: remove - def tag_expression - Cucumber::Core::Gherkin::TagExpression.new(@options[:tag_expressions]) - end - def tag_limits - tag_expression.limits.to_hash + @options[:tag_limits] end def tag_expressions @options[:tag_expressions] end @@ -151,11 +145,11 @@ @options[:filters] end def feature_files potential_feature_files = with_default_features_path(paths).map do |path| - path = path.gsub(/\\/, '/') # In case we're on windows. Globs don't work with backslashes. + 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) @@ -177,11 +171,11 @@ @options[:dry_run] ? other_files : env_files + other_files end def all_files_to_load files = require_dirs.map do |path| - path = path.gsub(/\\/, '/') # In case we're on windows. Globs don't work with backslashes. + 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.reject! {|f| !File.file?(f)} @@ -193,24 +187,25 @@ def step_defs_to_load all_files_to_load.reject {|f| f =~ %r{/support/} } end def formatter_factories - @options[:formats].map do |format_and_out| - format = format_and_out[0] - path_or_io = format_and_out[1] + formats.map do |format, formatter_options, path_or_io| begin factory = formatter_class(format) - yield factory, path_or_io, Cli::Options.new(STDOUT, STDERR, @options) + 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 def formatter_class(format) - if(builtin = Cli::Options::BUILTIN_FORMATS[format]) + if (builtin = Cli::Options::BUILTIN_FORMATS[format]) constantize(builtin[0]) else constantize(format) end end @@ -240,11 +235,11 @@ def event_bus @options[:event_bus] end - private + private def default_options { :autoload_code_paths => ['features/support', 'features/step_definitions'], :filters => [], @@ -259,15 +254,15 @@ :env_vars => {}, :diff_enabled => true, :snippets => true, :source => true, :duration => true, - :event_bus => Core::EventBus.new(Core::Events.registry.merge(Cucumber::Events.registry)) + :event_bus => Cucumber::Events.make_event_bus } end def default_features_paths - ["features"] + ['features'] end def with_default_features_path(paths) return default_features_paths if paths.empty? paths