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

blog_steps.rb 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. include Warden::Test::Helpers
  2. Given /^the following list of blog posts?$/ do |table|
  3. user = FactoryGirl.create(:user)
  4. table.hashes.each do |hash|
  5. post = FactoryGirl.create("blog_post", 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. Then(/^The current url should be "(.*?)"$/) do |arg1|
  16. uri = URI.parse(current_url)
  17. "#{uri.path}".should == arg1
  18. end
  19. Then(/^I should see "(.*?)"$/) do |arg1|
  20. page.should have_content(arg1)
  21. end
  22. Then(/^I should not see "(.*?)"$/) do |arg1|
  23. page.should have_no_content(arg1)
  24. end
  25. Then(/^I should see the link "(.*?)"$/) do |arg1|
  26. find_link(arg1).visible?
  27. end
  28. Then(/^I should not see the link "(.*?)"$/) do |arg1|
  29. assert has_no_link?(arg1)
  30. end
  31. Then(/^I should see "(.*?)" And I should see "(.*?)"$/) do |arg1, arg2|
  32. page.should have_content(arg1)
  33. page.should have_content(arg2)
  34. end
  35. Then(/^the page should have a "(.*?)" called "(.*?)"$/) do |arg1, arg2|
  36. selector = arg1 + '#' + arg2
  37. page.should have_css(selector)
  38. end
  39. Then(/^the page should not have a "(.*?)" called "(.*?)"$/) do |arg1, arg2|
  40. selector = arg1 + '#' + arg2
  41. page.should have_no_css(selector)
  42. end
  43. When(/^I click in the link "(.*?)"$/) do |arg1|
  44. click_link arg1
  45. end
  46. When(/^I click in the button "(.*?)"$/) do |arg1|
  47. click_button arg1
  48. end
  49. Then(/^I fill in "(.*?)" with "(.*?)"$/) do |arg1, arg2|
  50. fill_in arg1, :with => arg2
  51. end