Skip to content

Instantly share code, notes, and snippets.

@oelmekki
Created March 20, 2011 12:45
Show Gist options
  • Save oelmekki/878311 to your computer and use it in GitHub Desktop.
Save oelmekki/878311 to your computer and use it in GitHub Desktop.
describe 'with valid attributes' do
describe 'when publishing' do
before :each do
post 'create', :blog_post => @valid_attributes, :commit => { :publish => 'publish' }
end
it 'should create a new blog post' do
BlogPost.count.should == 1
end
it 'should publish it' do
BlogPost.first.published.should be_true
end
it 'should redirect to blog post page' do
response.should redirect_to( blog_post_path( BlogPost.first ) )
end
end
end
describe 'with invalid attributes' do
before :each do
post 'create', :blog_post => @valid_attributes.merge( :content => nil ), :commit => { :publish => 'publish' }
end
it 'should not create new blog post' do
BlogPost.count.should == 0
end
it 'should render new template' do
response.should render_template( :new )
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment