Created
December 8, 2010 05:19
-
-
Save shlevy/732925 to your computer and use it in GitHub Desktop.
Messages Controller and Controller Spec
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
class MessagesController < ApplicationController | |
def create | |
Message.new(params[:message]) | |
redirect_to :action => "index" | |
end | |
end |
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 '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