moredip/Frank — pull request #81 by mhaylock (2012-03-20 09:57:32+00:00)
Title: Shelly: Added UIView helpers to help detect if a view is animating

I ran into an issue where interacting with UIAlertView's was happening too fast (i.e. before the view finished animating) - in this particular case one UIAlertView would show another, but the still active animation of the previous alert view prevented it from showing.

Putting in a sleep worked but I wanted a faster solution. By adding a `isNotAnimating` selector to UIView I can now filter by this.

My alert view steps (based on the code in [this pull request](https://github.com/moredip/Frank/pull/64) which hasn't been merged in) now look like this:

```ruby
WAIT_TIMEOUT = ENV['WAIT_TIMEOUT'].to_i || 240

Given /^I (do not )?see an alert view titled "([^\"]*)"$/ do |qualifier, expected_mark|
expected_to_see = "do not " != qualifier

values = []
Timeout::timeout(WAIT_TIMEOUT) do
until !(values = frankly_map( 'alertView isNotAnimating', 'title')).empty?
sleep 0.1
end
end

if expected_to_see
values.should include(expected_mark)
else
values.should_not include(expected_mark)
end
end

Given /^I (do not )?see an alert view with the message "([^\"]*)"$/ do |qualifier, expected_mark|
expected_to_see = "not " != qualifier

values = []
Timeout::timeout(WAIT_TIMEOUT) do
until !(values = frankly_map( 'alertView isNotAnimating', 'message')).empty?
sleep 0.1
end
end

if expected_to_see
values.should include(expected_mark)
else
values.should_not include(expected_mark)
end
end
```

This change solves my problem - the code find the alert view the moment it stops animating. I suspect this pattern of waiting for a view to stop animating will be something I return to more than once as this first project using Frank grows.