From a21d844f136564a86b05c18dba9dad6910f37c01 Mon Sep 17 00:00:00 2001 From: Erwan Date: Tue, 4 Sep 2012 18:29:54 +0200 Subject: [PATCH] Bug fix in the overriding of max_threads when it was nil --- lib/browser.rb | 2 +- spec/lib/browser_spec.rb | 23 +++++++++++++++++------ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/lib/browser.rb b/lib/browser.rb index b29ad9bb..31845e42 100644 --- a/lib/browser.rb +++ b/lib/browser.rb @@ -197,7 +197,7 @@ class Browser # Override with the options if they are set def override_config_with_options(options) options.each do |option, value| - if ACCESSOR_OPTIONS.include?(option) + if value != nil and ACCESSOR_OPTIONS.include?(option) self.send(:"#{option}=", value) end end diff --git a/spec/lib/browser_spec.rb b/spec/lib/browser_spec.rb index 044da618..188a0600 100644 --- a/spec/lib/browser_spec.rb +++ b/spec/lib/browser_spec.rb @@ -94,7 +94,7 @@ describe Browser do end 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 check_instance_variables( Browser.instance(:config_file => CONFIG_FILE_WITHOUT_PROXY), @@ -104,7 +104,7 @@ describe Browser do end 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 check_instance_variables( Browser.instance(:config_file => CONFIG_FILE_WITH_PROXY), @@ -113,16 +113,27 @@ describe Browser do end end - # => @todo Write something to test all possible overriding - describe "override option : user_agent" do + # TODO Write something to test all possible overriding + describe "override option : user_agent & threads" do it "will check the instance vars, with an overriden one" do Browser.reset check_instance_variables( Browser.instance( :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