[MediaWiki-commits] [Gerrit] Renamed `bind` methods to `configure` - change (mediawiki/selenium)
jenkins-bot has submitted this change and it was merged. Change subject: Renamed `bind` methods to `configure` .. Renamed `bind` methods to `configure` Use of the obscure name `bind`, albeit it slightly more accurate to the implementation, has led to some confusion. Let's rename it now before it has widespread use. Change-Id: I234c30b33faf9f1bc532056f16d65922b7a4662c --- M lib/mediawiki_selenium/browser_factory/base.rb M lib/mediawiki_selenium/browser_factory/chrome.rb M lib/mediawiki_selenium/browser_factory/firefox.rb M lib/mediawiki_selenium/browser_factory/phantomjs.rb M lib/mediawiki_selenium/environment.rb M lib/mediawiki_selenium/remote_browser_factory.rb M lib/mediawiki_selenium/support/hooks.rb M spec/browser_factory/base_spec.rb 8 files changed, 81 insertions(+), 75 deletions(-) Approvals: Zfilipin: Looks good to me, approved jenkins-bot: Verified diff --git a/lib/mediawiki_selenium/browser_factory/base.rb b/lib/mediawiki_selenium/browser_factory/base.rb index b4df78f..784ab20 100644 --- a/lib/mediawiki_selenium/browser_factory/base.rb +++ b/lib/mediawiki_selenium/browser_factory/base.rb @@ -15,7 +15,7 @@ # @example Always configure Firefox's language according to `:browser_language` # module MediawikiSelenium::BrowserFactory # class Firefox Base -# bind(:browser_language) do |lang, options| +# configure(:browser_language) do |lang, options| # options[:desired_capabilities][:firefox_profile][intl.accept_languages] = lang # end # end @@ -26,13 +26,16 @@ # @yield [values, browser_options] A block that binds the configuration to # the browser options. # -def bind(*names, blk) +def configure(*names, blk) raise ArgumentError, 'no block given' unless block_given? key = names.length == 1 ? names.first : names default_bindings[key] ||= [] default_bindings[key] blk end + +# @deprecated Use {.configure} instead. +alias bind configure # All bindings for this factory class combined with those of super # classes. @@ -58,7 +61,7 @@ attr_reader :browser_name - bind(:browser_timeout) { |value, options| options[:http_client].timeout = value.to_i } + configure(:browser_timeout) { |value, options| options[:http_client].timeout = value.to_i } # Initializes new factory instances. # @@ -83,17 +86,17 @@ # # @example Override the user agent according :browser_user_agent # factory = BrowserFactory.new(:firefox) - # factory.bind(:browser_user_agent) do |agent, options| + # factory.configure(:browser_user_agent) do |agent, options| # options[:desired_capabilities][:firefox_profile][general.useragent.override] = agent # end # # @example Annotate the session with our build information - # factory.bind(:job_name, :build_number) do |job, build, options| + # factory.configure(:job_name, :build_number) do |job, build, options| # options[:desired_capabilities][:name] = #{job} (#{build}) # end # # @example Bindings aren't invoked unless all given options are configured - # factory.bind(:foo, :bar) do |foo, bar, options| + # factory.configure(:foo, :bar) do |foo, bar, options| # # this never happens! # options[:desired_capabilities][:name] = #{foo} #{bar} # end @@ -104,12 +107,15 @@ # @yield [values, browser_options] A block that binds the configuration to # the browser options. # - def bind(*names, blk) + def configure(*names, blk) key = names.length == 1 ? names.first : names @bindings[key] ||= [] @bindings[key] (blk || proc {}) end + # @deprecated Use {#configure} instead. + alias bind configure + # Effective bindings for this factory, those defined at the class level # and those defined for this instance. # diff --git a/lib/mediawiki_selenium/browser_factory/chrome.rb b/lib/mediawiki_selenium/browser_factory/chrome.rb index 7b0113d..71eb024 100644 --- a/lib/mediawiki_selenium/browser_factory/chrome.rb +++ b/lib/mediawiki_selenium/browser_factory/chrome.rb @@ -10,15 +10,15 @@ # @see Base # class Chrome Base - bind(:browser_http_proxy) do |http_proxy, options| + configure(:browser_http_proxy) do |http_proxy, options| options[:args] --proxy-server=#{http_proxy} end - bind(:browser_language) do |language, options| + configure(:browser_language) do |language, options| options[:prefs]['intl.accept_languages'] = language end - bind(:browser_user_agent) do |user_agent,
[MediaWiki-commits] [Gerrit] Renamed `bind` methods to `configure` - change (mediawiki/selenium)
Dduvall has uploaded a new change for review. https://gerrit.wikimedia.org/r/201830 Change subject: Renamed `bind` methods to `configure` .. Renamed `bind` methods to `configure` Use of the obscure name `bind`, albeit it slightly more accurate to the implementation, has led to some confusion. Let's rename it now before it has widespread use. Change-Id: I234c30b33faf9f1bc532056f16d65922b7a4662c --- M lib/mediawiki_selenium/browser_factory/base.rb M lib/mediawiki_selenium/browser_factory/chrome.rb M lib/mediawiki_selenium/browser_factory/firefox.rb M lib/mediawiki_selenium/browser_factory/phantomjs.rb M lib/mediawiki_selenium/environment.rb M lib/mediawiki_selenium/remote_browser_factory.rb M lib/mediawiki_selenium/support/hooks.rb M spec/browser_factory/base_spec.rb 8 files changed, 81 insertions(+), 75 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/selenium refs/changes/30/201830/1 diff --git a/lib/mediawiki_selenium/browser_factory/base.rb b/lib/mediawiki_selenium/browser_factory/base.rb index b4df78f..784ab20 100644 --- a/lib/mediawiki_selenium/browser_factory/base.rb +++ b/lib/mediawiki_selenium/browser_factory/base.rb @@ -15,7 +15,7 @@ # @example Always configure Firefox's language according to `:browser_language` # module MediawikiSelenium::BrowserFactory # class Firefox Base -# bind(:browser_language) do |lang, options| +# configure(:browser_language) do |lang, options| # options[:desired_capabilities][:firefox_profile][intl.accept_languages] = lang # end # end @@ -26,13 +26,16 @@ # @yield [values, browser_options] A block that binds the configuration to # the browser options. # -def bind(*names, blk) +def configure(*names, blk) raise ArgumentError, 'no block given' unless block_given? key = names.length == 1 ? names.first : names default_bindings[key] ||= [] default_bindings[key] blk end + +# @deprecated Use {.configure} instead. +alias bind configure # All bindings for this factory class combined with those of super # classes. @@ -58,7 +61,7 @@ attr_reader :browser_name - bind(:browser_timeout) { |value, options| options[:http_client].timeout = value.to_i } + configure(:browser_timeout) { |value, options| options[:http_client].timeout = value.to_i } # Initializes new factory instances. # @@ -83,17 +86,17 @@ # # @example Override the user agent according :browser_user_agent # factory = BrowserFactory.new(:firefox) - # factory.bind(:browser_user_agent) do |agent, options| + # factory.configure(:browser_user_agent) do |agent, options| # options[:desired_capabilities][:firefox_profile][general.useragent.override] = agent # end # # @example Annotate the session with our build information - # factory.bind(:job_name, :build_number) do |job, build, options| + # factory.configure(:job_name, :build_number) do |job, build, options| # options[:desired_capabilities][:name] = #{job} (#{build}) # end # # @example Bindings aren't invoked unless all given options are configured - # factory.bind(:foo, :bar) do |foo, bar, options| + # factory.configure(:foo, :bar) do |foo, bar, options| # # this never happens! # options[:desired_capabilities][:name] = #{foo} #{bar} # end @@ -104,12 +107,15 @@ # @yield [values, browser_options] A block that binds the configuration to # the browser options. # - def bind(*names, blk) + def configure(*names, blk) key = names.length == 1 ? names.first : names @bindings[key] ||= [] @bindings[key] (blk || proc {}) end + # @deprecated Use {#configure} instead. + alias bind configure + # Effective bindings for this factory, those defined at the class level # and those defined for this instance. # diff --git a/lib/mediawiki_selenium/browser_factory/chrome.rb b/lib/mediawiki_selenium/browser_factory/chrome.rb index 7b0113d..71eb024 100644 --- a/lib/mediawiki_selenium/browser_factory/chrome.rb +++ b/lib/mediawiki_selenium/browser_factory/chrome.rb @@ -10,15 +10,15 @@ # @see Base # class Chrome Base - bind(:browser_http_proxy) do |http_proxy, options| + configure(:browser_http_proxy) do |http_proxy, options| options[:args] --proxy-server=#{http_proxy} end - bind(:browser_language) do |language, options| + configure(:browser_language) do |language, options| options[:prefs]['intl.accept_languages'] = language end -