Sha256: a2b177241895174c4d941016621d26af5b88a3c58035403b8969fd93307e262b

Contents?: true

Size: 1.86 KB

Versions: 3

Compression:

Stored size: 1.86 KB

Contents

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

Expectations do
  expect Tag do
    Post.new.tags.build
  end

  expect Tagging do
    Post.new.taggings.build
  end
  
  expect ["is_taggable", "has 'tags' by default"] do
    n = Comment.new :tag_list => "is_taggable, has 'tags' by default"
    n.tag_list
  end
  
  expect ["one", "two"] do
    IsTaggable::TagList.delimiter = " "
    n = Comment.new :tag_list => "one two"
    IsTaggable::TagList.delimiter = "," # puts things back to avoid breaking following tests
    n.tag_list
  end

  expect ["something cool", "something else cool"] do
    p = Post.new :tag_list => "something cool, something else cool"
    p.tag_list
  end

  expect ["something cool", "something new"] do
    p = Post.new :tag_list => "something cool, something else cool"
    p.save!
    p.tag_list = "something cool, something new"
    p.save!
    p.tags.reload
    p.instance_variable_set("@tag_list", nil)
    p.tag_list
  end

  expect ["english", "french"] do
    p = Post.new :language_list => "english, french"
    p.save!
    p.tags.reload
    p.instance_variable_set("@language_list", nil)
    p.language_list
  end

  expect ["english", "french"] do
    p = Post.new :language_list => "english, french"
    p.language_list
  end

  expect "english,french" do
    p = Post.new :language_list => "english, french"
    p.language_list.to_s
  end
  
  # added - should clean up strings with arbitrary spaces around commas
  expect ["spaces","should","not","matter"] do
    p = Post.new
    p.tag_list = "spaces,should,  not,matter"
    p.save!
    p.tags.reload
    p.tag_list
  end

  expect ["blank","topics","should be ignored"] do
    p = Post.new
    p.tag_list = "blank, topics, should be ignored, "
    p.save!
    p.tags.reload
    p.tag_list
  end

  expect 2 do
    p = Post.new :language_list => "english, french"
    p.save!
    p.tags.length
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
edouard-is_taggable-0.1.3 test/is_taggable_test.rb
edouard-is_taggable-0.1.1 test/is_taggable_test.rb
is_taggable-0.1.0 test/is_taggable_test.rb