Sha256: 88fffdca9e72ac11b21174a787f0c327ef4009fad6817b15556763263e51cf0d

Contents?: true

Size: 1.18 KB

Versions: 1

Compression:

Stored size: 1.18 KB

Contents

require 'spec_helper'
require 'cantango/registry/shared/hash_ex'

describe CanTango::Config::Categories do
  subject { CanTango.config.categories }

  describe 'API' do
    before(:each) do
      categories = {:a => ['B', 'C'], 'x' => ['Y', 'Z'], 'v' => ['B', 'Z']}

      subject.clean!
      subject.register categories
    end

    describe 'get index []' do
      specify {
        subject.register(:w => 'something non-array!')
        lambda { subject.category('w') }.should raise_error
      }
    end

    describe 'category_has_subject?' do
      specify {
        subject.category('a').has_any?('B').should be_true 
      }
    end

    describe 'has_subject?' do
      specify { subject.has_any?('Y').should be_true }
    end

    describe 'category_names_of_subject' do
      specify { subject.category_names_of_subject('B').last.should == 'v' }

      specify { subject.category_names_of_subject('c').first.should == nil }
    end

    describe 'categories_of_subject' do
      specify do
        subject.categories_of_subject('B').should == {'a' => ['B', 'C'], 'v' => ['B', 'Z'],}
      end

      specify do
        subject.categories_of_subject('blip').should == {}
      end
    end
  end
end


Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cantango-config-0.2.0 spec/cantango/config/categories_spec.rb