From fcfdb106bc87a59c30c758919a97f284f46034da Mon Sep 17 00:00:00 2001 From: Thomas Walpole Date: Wed, 2 Jul 2014 19:31:13 -0700 Subject: [PATCH] DRY modal method documentation [ci skip] --- lib/capybara/session.rb | 41 +++++++++++------------------------------ spec/selenium_spec.rb | 2 +- 2 files changed, 12 insertions(+), 31 deletions(-) diff --git a/lib/capybara/session.rb b/lib/capybara/session.rb index 15d68f83..1f1f07ff 100644 --- a/lib/capybara/session.rb +++ b/lib/capybara/session.rb @@ -530,12 +530,13 @@ module Capybara # # Execute the block, accepting a alert. # - # @overload accept_alert(text, options = {}, &blk) - # @param text [String, Regexp] Text or regex to match against the text in the modal. If not provided any prompt modal is matched - # @overload accept_alert(options = {}, &blk) - # @option options [Numeric] :wait How long to wait for the modal to appear after executing the block. - # @return [String] the message shown in the modal - # @raise [Capybara::ModalNotFound] if modal dialog hasn't been found + # @!macro modal_params + # @overload $0(text, options = {}, &blk) + # @param text [String, Regexp] Text or regex to match against the text in the modal. If not provided any modal is matched + # @overload $0(options = {}, &blk) + # @option options [Numeric] :wait How long to wait for the modal to appear after executing the block. + # @return [String] the message shown in the modal + # @raise [Capybara::ModalNotFound] if modal dialog hasn't been found # def accept_alert(text_or_options=nil, options={}, &blk) if text_or_options.is_a? Hash @@ -551,12 +552,7 @@ module Capybara # # Execute the block, accepting a confirm. # - # @overload accept_confirm(text, options = {}, &blk) - # @param text [String, Regexp] Text or regex to match against the text in the modal. If not provided any prompt modal is matched - # @overload accept_confirm(options = {}, &blk) - # @option options [Numeric] :wait How long to wait for the modal to appear after executing the block. - # @return [String] the message shown in the modal - # @raise [Capybara::ModalNotFound] if modal dialog hasn't been found + # @macro modal_params # def accept_confirm(text_or_options=nil, options={}, &blk) if text_or_options.is_a? Hash @@ -572,12 +568,7 @@ module Capybara # # Execute the block, dismissing a confirm. # - # @overload dismiss_confirm(text, options = {}, &blk) - # @param text [String, Regexp] Text or regex to match against the text in the modal. If not provided any prompt modal is matched - # @overload dismiss_confirm(options = {}, &blk) - # @option options [Numeric] :wait How long to wait for the modal to appear after executing the block. - # @return [String] the message shown in the modal - # @raise [Capybara::ModalNotFound] if modal dialog hasn't been found + # @macro modal_params # def dismiss_confirm(text_or_options=nil, options={}, &blk) if text_or_options.is_a? Hash @@ -593,13 +584,8 @@ module Capybara # # Execute the block, accepting a prompt, optionally responding to the prompt. # - # @overload accept_prompt(text, options = {}, &blk) - # @param text [String, Regexp] Text or regex to match against the text in the modal. If not provided any prompt modal is matched - # @overload accept_prompt(options = {}, &blk) + # @macro modal_params # @option options [String] :with Response to provide to the prompt - # @option options [Numeric] :wait How long to wait for the prompt to appear after executing the block. - # @return [String] the message shown in the modal - # @raise [Capybara::ModalNotFound] if modal dialog hasn't been found # def accept_prompt(text_or_options=nil, options={}, &blk) if text_or_options.is_a? Hash @@ -615,12 +601,7 @@ module Capybara # # Execute the block, dismissing a prompt. # - # @overload dismiss_prompt(text, options = {}, &blk) - # @param text [String, Regexp] Text or regex to match against the text in the modal. If not provided any prompt modal is matched - # @overload dismiss_prompt(options = {}, &blk) - # @option options [Numeric] :wait How long to wait for the prompt to appear after executing the block. - # @return [String] the message shown in the modal - # @raise [Capybara::ModalNotFound] if modal dialog hasn't been found + # @macro modal_params # def dismiss_prompt(text_or_options=nil, options={}, &blk) if text_or_options.is_a? Hash diff --git a/spec/selenium_spec.rb b/spec/selenium_spec.rb index 9420a612..b0f39822 100644 --- a/spec/selenium_spec.rb +++ b/spec/selenium_spec.rb @@ -64,7 +64,7 @@ RSpec.describe Capybara::Session do end end - describe "#accept_alert", focus: true do + describe "#accept_alert" do it "supports a blockless mode" do @session.visit('/with_js') @session.click_link('Open alert')