Publisher modal cucumber step is now officially insane. Or is that me?

This commit is contained in:
Sarah Mei 2011-03-19 18:19:37 -07:00
parent c1bf68068f
commit a8737ab318
2 changed files with 27 additions and 11 deletions

View file

@ -55,7 +55,7 @@ Feature: posting
And I have turned off jQuery effects
And I click "Mention" button
And I expand the publisher in the modal window
And I append "I am eating a yogurt" to the publisher in the modal window
And I append "I am eating a yogurt" to the publisher
And I press "Share" in the modal window
And I follow "<aspect>"
Then I should <see> "I am eating a yogurt"
@ -70,7 +70,7 @@ Feature: posting
And I have turned off jQuery effects
And I click "Mention" button
And I expand the publisher in the modal window
And I append "I am eating a yogurt" to the publisher in the modal window
And I append "I am eating a yogurt" to the publisher
And I follow "DidntPostTo" within "#publisher" in the modal window
And I press "Share" in the modal window
And I follow "<aspect>"

View file

@ -11,13 +11,29 @@ And /^I expand the publisher$/ do
')
end
When /^I append "([^"]*)" to the publisher$/ do |stuff|
script = <<-JS
$('#status_message_fake_text').val(
$('#status_message_fake_text').val() + '#{stuff}').keyup();
JS
page.execute_script(script)
# Wait for the publisher to appear and all the elements to lay out
wait_until { evaluate_script("$('#status_message_fake_text').focus().length == 1") }
# Write to the placeholder field and trigger a keyup to start the copy
page.execute_script <<-JS
$('#status_message_fake_text').val($('#status_message_fake_text').val() + '#{stuff}');
$('#status_message_fake_text').keyup();
JS
# Wait until the text appears in the placeholder
wait_until do
evaluate_script("$('#status_message_fake_text').val().match(/#{stuff}/) != null")
end
# WAIT FOR IT!...
# Wait until the text copy is finished
wait_until do
evaluate_script <<-JS
$('#status_message_text').val() && ($('#status_message_text').val().match(/#{stuff}/) != null)
JS
end
end
And /^I hover over the post$/ do
@ -58,7 +74,7 @@ When /^I press the first "([^"]*)"(?: within "([^"]*)")?$/ do |link_selector, wi
end
end
When /^I press the ([\d])(nd|rd|st|th) "([^\"]*)"(?: within "([^\"]*)")?$/ do |number,rd, link_selector, within_selector|
When /^I press the ([\d])(nd|rd|st|th) "([^\"]*)"(?: within "([^\"]*)")?$/ do |number, rd, link_selector, within_selector|
with_scope(within_selector) do
find(:css, link_selector+":nth-child(#{number})").click
end