Sha256: 8a245cee8c3cdd663ec7c80c265226923e70946a5646d09b4cf75f3e1d73bd83

Contents?: true

Size: 1.24 KB

Versions: 1

Compression:

Stored size: 1.24 KB

Contents

require 'spec_helper'

describe Article do
  # context "Validation" do
  #   should_validate_presence_of :title, :body
  #   should_belong_to :site
  #   should_belong_to :user
  # end

  before do
    @site = Site.make
    @post_1 = @site.articles.make(:title => "first post")
    @post_2 = @site.articles.make(:title => "second post")
  end

  it "should set published_at when publish" do
    article = @site.articles.make
    article.published?.should == false
    
    article.publish!
    
    article.published?.should == true
    article.published_at.should be_a(Time)
  end

  it "has link to prev article" do
    @post_1.publish!
    @post_2.publish!
    
    @post_1.prev.should == nil
    @post_2.prev.should == @post_1
  end
  
  it "has link to next article" do
    @post_1.publish!
    @post_2.publish!
    
    @post_1.next.should == @post_2
    @post_2.next.should == nil
  end

  it "has a article style url (/:year/:month/:permalink)" do
    pattern = /^\/articles\/[0-9]{4}\/[0-9]{2}\/[0-9]{2}\/([a-z0-9-]+)$/    
    Article.make.url.should =~ pattern
  end

  context "Tagging" do
    it "tag list for multiple tagging" do
      @post_1.tag_list = 'ruby, rails'
      
      @post_1.save
      
      @post_1.should have(2).tags
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
content_engine-0.1.0 spec/models/article_spec.rb