Guest User

Untitled

a guest
Mar 11th, 2018
615
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1. ENV["RAILS_ENV"] = "test"
  2. require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
  3. require 'spec/rails/story_adapter'
  4.  
  5. def create_account(options = {})
  6. options.reverse_update(
  7. :name => "test",
  8. :password => "secret",
  9. :password_confirmation => options[:password_confirmation] || options[:password] || "test@naruku.de",
  10. :email => "test@naruku.de",
  11. :email_confirmation => options[:email_confirmation] || options[:email] || "test@naruku.de",
  12. :activated => true
  13. )
  14.  
  15. u = User.create!(options)
  16. u.activate! if options[:activated]
  17. end
  18.  
  19. def current_user
  20. User.find(session[:user_id]) if session[:user_id]
  21. end
  22.  
  23. steps_for :misc do
  24. Given "an account with username: $username and password: $password" do |username, password|
  25. create_account(:name => username, :password => password)
  26. end
  27.  
  28. Given "I view the index" do
  29. visits "/"
  30. end
  31.  
  32.  
  33.  
  34.  
  35. When "I click the \"$link_text\" link" do |link_text|
  36. clicks_link link_text
  37. end
  38.  
  39. When "I fill in \"$field\" with \"$content\"" do |field, content|
  40. fills_in field, :with => content
  41. end
  42.  
  43. When "I click the \"$button\" button" do |button|
  44. clicks_button button
  45. end
  46.  
  47.  
  48.  
  49.  
  50. Then "I should be logged in" do
  51. session[:user_id].should_not be_nil
  52. end
  53.  
  54. Then "I should not be logged in" do
  55. session[:user_id].should be_nil
  56. end
  57.  
  58. Then "I should see a flash $type" do |type|
  59. if flash[type.to_sym]
  60. flash[type.to_sym].should_not be_blank
  61. else
  62. response.should have_tag("#flash") do
  63. with_tag(".#{type}")
  64. end
  65. end
  66. end
  67.  
  68. Then "I should not see a flash $type" do |type|
  69. if flash[type.to_sym]
  70. flash[type.to_sym].should be_blank
  71. else
  72. response.should have_tag("#flash") do
  73. without_tag(".#{type}")
  74. end
  75. end
  76. end
  77.  
  78. Then "I should see my dashboard" do
  79. response.should have_text(/Dein Dashboard/)
  80. end
  81.  
  82. Then "I should see the signup page" do
  83. response.should have_text(/Anmeldung/)
  84. end
  85.  
  86. Then "I should see the index" do
  87. response.should have_text(/Willkommen bei Naruku/)
  88. end
  89.  
  90. Then "I should see error messages" do
  91. response.should have_tag("#errorExplanation") do
  92. with_tag("ul li")
  93. end
  94. end
  95. end
Add Comment
Please, Sign In to add comment