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