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

blog_steps.rb 1.7KB

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