Skip to content

Instantly share code, notes, and snippets.

@shlevy
Created December 8, 2010 05:19
Show Gist options
  • Save shlevy/732925 to your computer and use it in GitHub Desktop.
Save shlevy/732925 to your computer and use it in GitHub Desktop.
Messages Controller and Controller Spec
class MessagesController < ApplicationController
def create
Message.new(params[:message])
redirect_to :action => "index"
end
end
require 'spec_helper'
class Message
extend ActiveModel::Naming
end
describe MessagesController do
describe "POST create" do
let (:message) {mock_model("Message").as_null_object}
before do
Message.stub(:new).and_return(message)
end
it "creates a new message" do
Message.should_receive(:new).with("text" => "a quick brown fox")
post :create, :message => { "text" => "a quick brown fox" }
end
it "saves the message"
it "redirects to the Messages index" do
post :create
response.should redirect_to(:action => "index")
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment