Bug fix in the overriding of max_threads when it was nil

This commit is contained in:
Erwan
2012-09-04 18:29:54 +02:00
parent 8e5d506bc1
commit a21d844f13
2 changed files with 18 additions and 7 deletions

View File

@@ -197,7 +197,7 @@ class Browser
# Override with the options if they are set # Override with the options if they are set
def override_config_with_options(options) def override_config_with_options(options)
options.each do |option, value| options.each do |option, value|
if ACCESSOR_OPTIONS.include?(option) if value != nil and ACCESSOR_OPTIONS.include?(option)
self.send(:"#{option}=", value) self.send(:"#{option}=", value)
end end
end end

View File

@@ -94,7 +94,7 @@ describe Browser do
end end
describe "#instance with :config_file = #{CONFIG_FILE_WITHOUT_PROXY}" do describe "#instance with :config_file = #{CONFIG_FILE_WITHOUT_PROXY}" do
it 'will check the instance vars' do it "will check the instance vars" do
Browser.reset Browser.reset
check_instance_variables( check_instance_variables(
Browser.instance(:config_file => CONFIG_FILE_WITHOUT_PROXY), Browser.instance(:config_file => CONFIG_FILE_WITHOUT_PROXY),
@@ -104,7 +104,7 @@ describe Browser do
end end
describe "#instance with :config_file = #{CONFIG_FILE_WITH_PROXY}" do describe "#instance with :config_file = #{CONFIG_FILE_WITH_PROXY}" do
it 'will check the instance vars' do it "will check the instance vars" do
Browser.reset Browser.reset
check_instance_variables( check_instance_variables(
Browser.instance(:config_file => CONFIG_FILE_WITH_PROXY), Browser.instance(:config_file => CONFIG_FILE_WITH_PROXY),
@@ -113,16 +113,27 @@ describe Browser do
end end
end end
# => @todo Write something to test all possible overriding # TODO Write something to test all possible overriding
describe "override option : user_agent" do describe "override option : user_agent & threads" do
it "will check the instance vars, with an overriden one" do it "will check the instance vars, with an overriden one" do
Browser.reset Browser.reset
check_instance_variables( check_instance_variables(
Browser.instance( Browser.instance(
:config_file => CONFIG_FILE_WITHOUT_PROXY, :config_file => CONFIG_FILE_WITHOUT_PROXY,
:user_agent => 'fake IE' :user_agent => "fake IE"
), ),
@json_config_without_proxy.merge('user_agent' => 'fake IE') @json_config_without_proxy.merge("user_agent" => "fake IE")
)
end
it "should not override the max_threads if max_threads = nil" do
Browser.reset
check_instance_variables(
Browser.instance(
:config_file => CONFIG_FILE_WITHOUT_PROXY,
:max_threads => nil
),
@json_config_without_proxy
) )
end end
end end