Sha256: 35fa698c95ae5a68683fc61f684d9843dd4ce4b8c649f5891edf0a21065bcd15

Contents?: true

Size: 1.49 KB

Versions: 3

Compression:

Stored size: 1.49 KB

Contents

require 'spec_helper'

# The Contact class which is used in this as our taggable model
# is defined in the spec/models.rb file.

describe "Taggable" do
  before(:each) do
    @user = User.create!(:name => "My Owner")
    @contact = Contact.create!(:name => "My Taggable")
  end

  describe "Integration" do
    describe "#has_tag?" do
      it "returns true if the taggable has the given tag" do
        tag = @user.tagalong_tags.create!(:name => "foo")
        @contact.tagalong_taggings.create!(:tagalong_tag_id => tag.id)
        @contact.has_tag?("foo").should be_true
      end
      
      it "returns false if the taggable does NOT have the given tag" do
        @contact.has_tag?("bar").should be_false
      end
    end

    describe "#tags" do
      it "returns list of tags currently applied to this taggable" do
        @contact.tagalong_tags.create!(:name => "foo")
        @contact.tagalong_tags.create!(:name => "bar")
        @contact.tagalong_tags.create!(:name => "car")
        @contact.tags.should == ["foo", "bar", "car"]
      end

      it "returns list of tags currently applied in descending order of references" do
        @contact.tagalong_tags.create!(:name => "hoopty", :number_of_references => 5)
        @contact.tagalong_tags.create!(:name => "doopty", :number_of_references => 99)
        @contact.tagalong_tags.create!(:name => "toopty", :number_of_references => 4)
        @contact.tags.should == ["doopty", "hoopty", "toopty"]
      end
    end
  end

  describe "Isolation" do
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tagalong-0.0.3 spec/lib/tagalong/taggable_spec.rb
tagalong-0.0.2 spec/lib/tagalong/taggable_spec.rb
tagalong-0.0.1 spec/lib/tagalong/taggable_spec.rb