hornbeck / blerb-core

blerb running on merb-core

This URL has Read+Write access

blerb-core / spec / controllers / comments_spec.rb
100644 35 lines (29 sloc) 1.064 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
require File.join(File.dirname(__FILE__), 'controller_spec_helper.rb')
 
describe Comments do
  before(:each) do
    @article = mock_model Article,
      {
        :title => "Merb + Blerb = Superb!",
        :slug => "merb-blerb-superb",
        :created_at => Time.now,
        :body => ""
      }
    
    @comment = mock_model(Comment)
  end
  
  describe "#create" do
    it "should find the article for the new comment by the article id" do
      #Stubs & mocks, stubs & mocks
      builder = mock(:dm_builder)
      builder.stub!(:build).and_return @comment
      @comment.stub!(:request=)
      @comment.stub!(:save)
      @article.stub!(:comments).and_return(builder)
      
      #The good stuff
      Article.should_receive(:first).and_return @article
      
      dispatch_to(Comments, :create, :article_id => @article.id, :comment => "T-T-T-Testing!")
    end
    
    it "should be able to create a comment"
    it "should redirect to parent article if create succeeds"
    it "should redirect to parent ar new again if authentication failed"
  end
end