Allow multiple configuration blocks without dropping previous configuration.

If you really want to start with a default configuration use:

  Webrat.configure(Webrat::Configuration.new) do |config|
    ...
  end
This commit is contained in:
Bryan Helmkamp 2009-01-18 16:15:56 -05:00
parent 0b07dfedcd
commit fdb94f399c
2 changed files with 15 additions and 1 deletions

View File

@ -4,7 +4,7 @@ module Webrat
# Configures Webrat. If this is not done, Webrat will be created # Configures Webrat. If this is not done, Webrat will be created
# with all of the default settings. # with all of the default settings.
def self.configure(configuration = Webrat::Configuration.new) def self.configure(configuration = Webrat.configuration)
yield configuration if block_given? yield configuration if block_given?
@@configuration = configuration @@configuration = configuration
end end

View File

@ -34,6 +34,20 @@ describe Webrat::Configuration do
config.should_not open_error_files config.should_not open_error_files
end end
it "should be configurable with multiple blocks" do
Webrat.configure do |config|
config.open_error_files = false
end
Webrat.configure do |config|
config.selenium_server_port = 1234
end
config = Webrat.configuration
config.should_not open_error_files
config.selenium_server_port.should == 1234
end
[:rails, [:rails,
:selenium, :selenium,
:rack, :rack,