Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "[#33 state:resolved] refactored to move the config down to We…
…brat::Core as it seemed nicer" This reverts commit 58cbf49.
- Loading branch information
Showing
7 changed files
with
69 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
module Webrat | ||
module Core | ||
class Configuration | ||
|
||
# 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 | ||
|
||
# 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 | ||
@@configuration = nil | ||
|
||
def default_open_error_files | ||
true | ||
end | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper") | ||
|
||
describe Webrat::Core::Configuration do | ||
|
||
before do | ||
Webrat::Core::Configuration.cache_config_for_test | ||
end | ||
|
||
after do | ||
Webrat::Core::Configuration.reset_for_test | ||
end | ||
|
||
it "should have a default config" do | ||
Webrat::Core::Configuration.configuration.should be_an_instance_of(Webrat::Core::Configuration) | ||
end | ||
|
||
it "should set default values" do | ||
config = Webrat::Core::Configuration.configuration | ||
config.open_error_files.should == true | ||
end | ||
|
||
it "should be configurable with a block" do | ||
Webrat::Core::Configuration.configure do |config| | ||
config.open_error_files = false | ||
end | ||
config = Webrat::Core::Configuration.configuration | ||
config.open_error_files.should == false | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.