Sha256: e9b69972a4c419f0223b396b5ddaaa0c1d11ddcfe824e5bbf61f9231b46b5c41

Contents?: true

Size: 1.56 KB

Versions: 10

Compression:

Stored size: 1.56 KB

Contents

require 'helper'

class TestTags < Test::Unit::TestCase
  context "working with tags" do
    setup do
      BlogPost.delete_all
      @blogpost = BlogPost.create(:title => "operation systems",
                                  :body => "list of some operating systems",
                                  :tags => %w[list windows freebsd osx linux])
      @blogpost2 = BlogPost.create(:title => "nosql database",
                                   :body => "list of some nosql databases",
                                   :tags => %w[list mongodb redis couchdb])
    end

    should "generate the tagcloud" do
      cloud = BlogPost.tag_cloud

      [{"name"=>"list", "count"=>2.0},
       {"name"=>"windows", "count"=>1.0},
       {"name"=>"freebsd", "count"=>1.0},
       {"name"=>"osx", "count"=>1.0},
       {"name"=>"linux", "count"=>1.0},
       {"name"=>"mongodb", "count"=>1.0},
       {"name"=>"redis", "count"=>1.0},
       {"name"=>"couchdb", "count"=>1.0}].each do |entry|
        cloud.should include(entry)
      end
    end

    should "find blogpost that include the given tags" do
      BlogPost.find_with_tags("mongodb").should == [@blogpost2]
      posts = BlogPost.find_with_tags("mongodb", "linux")
      posts.should include(@blogpost)
      posts.should include(@blogpost2)
      posts.size.should == 2
    end

    should "find tags that start with li" do
      tags = BlogPost.find_tags(/^li/)
      [{"name"=>"list", "count"=>2.0}, {"name"=>"linux", "count"=>1.0}].each do |entry|
        tags.should include(entry)
      end
      tags.size.should == 2
    end

  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
mongomapper_ext-0.5.2 test/test_tags.rb
mongomapper_ext-0.5.1 test/test_tags.rb
mongomapper_ext-0.5.0 test/test_tags.rb
mongomapper_ext-0.4.0 test/test_tags.rb
mongomapper_ext-0.3.0 test/test_tags.rb
mongomapper_ext-0.2.4 test/test_tags.rb
mongomapper_ext-0.2.3 test/test_tags.rb
mongomapper_ext-0.2.2 test/test_tags.rb
mongomapper_ext-0.2.1 test/test_tags.rb
mongomapper_ext-0.2.0 test/test_tags.rb