Sha256: 17bc92974c09f13930299372def63403004666eefdf2209b0710af7db3650101

Contents?: true

Size: 1.39 KB

Versions: 1

Compression:

Stored size: 1.39 KB

Contents

# encoding: UTF-8

require File.expand_path('../../../test_helper', __FILE__)

describe "Tag list fields" do
  before do
    @site = setup_site
    @now = Time.now
    stub_time(@now)
    Spontaneous::State.delete
    @site.background_mode = :immediate
    @content_class = Class.new(::Piece)
    @prototype = @content_class.field :tags
    @content_class.stubs(:name).returns("ContentClass")
    @instance = @content_class.create
    @field = @instance.tags
  end

  it "has a distinct editor class" # eventually...

  it "adopts any field called 'tags'" do
    assert @field.is_a?(Spontaneous::Field::Tags), "Field should be an instance of TagsField but instead has the following ancestors #{ @prototype.instance_class.ancestors }"
  end

  it "defaults to an empty list" do
    @field.value(:html).must_equal ""
    @field.value(:tags).must_equal []
  end

  it "correctly parses strings" do
    @field.value = 'this that "the other" more'
    @field.value(:html).must_equal 'this that "the other" more'
    @field.value(:tags).must_equal ["this", "that", "the other", "more"]
  end

  it "includes Enumerable" do
    @field.value = 'this that "the other" more'
    @field.map(&:upcase).must_equal  ["THIS", "THAT", "THE OTHER", "MORE"]
  end

  it "allows for tags with commas" do
    @field.value = %(this that "the, other" more)
    @field.map(&:upcase).must_equal  ["THIS", "THAT", "THE, OTHER", "MORE"]
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spontaneous-0.2.0.beta10 test/unit/fields/test_tag_list_fields.rb