Collapsing Webrat::Core module. Moving configuration methods to configuration.rb
This commit is contained in:
parent
9f8a88d649
commit
31cc6b75da
@ -12,22 +12,6 @@ module Webrat
|
||||
defined?(RAILS_ROOT) ? RAILS_ROOT : Merb.root
|
||||
end
|
||||
|
||||
|
||||
# Configures Webrat. If this is not done, Webrat will be created
|
||||
# with all of the default settings.
|
||||
def self.configure(configuration = Webrat::Core::Configuration.new)
|
||||
yield configuration if block_given?
|
||||
@@configuration = configuration
|
||||
end
|
||||
|
||||
def self.configuration
|
||||
@@configuration = Webrat::Core::Configuration.new unless @@configuration
|
||||
@@configuration
|
||||
end
|
||||
|
||||
private
|
||||
@@configuration = nil
|
||||
|
||||
end
|
||||
|
||||
# We need Nokogiri's CSS to XPath support, even if using REXML and Hpricot for parsing and searching
|
||||
|
@ -1,18 +1,24 @@
|
||||
module Webrat
|
||||
module Core
|
||||
|
||||
# Configures Webrat. If this is not done, Webrat will be created
|
||||
# with all of the default settings.
|
||||
def self.configure(configuration = Webrat::Configuration.new)
|
||||
yield configuration if block_given?
|
||||
@@configuration = configuration
|
||||
end
|
||||
|
||||
def self.configuration
|
||||
@@configuration ||= Webrat::Configuration.new
|
||||
end
|
||||
|
||||
class Configuration
|
||||
# Sets whether to save and open pages with error status codes in a browser
|
||||
attr_accessor :open_error_files
|
||||
|
||||
def initialize
|
||||
self.open_error_files = default_open_error_files
|
||||
end
|
||||
|
||||
private
|
||||
def default_open_error_files
|
||||
true
|
||||
self.open_error_files = true
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
end
|
@ -11,7 +11,6 @@ Spec::Runner.configure do |config|
|
||||
# Nothing to configure yet
|
||||
end
|
||||
|
||||
|
||||
module Webrat
|
||||
@@previous_config = nil
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
||||
|
||||
describe Webrat::Core::Configuration do
|
||||
|
||||
describe Webrat::Configuration do
|
||||
before do
|
||||
Webrat.cache_config_for_test
|
||||
end
|
||||
@ -11,7 +10,7 @@ describe Webrat::Core::Configuration do
|
||||
end
|
||||
|
||||
it "should have a default config" do
|
||||
Webrat.configuration.should be_an_instance_of(Webrat::Core::Configuration)
|
||||
Webrat.configuration.should be_an_instance_of(Webrat::Configuration)
|
||||
end
|
||||
|
||||
it "should set default values" do
|
||||
@ -26,5 +25,4 @@ describe Webrat::Core::Configuration do
|
||||
config = Webrat.configuration
|
||||
config.open_error_files.should == false
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in New Issue
Block a user