Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#33 state:resolved] refactored to move the config down to Webrat::Co…
…re as it seemed nicer
- Loading branch information
Showing
7 changed files
with
74 additions
and
69 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 |
---|---|---|
@@ -1,33 +0,0 @@ | ||
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 was deleted.
Oops, something went wrong.
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 do | ||
|
||
before do | ||
Webrat::Core.cache_config_for_test | ||
end | ||
|
||
after do | ||
Webrat::Core.reset_for_test | ||
end | ||
|
||
it "should have a default config" do | ||
Webrat::Core.configuration.should be_an_instance_of(Webrat::Core) | ||
end | ||
|
||
it "should set default values" do | ||
config = Webrat::Core.configuration | ||
config.open_error_files.should == true | ||
end | ||
|
||
it "should be configurable with a block" do | ||
Webrat::Core.configure do |config| | ||
config.open_error_files = false | ||
end | ||
config = Webrat::Core.configuration | ||
config.open_error_files.should == false | ||
end | ||
|
||
end |