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

- old
+ new

@@ -1,10 +1,13 @@ +# frozen_string_literal: true 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 include Constantize @@ -18,31 +21,27 @@ # # See {Cucumber::Events} for the list of possible events. # # @param event_id [Symbol, Class, String] Identifier for the type of event to subscribe to # @param handler_object [Object optional] an object to be called when the event occurs - # @yield [Object] Block to be called when th event occurs + # @yield [Object] Block to be called when the event occurs # @method on_event - def_instance_delegator :event_bus, :register, :on_event + def_instance_delegator :event_bus, :on, :on_event # @private - def_instance_delegator :event_bus, :notify + def notify(message, *args) + event_bus.send(message, *args) + end def initialize(user_options = {}) - @options = default_options.merge(Cucumber::Hash(user_options)) + @options = default_options.merge(Hash(user_options)) end def with_options(new_options) self.class.new(@options.merge(new_options)) end - # TODO: Actually Deprecate??? - def options - warn("Deprecated: Configuration#options will be removed from the next release of Cucumber. Please use the configuration object directly instead.") - Marshal.load(Marhal.dump(@options)) - end - def out_stream @options[:out_stream] end def error_stream @@ -83,10 +82,34 @@ def expand? @options[:expand] end + def source? + @options[:source] + end + + def duration? + @options[:duration] + end + + def snippets? + @options[:snippets] + end + + def skip_profile_information? + @options[:skip_profile_information] + end + + def profiles + @options[:profiles] || [] + end + + def custom_profiles + profiles - [@options[:default_profile]] + end + def paths @options[:paths] end def formats @@ -177,12 +200,11 @@ path_or_io = format_and_out[1] begin factory = formatter_class(format) yield factory, path_or_io, Cli::Options.new(STDOUT, STDERR, @options) rescue Exception => e - e.message << "\nError creating formatter: #{format}" - raise e + raise e, "#{e.message}\nError creating formatter: #{format}", e.backtrace end end end def formatter_class(format) @@ -199,11 +221,11 @@ # 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 # @@ -214,10 +236,14 @@ def register_snippet_generator(generator) snippet_generators << generator self end + def event_bus + @options[:event_bus] + end + private def default_options { :autoload_code_paths => ['features/support', 'features/step_definitions'], @@ -233,17 +259,12 @@ :env_vars => {}, :diff_enabled => true, :snippets => true, :source => true, :duration => true, - :event_bus => Events::Bus.new(Cucumber::Events) + :event_bus => Core::EventBus.new(Core::Events.registry.merge(Cucumber::Events.registry)) } end - - def event_bus - @options[:event_bus] - end - def default_features_paths ["features"] end