Sha256: f671de53e88eeb5ba3cb3d36056dad39a635305d7370cd0916a6717d2e0fb9f8

Contents?: true

Size: 1.68 KB

Versions: 13

Compression:

Stored size: 1.68 KB

Contents

require "#{File.dirname(__FILE__)}/../spec_helper"


describe 'Taggable, Unit', :unit_test => true do

  let(:nodule) { CukeModeler::Taggable }
  let(:model) { o = Object.new.extend(nodule)

                  def o.parent_model
                    @parent_model
                  end

                  def o.parent_model=(parent)
                    @parent_model = parent
                  end

                  o
                }


  describe 'unique behavior' do

    it 'has tags' do
      expect(model).to respond_to(:tags)
    end

    it 'can change its tags' do
      expect(model).to respond_to(:tags=)

      model.tags = :some_tags
      expect(model.tags).to eq(:some_tags)
      model.tags = :some_other_tags
      expect(model.tags).to eq(:some_other_tags)
    end

    it 'has applied tags' do
      expect(model).to respond_to(:applied_tags)
    end

    it 'inherits its applied tags from its ancestors' do
      all_parent_tags = [:parent_tag_1, :parent_tag_2, :grandparent_tag_1]
      parent = double(:all_tags => all_parent_tags)

      model.parent_model = parent

      expect(model.applied_tags).to eq(all_parent_tags)
    end

    it 'knows all of its applicable tags' do
      all_parent_tags = [:parent_tag_1, :parent_tag_2, :grandparent_tag_1]
      own_tags = [:tag_1, :tag_2]

      parent = double(:all_tags => all_parent_tags)

      model.parent_model = parent
      model.tags = own_tags

      expect(model.all_tags).to eq(all_parent_tags + own_tags)
    end

    it 'may have no applied tags' do
      model.parent_model = :not_a_tagged_object

      expect(model.applied_tags).to eq([])
    end

  end

end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
cuke_modeler-2.1.0 testing/rspec/spec/unit/taggable_unit_spec.rb
cuke_modeler-2.0.0 testing/rspec/spec/unit/taggable_unit_spec.rb
cuke_modeler-1.5.1 testing/rspec/spec/unit/taggable_unit_spec.rb
cuke_modeler-1.5.0 testing/rspec/spec/unit/taggable_unit_spec.rb
cuke_modeler-1.4.0 testing/rspec/spec/unit/taggable_unit_spec.rb
cuke_modeler-1.3.0 testing/rspec/spec/unit/taggable_unit_spec.rb
cuke_modeler-1.2.1 testing/rspec/spec/unit/taggable_unit_spec.rb
cuke_modeler-1.2.0 testing/rspec/spec/unit/taggable_unit_spec.rb
cuke_modeler-1.1.1 testing/rspec/spec/unit/taggable_unit_spec.rb
cuke_modeler-1.1.0 testing/rspec/spec/unit/taggable_unit_spec.rb
cuke_modeler-1.0.4 testing/rspec/spec/unit/taggable_unit_spec.rb
cuke_modeler-1.0.3 testing/rspec/spec/unit/taggable_unit_spec.rb
cuke_modeler-1.0.2 testing/rspec/spec/unit/taggable_unit_spec.rb