Created
August 9, 2012 20:21
-
-
Save beckyconning/3307763 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
# There is no message object in the first example, and there needs to be one | |
# for the code in the action to run. | |
def create | |
message = Message.new(params[:message]) | |
message.save | |
redirect_to :action => "index" | |
end | |
# We can get the first example to pass without impacting the second example by | |
# introducing a mock message: | |
it "creates a new message" do | |
message = mock_model(Message) | |
Message.should_receive(:new).with( | |
"text" => "a quick brown fox" | |
).and_return(message) | |
post :create, :message => { "text" => "a quick brown fox" } | |
end | |
# Here we create a mock message and then tell the Message class to return it | |
# in response to new( ). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment