describe "when logging in at '/'" do describe "the login form" do it "exists" do response_for("/").should have_xpath("//*") end it "POSTS to url(:login)" do response_for("/").should have_xpath("//form[@method='post'][@action='#{url(:login)}']") end it "has a text field named 'username'" do response_for("/").should have_xpath("//form/input[@name='username'][@type='text']") end it "has a password field named password" do response_for("/").should have_xpath("//form/input[@name='password'][@type='password']") end end it "redirects to '/' if the login was incorrect" do requesting("/", :method => "POST", :body_params => {:username => "wycats", :password => "bad"}). should redirect_to(:get_login) end it "logs in" do logging_in.should redirect_to(:home) end end