Sha256: 1785f6c2947ef61c920a84114b5ebceee83ef61d6ca4f289d0f2f1ace4595e3e

Contents?: true

Size: 1.17 KB

Versions: 22

Compression:

Stored size: 1.17 KB

Contents

shared_examples_for 'Hash Registry' do
  let(:hash1) do
    {:a => 1, :b => 2}
  end

  let(:hash2) do
    {:c => 3}
  end

  describe 'default settings' do
    its(:registered)  { should be_empty }

    describe 'defaults' do
      before do
        subject.default = hash1
      end

      its(:default) { should include(hash1) }
    end
  end

  describe 'register' do
    before do
      subject.register hash1
      subject.register hash2
    end
    its(:registered) { should include(hash1) }
    its(:registered) { should include(hash2) }
  end

  describe 'append <<' do
    before do
      subject << hash2
      subject.register hash1
      subject << hash2
    end
    its(:registered) { should include(hash1, hash2) }
  end

  describe 'get index []' do
    before do
      subject.register hash1
      subject << hash2
    end
    
    it 'should respond to :symbol keys' do
      subject[:c].should == 3
    end

    it "should respond to 'string' keys" do
      subject['c'].should == 3
    end
  end

  describe 'set index []=' do
    before do
      subject.clean!
      subject.register hash1
      subject[:d] = 5
    end
    specify { subject[:d].should == 5 }

  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
cantango-0.9.4.7 spec/cantango/configuration/shared/hash_registry_ex.rb
cantango-0.9.4.6 spec/cantango/configuration/shared/hash_registry_ex.rb
cantango-0.9.4.5 spec/cantango/configuration/shared/hash_registry_ex.rb
cantango-0.9.4.3 spec/cantango/configuration/shared/hash_registry_ex.rb
cantango-0.9.4.2 spec/cantango/configuration/shared/hash_registry_ex.rb
cantango-0.9.4.1 spec/cantango/configuration/shared/hash_registry_ex.rb
cantango-0.9.4 spec/cantango/configuration/shared/hash_registry_ex.rb
cantango-0.9.3.2 spec/cantango/configuration/shared/hash_registry_ex.rb
cantango-0.8.9.5 spec/cantango/configuration/shared/hash_registry_ex.rb
cantango-0.8.9.4 spec/cantango/configuration/shared/hash_registry_ex.rb
cantango-0.8.9.3 spec/cantango/configuration/shared/hash_registry_ex.rb
cantango-0.8.9.2 spec/cantango/configuration/shared/hash_registry_ex.rb
cantango-0.8.9.1 spec/cantango/configuration/shared/hash_registry_ex.rb
cantango-0.8.9 spec/cantango/configuration/shared/hash_registry_ex.rb
cantango-0.8.8.1 spec/cantango/configuration/shared/hash_registry_ex.rb
cantango-0.8.8 spec/cantango/configuration/shared/hash_registry_ex.rb
cantango-0.8.7 spec/cantango/configuration/shared/hash_registry_ex.rb
cantango-0.8.6.2 spec/cantango/configuration/shared/hash_registry_ex.rb
cantango-0.8.6.1 spec/cantango/configuration/shared/hash_registry_ex.rb
cantango-0.8.6 spec/cantango/configuration/shared/hash_registry_ex.rb