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

blog_steps.rb 1.5KB

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