Sha256: 75fd7ef06d03d443ac8e53574b9a122e24a48f18ea94d7e03f45c2f386db9c74

Contents?: true

Size: 1.17 KB

Versions: 3

Compression:

Stored size: 1.17 KB

Contents

require '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.should be_true
    @tagged_model.should be_saved

    @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.should be_true
    @tagged_model.should be_saved

    @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.should be_true

    @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 ]

    @tagged_model.tag_list = ""
    @tagged_model.skill_list = ""
    @tagged_model.save

    @tagged_model.tags.should == []
    @tagged_model.skills.should == []
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dm-tags-0.10.2 spec/dm-tags/updating_spec.rb
dm-tags-0.10.1 spec/dm-tags/updating_spec.rb
dm-tags-0.10.0 spec/dm-tags/updating_spec.rb