PageRenderTime 73ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

/features/step_definitions/general_steps.rb

https://github.com/xanthipe/bladesdb
Ruby | 108 lines | 85 code | 23 blank | 0 comment | 8 complexity | 53ac38e957cec28d88ecca860a4a926a MD5 | raw file
  1. When(/^I fill in "(.*?)" with "(.*?)"$/) do |field, value|
  2. fill_in("#{field}", with: value)
  3. end
  4. When(/^I click the "(.*?)" button$/) do |button|
  5. click_button(button)
  6. end
  7. When(/^I click on the "(.*?)" link for "(.*?)"$/) do |text, fieldname|
  8. page.find("li##{fieldname.gsub(/(\W)/, '').underscore}").find_link(text).click
  9. end
  10. When(/^I click on the "(.*?)" link for the "(?:.*?)" with the name "(.*?)"$/) do |text, name|
  11. page.find_link(name).first(:xpath,".//..//..").find_link(text).click
  12. end
  13. When(/^I click on the "(.*?)" link$/) do |text|
  14. page.find("div#content-space").find_link(text).click
  15. end
  16. When(/^I check "(.*?)"$/) do |text|
  17. text.downcase!
  18. page.find("label", text: text).click
  19. end
  20. When(/^I uncheck "(.*?)"$/) do |text|
  21. text.downcase!
  22. page.find("label", text: text).click
  23. end
  24. When(/^I take a screenshot$/) do
  25. page.save_screenshot('screenshot.png')
  26. end
  27. Then(/^a(?:n?) (.*?) message is displayed saying "(.*?)"$/) do |type, message|
  28. if type == "dialogue error"
  29. page.should have_css("div#errorExplanation")
  30. page.find("div#errorExplanation").should have_content(message, exact: true)
  31. else
  32. page.should have_css("div.#{type}")
  33. page.find("div.#{type}").should have_content(message, exact: true)
  34. end
  35. end
  36. Then(/^I can see(?:| my| their) "(.*?)" field$/) do |fieldname|
  37. page.find("li##{fieldname.gsub(/(\W)/, '').underscore}").find("div.fieldlabel").should have_content(fieldname)
  38. end
  39. Then(/^I can see(?:| my| their) "(.*?)" (?:|is|are|) "(.*?)"$/) do |fieldname, value|
  40. page.find("li##{fieldname.gsub(/(\W)/, '').underscore}").find("div.fieldcontents").should have_content(value)
  41. end
  42. Then(/^I can see(?:| my| their) "(.*?)" section$/) do |section|
  43. page.find("div##{section.gsub(/(\W)/, '').underscore}")
  44. end
  45. Then(/^there(?:| is| are|) no "(.*?)" links?$/) do |text|
  46. page.find("div#content-space").all("a").should_not have_content(text)
  47. end
  48. Then(/^there(?:| is| are|) an? "(.*?)" links?$/) do |text|
  49. page.find("div#content-space").find_link(text)
  50. end
  51. Then(/^an? "(.*?)" dialogue opens$/) do |title|
  52. page.find("span.ui-dialog-title").should have_content(title)
  53. end
  54. Then(/^the "(?:.*?)" with the name "(.*?)" is in the "(.*?)" table$/) do |name, table|
  55. table.downcase!
  56. page.find("table##{table}").find_link(name)
  57. end
  58. Then(/^there is no "(.*?)" table$/) do |table|
  59. table.downcase!
  60. page.should_not have_css("table##{table}")
  61. end
  62. Then(/^there is an? "(.*?)" table$/) do |table|
  63. table.downcase!
  64. page.should have_css("table##{table}")
  65. end
  66. Then(/^there is no "(.*?)" link for the "(?:.*?)" with the name "(.*?)"$/) do |text, name|
  67. page.find_link(name).first(:xpath,".//..//..").has_no_link?(text)
  68. end
  69. Then(/^there is an? "(.*?)" link for the "(?:.*?)" with the name "(.*?)"$/) do |text, name|
  70. page.find_link(name).first(:xpath,".//..//..").has_link?(text)
  71. end
  72. Then(/^the "(?:.*?)" with the name "(.*?)" does not appear on any table$/) do |name|
  73. page.has_no_link?(name)
  74. end
  75. Then(/^the "(?:.*?)" with the name "(.*?)" has the "(.*?)" marker$/) do |name, marker|
  76. page.find_link(name).first(:xpath,".//..//..").has_xpath?(".//img[@title='#{marker}']")
  77. end
  78. Then(/^the "(?:.*?)" with the name "(.*?)" does not have the "(.*?)" marker$/) do |name, marker|
  79. page.find_link(name).first(:xpath,".//..//..").has_no_xpath?(".//img[@title='#{marker}']")
  80. end
  81. Then(/^there will be a "(.*?)" message in the sidebar$/) do |message|
  82. if message == "medical details"
  83. page.find("div.admin_notifications").should have_content("Your medical details")
  84. end
  85. end