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

blog_steps.rb 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. include Warden::Test::Helpers
  2. Given /^the following (.+) list ?$/ do |factory, table|
  3. user = FactoryGirl.create(:user)
  4. table.hashes.each do |hash|
  5. post = FactoryGirl.create(factory, hash)
  6. post.author = user
  7. post.save
  8. end
  9. end
  10. Given /^I have blog posts titled (.+)$/ do |titles|
  11. titles.split(', ').each do |title|
  12. BlogPost.create!(:title => title)
  13. end
  14. end
  15. When /^I go to (.+)$/ do |page_name|
  16. path_to(page_name)
  17. end
  18. Then(/^The current url should be "(.*?)"$/) do |arg1|
  19. uri = URI.parse(current_url)
  20. "#{uri.path}".should == arg1
  21. end
  22. Then(/^I should see "(.*?)"$/) do |arg1|
  23. page.should have_content(arg1)
  24. end
  25. Then(/^I should not see "(.*?)"$/) do |arg1|
  26. page.should have_no_content(arg1)
  27. end
  28. Then(/^I should see the link "(.*?)"$/) do |arg1|
  29. find_link(arg1).visible?
  30. end
  31. Then(/^I should not see the link "(.*?)"$/) do |arg1|
  32. assert has_no_link?(arg1)
  33. end
  34. Then(/^I should see "(.*?)" And I should see "(.*?)"$/) do |arg1, arg2|
  35. page.should have_content(arg1)
  36. page.should have_content(arg2)
  37. end
  38. Then(/^the page should have a "(.*?)" called "(.*?)"$/) do |arg1, arg2|
  39. selector = arg1 + '#' + arg2
  40. page.should have_css(selector)
  41. end
  42. Then(/^the page should not have a "(.*?)" called "(.*?)"$/) do |arg1, arg2|
  43. selector = arg1 + '#' + arg2
  44. page.should have_no_css(selector)
  45. end
  46. When(/^I click in the link "(.*?)"$/) do |arg1|
  47. click_link arg1
  48. end
  49. When(/^I click in the button "(.*?)"$/) do |arg1|
  50. click_button arg1
  51. end
  52. Then(/^I fill in "(.*?)" with "(.*?)"$/) do |arg1, arg2|
  53. fill_in arg1, :with => arg2
  54. end