Skip to content

Instantly share code, notes, and snippets.

@patmaddox
Created March 10, 2009 02:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patmaddox/76667 to your computer and use it in GitHub Desktop.
Save patmaddox/76667 to your computer and use it in GitHub Desktop.
class PeopleController < ApplicationController
def create
begin
p = Person.new params[:person]
p.save
render :text => "yay!"
rescue
render :text => "oops!"
end
end
end
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe PeopleController do
integrate_views
it "should show a message when there's an error'" do
post :create, :person => {:name => nil}
response.body.should == "oops!"
end
end
class CreatePeople < ActiveRecord::Migration
def self.up
create_table :people do |t|
t.string :name, :null => false
t.timestamps
end
end
def self.down
drop_table :people
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment