Sha256: 8003d34277943a6af2007c8c6c452f0b9035cca956001b14d23cf47b77f1fd2d

Contents?: true

Size: 1 KB

Versions: 1

Compression:

Stored size: 1 KB

Contents

module Contracts
  module Extensions
    describe HashSubsetOf do
      describe '#subset_of?' do
        context 'when the other hash is the same' do
          it 'should return true' do
            {:a => 'a'}.should be_subset_of({:a => 'a'})
          end
        end

        context 'when the other hash is a subset' do
          it 'should return true' do
            {:a => 'a'}.should be_subset_of({:a => 'a', :b => 'b'})
          end
        end

        context 'when the other hash is not a subset' do
          it 'should return false' do
            {:a => 'a'}.subset_of?({:a => 'b'}).should be_false
          end
        end
      end

      describe '#normalize_keys' do
        it 'should turn keys into downcased strings' do
          {:A => 'a'}.normalize_keys.should == {'a' => 'a'}
          {:a => 'a'}.normalize_keys.should == {'a' => 'a'}
          {'A' => 'a'}.normalize_keys.should == {'a' => 'a'}
          {'a' => 'a'}.normalize_keys.should == {'a' => 'a'}
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
contracts_api_test-0.0.1 spec/contracts/extensions_spec.rb