public
Description: blerb running on merb-core
Homepage:
Clone URL: git://github.com/hornbeck/blerb-core.git
Sean Braithwaite (author)
Mon Mar 24 14:14:32 -0700 2008
commit  cfbe86545f97d2a058abf3fe7b63bfb22a5c9c3d
tree    f78b19b6fb2d42b6e0fdeb4fbf579c6cee38d2e9
parent  a4a64804e50e4226caae85b9bb7952b53cc98165
blerb-core / spec / controllers / articles_spec.rb
08819d2f » benburkert 2008-02-22 added controller specific s... 1 require File.join(File.dirname(__FILE__), 'controller_spec_helper.rb')
208424ba » hornbeck 2008-01-25 first commit 2
ef6f0855 » jwhitmire 2008-01-28 implemented default model/c... 3 describe Articles do
0a17d2bf » brapse 2008-02-15 Fixed and refactored Defaul... 4 include DefaultSpecHelper
5 include ArticleSpecHelper
6 include DefaultControllerHelper
7
8 it_should_behave_like "default controller behavior"
9
8071c75c » jwhitmire 2008-01-28 Changed Articles#index to p... 10 describe "#index" do
6744c2ee » benburkert 2008-02-14 Fixing up the specs for mer... 11 it "should find all articles and place them in @articles" do
12 Article.should_receive(:all).and_return []
13 dispatch_to(Articles, :index).assigns(:articles).should == []
14 end
15
16 it "should find all articles by reverse date" do
17 Article.should_receive(:all).with(:order => 'created_at desc')
18
19 dispatch_to(Articles, :index)
20 end
21 end
22
23 describe "#show" do
24 before(:each) do
25 @article = mock_model Article,
26 {
27 :title => "Merb + Blerb = Superb!",
28 :slug => "merb-blerb-superb",
29 :created_at => Time.now,
30 :body => "",
31 :comments => []
32 }
33 end
34
35 it "should find the first article by the slug" do
36 Article.should_receive(:with_slug).with(@article.slug).and_return @article
37
38 dispatch_to(Articles, :show, :id => @article.slug)
8071c75c » jwhitmire 2008-01-28 Changed Articles#index to p... 39 end
40
6744c2ee » benburkert 2008-02-14 Fixing up the specs for mer... 41 it "should find the first article and place it in @article" do
42 Article.should_receive(:with_slug).and_return @article
43
44 dispatch_to(Articles, :show, :id => @article.slug).assigns(:article).should == @article
45 end
46
47 it "should raise a NotFound error if the slug id does not find an article" do
48 Article.should_receive(:with_slug).and_return nil
49
50 lambda { dispatch_to(Articles, :show, :id => @article.slug) }.should raise_error(Merb::ControllerExceptions::NotFound)
51 end
8071c75c » jwhitmire 2008-01-28 Changed Articles#index to p... 52 end
0a17d2bf » brapse 2008-02-15 Fixed and refactored Defaul... 53 end