Sha256: 3ea78cfbd5193f15a75a6abb47b6de7b7b9dcc2e5da601902f24ffcfa7d28d1e

Contents?: true

Size: 1.47 KB

Versions: 8

Compression:

Stored size: 1.47 KB

Contents

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

describe CanTango::Configuration::Category do
  subject { CanTango::Configuration::Category.new }
    specify { subject.has_any?(:x).should_not be_true }

  subject { CanTango::Configuration::Category.new :a, :b }
    specify { subject.has_any?(:a).should be_true }
end

describe CanTango::Configuration::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

8 entries across 8 versions & 1 rubygems

Version Path
cantango-config-0.1.9.2 spec/cantango/configuration/categories_spec.rb
cantango-config-0.1.8.1 spec/cantango/configuration/categories_spec.rb
cantango-config-0.1.8 spec/cantango/configuration/categories_spec.rb
cantango-config-0.1.7 spec/cantango/configuration/categories_spec.rb
cantango-config-0.1.6 spec/cantango/configuration/categories_spec.rb
cantango-config-0.1.5 spec/cantango/configuration/categories_spec.rb
cantango-config-0.1.4 spec/cantango/configuration/categories_spec.rb
cantango-config-0.1.3 spec/cantango/configuration/categories_spec.rb