Guest User

Untitled

a guest
Mar 11th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. require File.dirname(__FILE__) + "/helper"
  2.  
  3. def login_user
  4. post "/sessions", :login => @user.login, :password => "test"
  5. @login_response = response
  6. end
  7.  
  8. def create_user(login = "some_user")
  9. user = User.create!(:login => login, :password => 'test', :password_confirmation => 'test', :email => "#{login}@test.com")
  10. user.activate
  11. user
  12. end
  13.  
  14. steps_for(:simple_user) do
  15. Given "a user" do
  16. @user = create_user("user_ursula")
  17. end
  18.  
  19. When "the user logs in" do
  20. login_user
  21. end
  22.  
  23. Then "the login should be successful" do
  24. response.should be_success
  25. end
  26. end
  27.  
  28. with_steps_for(:simple_user) do
  29. run_local_story "simple", :type => RailsStory
  30. end
  31.  
  32. ### simple is below:
  33. Story: User logging in
  34.  
  35. As a user
  36. I want to login with my details
  37. So that I can get access to the site
  38.  
  39. Scenario: User is valid
  40.  
  41. Given a user
  42.  
  43. When the user logs in
  44.  
  45. Then the login should be successful
  46.  
  47. ### output:
  48. $ ruby stories/simple.rb
  49. Running 1 scenarios
  50.  
  51. Story: User logging in
  52.  
  53. As a user
  54. I want to login with my details
  55. So that I can get access to the site
  56.  
  57. Scenario: User is valid
  58.  
  59. Given a user
  60.  
  61. When the user logs in
  62.  
  63. Then the login should be successful (FAILED)
  64.  
  65. 1 scenarios: 0 succeeded, 1 failed, 0 pending
  66.  
  67. FAILURES:
  68. 1) User logging in (User is valid) FAILED
  69. Spec::Expectations::ExpectationNotMetError: expected success? to return true, got false
  70. vendor/plugins/rspec_on_rails/lib/spec/rails/../../../../rspec/lib/spec/expectations.rb:52:in `fail_with'
  71. ...
Add Comment
Please, Sign In to add comment