require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe PostsController do integrate_views describe 'GET /index' do before(:each) do get :index end it "should be successful" do response.should be_success end it "should render template 'index'" do response.should render_template("index") response.should have_tag("h1") end end describe 'GET /index.xml' do before(:each) do request.env["HTTP_ACCEPT"] = "application/xml" get :index end it "should be successful" do response.should be_success end it "should render all posts as xml" do response.body.should include('') end end describe "POST /posts" do describe "with valid parameters" do before(:each) do post :create, :post => { :title => 'Cool' } end it "should be redirected" do response.should be_redirect end it "should redirect to the created post" do response.should redirect_to(post_url(1)) end end describe "with invalid parameters" do before(:each) do post :create, :post => {} end it "should not be redirected" do response.should_not be_redirect end it "should render template 'new'" do response.should render_template("new") response.should have_tag("h1") end end end end