Hi all guys!im new in rails!
i have a forum,have_many topics,and the topic also has_many
replies.Now i want to write the respec for the repliescontroller:
describe RepliesController do
controller_name :repies
describe “All Requests”,:share=>true do
before do
@forum = mock_model(Forum,:id=>‘1’)
@topic = mock_model(Topic,:id=>‘1’,:forum =>@forum)
@reply = mock_model(Reply,:topic => @topic,:save=>true)
Topic.stub!(:find).and_return(@topic)
Reply.stub!(:new).and_return(@reply)
@params = {
:topic_id => @topic.id,
:forum_id => @forum.id,
:title => 'Ragnarok',
:body => 'ragnarokrangarkratnonfgdsakl'
}
end
def do_post
post :create,:reply =>@params
end
it "should call Reply modl with new values" do
Reply.should_receive(:new).with(anything()).and_return(@reply)
do_post
end
it "should add reply to the topic" do
do_post
response.should redirect_to([@forum,@topic])
end
end
end
No route matches Error!
i have no idea for rspec!!