Guest User

Untitled

a guest
Feb 20th, 2018
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. describe "a request to /foo/bar" do
  2. def login
  3. post("/account/login", "username=myuser&password=awesomepass")
  4. end
  5.  
  6. def logout
  7. post("/account/logout")
  8. end
  9.  
  10. before(:each) do
  11. login
  12. get("/foo/bar")
  13. end
  14.  
  15. after(:each) do
  16. logout
  17. end
  18.  
  19. it("should be successful") do
  20. rack.status.should == 200
  21. end
  22.  
  23. it("should show a login page if you're not logged in") do
  24. logout
  25. get("/foo/bar")
  26. rack.status.should == 302
  27. rack.should redirect_to("/account/login")
  28. end
  29.  
  30. it("should show a page") do
  31. expected = html do
  32. header "User"
  33. element do
  34. User.first.name
  35. end
  36. end
  37. rack.body.should have_contents_like(expected)
  38. end
  39. end
Add Comment
Please, Sign In to add comment