Sha256: e6e81751fe63fb9cb287a5d6b77a1854b3bdc2633636c32591a1892f692d7cda

Contents?: true

Size: 1.37 KB

Versions: 6

Compression:

Stored size: 1.37 KB

Contents

require File.dirname(__FILE__) + '/../spec_helper'

describe Tag do
  dataset :tags
  
  it "should reuse an existing tag if possible" do
    tag = Tag.for('colourless')
    tag.should == tags(:colourless)
  end
  
  it "should create a tag where none exists" do
    tag = Tag.for('calumny')
    tag.should be_valid
    tag.new_record?.should be_false
  end

  it "should find_or_create tags from a list" do
    tags = Tag.from_list('colourless,ideas,lifebelt')
    tags[0].should == tags(:colourless)
    tags[1].should == tags(:ideas)
    tags[2].created_at.should be_close((Time.now).utc, 10.seconds)
  end
  
  it "should stringify as title" do
    "#{tags(:colourless)}".should == 'colourless'
  end

  it "should <=> by title" do
    tags = Tag.from_list('ideas,colourless,lifebelt')
    tags.sort.first.should == tags(:colourless)
  end

  it "should sort tags naturally" do
    tags = Tag.from_list('item2, item11, item13, item20, item1, item0')
    tags.sort.join(' ').should == %{item0 item1 item2 item11 item13 item20}
  end
  
  describe "instantiated" do
    before do
      @tag = tags(:sleep)
    end
    
    it "should have retrieval methods for taggable models" do
      @tag.respond_to?(:page_taggings).should be_true
      @tag.respond_to?(:pages).should be_true
    end
    
    it "should return its list of pages" do
      @tag.pages.should == [pages(:first)]
    end
    
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
radiant-taggable-extension-2.0.0.rc2 spec/models/tag_spec.rb
radiant-taggable-extension-2.0.0.rc1 spec/models/tag_spec.rb
radiant-taggable-extension-1.2.5 spec/models/tag_spec.rb
radiant-taggable-extension-1.2.4 spec/models/tag_spec.rb
radiant-taggable-extension-1.2.3 spec/models/tag_spec.rb
radiant-taggable-extension-1.2.2 spec/models/tag_spec.rb