lib/cucumber/configuration.rb in cucumber-2.1.0 vs lib/cucumber/configuration.rb in cucumber-2.2.0
- old
+ new
@@ -1,10 +1,13 @@
require 'cucumber/constantize'
require 'cucumber/cli/rerun_file'
require 'cucumber/events'
require 'forwardable'
require 'cucumber/core/gherkin/tag_expression'
+require 'cucumber'
+require 'event/bus'
+require 'event/name_resolver'
module Cucumber
# The base class for configuring settings for a Cucumber run.
class Configuration
include Constantize
@@ -26,15 +29,15 @@
# @private
def_instance_delegator :event_bus, :notify
def initialize(user_options = {})
- @options = default_options.merge(Hash.try_convert(user_options))
+ @options = default_options.merge(Cucumber::Hash(user_options))
end
def with_options(new_options)
- self.class.new(new_options.merge(@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.")
@@ -191,10 +194,29 @@
def to_hash
@options
end
+ # 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
+ #
+ def snippet_generators
+ @options[:snippet_generators] ||= []
+ end
+
+ def register_snippet_generator(generator)
+ snippet_generators << generator
+ self
+ end
+
private
def default_options
{
:autoload_code_paths => ['features/support', 'features/step_definitions'],
@@ -210,10 +232,10 @@
:env_vars => {},
:diff_enabled => true,
:snippets => true,
:source => true,
:duration => true,
- :event_bus => Events::Bus.new(Cucumber::Events)
+ :event_bus => Event::Bus.new(Event::NameResolver.new(Cucumber::Events))
}
end
def event_bus
@options[:event_bus]