Skip to content

Commit

Permalink
remove duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
Despo Pentara authored and Despo Pentara committed Jul 12, 2012
1 parent a472184 commit 99f54d9
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions lib/prickle/capybara/popup/selenium.rb
Expand Up @@ -12,24 +12,15 @@ def initialize
alias :popup :initialize

def confirm &block
if block_given?
block.call
@message = popup.text
end
handle_webkit_syntax &block if block_given?
popup.accept
self
end

alias :accept :confirm

def dismiss &block
if block_given?
block.call
@message = popup.text
sleep 1
popup.accept
return self
end
return handle_webkit_syntax_dismiss &block if block_given?
popup.dismiss
end

Expand All @@ -41,6 +32,19 @@ def contains_message? message
raise Exceptions::MessageNotContainedInPopup.new(self.message) unless self.message.eql? message
end

private

def handle_webkit_syntax_dismiss &block
handle_webkit_syntax &block
popup.accept
self
end

def handle_webkit_syntax &block
block.call
@message = popup.text
end

end
end
end
Expand Down

0 comments on commit 99f54d9

Please sign in to comment.