Created
December 3, 2008 23:06
-
-
Save nmerouze/31749 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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('<?xml version="1.0" encoding="UTF-8"?>') | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment