Sha256: e69c35747a2e71e15c73883dc21a038dbe84b58d62576e5a8f8df9ba5a2572f1

Contents?: true

Size: 1.04 KB

Versions: 4

Compression:

Stored size: 1.04 KB

Contents

require 'pathname'
require Pathname(__FILE__).dirname.expand_path.parent + 'spec_helper'

describe "Tag", "when updating" do
  before do
    @tagged_model = TaggedModel.new
  end

  it "should create itself" do
    @tagged_model.tag_list = "abc, def, ghi"
    @tagged_model.skill_list = "Casablanca, Morocco"
    @tagged_model.save

    @tagged_model.should_not be_new_record
    @tagged_model.reload
    @tagged_model.tags.map { |t| t.name }.should == %w[ abc def ghi ]
    @tagged_model.skills.map { |t| t.name }.should == %w[ Casablanca Morocco ]
  end

  it "should update itself" do
    @tagged_model.save
    @tagged_model.should_not be_new_record
    @tagged_model.reload

    @tagged_model.tags.should be_empty
    @tagged_model.skills.should be_empty

    @tagged_model.tag_list = "abc, def, xyz, jkl"
    @tagged_model.skill_list = "Sahara, Morocco"
    @tagged_model.save

    @tagged_model.reload
    @tagged_model.tags.map { |t| t.name }.should == %w[ abc def jkl xyz ]
    @tagged_model.skills.map { |t| t.name }.should == %w[ Morocco Sahara ]
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dm-tags-0.9.8 spec/dm-tags/updating_spec.rb
dm-tags-0.9.10 spec/dm-tags/updating_spec.rb
dm-tags-0.9.11 spec/dm-tags/updating_spec.rb
dm-tags-0.9.9 spec/dm-tags/updating_spec.rb