spec/button_spec.rb in rautomation-0.3.0 vs spec/button_spec.rb in rautomation-0.4.0

- old
+ new

@@ -1,6 +1,6 @@ -require File.expand_path(File.dirname(__FILE__) + '/spec_helper') +require 'spec_helper' describe RAutomation::Button do it "#button" do RAutomation::Window.new(:title => SpecHelper::DATA[:window2_title]). button(:value => SpecHelper::DATA[:window2_button_text]).should exist @@ -29,12 +29,31 @@ window = RAutomation::Window.new(:title => SpecHelper::DATA[:window2_title]) RAutomation::Window.wait_timeout = 0.1 expect {window.button(:value => "non-existent-button").click}. to raise_exception(RAutomation::UnknownButtonException) + RAutomation::Window.wait_timeout = 60 button = window.button(:value => SpecHelper::DATA[:window2_button_text]) button.should exist button.click button.should_not exist window.should_not exist end -end \ No newline at end of file + + it "#click with a block for defining successful click" do + window = RAutomation::Window.new(:title => SpecHelper::DATA[:window2_title]) + RAutomation::Window.wait_timeout = 5 + button = window.button(:value => SpecHelper::DATA[:window2_button_text]) + expect {button.click {false}}. + to raise_exception(RAutomation::WaitHelper::TimeoutError) + button.should_not exist + window.should_not exist + + RAutomation::Window.wait_timeout = 10 + window = RAutomation::Window.new(:title => SpecHelper::DATA[:window2_title]) + button = window.button(:value => SpecHelper::DATA[:window2_button_text]) + button.should exist + button.click {|button| !button.exists? && !window.exists?} + button.should_not exist + window.should_not exist + end +end