A website template with lots of features, built with ruby on rails.

helper_steps.rb 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. Then(/^I should see in the field "(.*?)" the text "(.*?)"$/) do |arg1, arg2|
  2. value = find_field(arg1).value
  3. value.should have_content(arg2)
  4. end
  5. Given(/^the website is configured$/) do
  6. configs = Info.all
  7. configs.each do |config|
  8. config.destroy
  9. end
  10. FactoryGirl.create(:info)
  11. end
  12. Given(/^Maintenance mode is activated$/) do
  13. Info.last.update(maintenance_mode: true, maintenance_title: 'Website under maintenance', maintenance_message: 'Please check back soon')
  14. end
  15. Given /^the following (.+) list ?$/ do |factory, table|
  16. table.hashes.each do |hash|
  17. FactoryGirl.create(factory, hash)
  18. end
  19. end
  20. Then(/^spit out the page HTML$/) do
  21. puts page.html
  22. end
  23. Then /^show me the page$/ do
  24. save_and_open_page
  25. end
  26. When /^I go to (.+)$/ do |page_name|
  27. path_to(page_name)
  28. end
  29. Given /^I visit the "(.*)"/ do |place|
  30. visit "/#{place}"
  31. end
  32. When /^I visit the homepage$/ do
  33. visit ""
  34. end
  35. # File Upload
  36. Then(/^I upload the file "(.*?)" to the field "(.*?)"$/) do |arg1, arg2|
  37. @test_file_path = File.expand_path(('../../spec/fixtures/' + arg1), File.dirname(__FILE__))
  38. attach_file arg2, @test_file_path
  39. end
  40. # Check for image
  41. Then(/^I should see the image "(.*?)"$/) do |image_name|
  42. page.should have_selector("img[src$='#{image_name}']")
  43. end
  44. # Upload Images
  45. Given(/^the following files where uploaded$/) do |table|
  46. table.hashes.each do |hash|
  47. visit '/admin/files/new'
  48. fill_in "Title", :with => hash[:title]
  49. fill_in "Description", :with => hash[:description]
  50. @test_file_path = File.expand_path(('../../spec/fixtures/' + hash[:file]), File.dirname(__FILE__))
  51. attach_file "upload_file", @test_file_path
  52. click_button "Save"
  53. end
  54. end