diff options
author | Folker Bernitt <fbernitt@thoughtworks.com> | 2014-08-20 17:21:20 +0200 |
---|---|---|
committer | Folker Bernitt <fbernitt@thoughtworks.com> | 2014-08-20 17:45:12 +0200 |
commit | ae6f773d4abc42dcc0eaa1c70f8af14b091f8d47 (patch) | |
tree | 15e5df69a6d1b774042dfd29372115a1baf4136f /py-fake-service/features/step_definitions/mail_list.rb | |
parent | a3ea808b6290a7c756b28099df9fa8574c94055e (diff) |
Translated cucumber tests to behave.
Diffstat (limited to 'py-fake-service/features/step_definitions/mail_list.rb')
-rw-r--r-- | py-fake-service/features/step_definitions/mail_list.rb | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/py-fake-service/features/step_definitions/mail_list.rb b/py-fake-service/features/step_definitions/mail_list.rb new file mode 100644 index 00000000..d41a62a0 --- /dev/null +++ b/py-fake-service/features/step_definitions/mail_list.rb @@ -0,0 +1,55 @@ +When(/^I open the first mail in the '(.*)'$/) do |tag| + page.execute_script("window.scrollBy(0, -200)") + step "I select the tag '#{tag}'" + step 'I open the first mail in the mail list' +end + +When(/^I open the first mail in the mail list$/) do + within('#mail-list') do + mail_link = first('a') + @current_mail_id = mail_link.native.attribute('href').scan(/\/(\d+)$/).flatten.first + begin + mail_link.click + rescue # in Chrome, the 'a' in mail_list is not clickable because it's hidden inside the 'li' + mail_link_parent_li = mail_link.find(:xpath, '../..') + mail_link_parent_li.click + end + end +end + +When(/I see that mail under the '(.*)' tag/) do |tag| + step "I select the tag '#{tag}'" + check_current_mail_is_visible +end + +And(/^I open the mail I previously tagged$/) do + open_current_mail +end + +When(/^I open that mail$/) do + open_current_mail +end + +Then(/^I see the mail I sent$/) do + check_current_mail_is_visible +end + +Then(/^the deleted mail is there$/) do + check_current_mail_is_visible +end + +def open_current_mail + within('#mail-list') do + begin + first("#mail-#{@current_mail_id} a").click + rescue # in Chrome, the 'a' in mail_list is not clickable because it's hidden inside the 'li' + first("#mail-#{@current_mail_id}").click + end + end +end + +def check_current_mail_is_visible + within('#mail-list') do + have_selector?("#mail-#{@current_mail_id}").should be_true + end +end |