spec/unit/pacto/extensions_spec.rb in pacto-0.3.0.pre vs spec/unit/pacto/extensions_spec.rb in pacto-0.3.0

- old
+ new

@@ -1,33 +1,24 @@ module Pacto module Extensions describe HashSubsetOf do - describe '#subset_of?' do - context 'when the other hash is the same' do - it 'returns true' do - expect({:a => 'a'}).to be_subset_of({:a => 'a'}) - end + describe '#normalize_keys' do + it 'turns keys into downcased strings' do + expect({:A => 'a'}.normalize_keys).to eq('a' => 'a') + expect({:a => 'a'}.normalize_keys).to eq('a' => 'a') + expect({'A' => 'a'}.normalize_keys).to eq('a' => 'a') + expect({'a' => 'a'}.normalize_keys).to eq('a' => 'a') end - - context 'when the other hash is a subset' do - it 'returns true' do - expect({:a => 'a'}).to be_subset_of({:a => 'a', :b => 'b'}) - end - end - - context 'when the other hash is not a subset' do - it 'returns false' do - expect({:a => 'a'}.subset_of?({:a => 'b'})).to be_false - end - end end - describe '#normalize_keys' do - it 'turns keys into downcased strings' do - expect({:A => 'a'}.normalize_keys).to eq({'a' => 'a'}) - expect({:a => 'a'}.normalize_keys).to eq({'a' => 'a'}) - expect({'A' => 'a'}.normalize_keys).to eq({'a' => 'a'}) - expect({'a' => 'a'}.normalize_keys).to eq({'a' => 'a'}) + describe '#normalize_header_keys' do + it 'matches headers to the style in the RFC documentation' do + expect(Pacto::Extensions.normalize_header_keys(:'user-agent' => 'a')).to eq('User-Agent' => 'a') # rubocop:disable SymbolName + expect(Pacto::Extensions.normalize_header_keys(:user_agent => 'a')).to eq('User-Agent' => 'a') + expect(Pacto::Extensions.normalize_header_keys('User-Agent' => 'a')).to eq('User-Agent' => 'a') + expect(Pacto::Extensions.normalize_header_keys('user-agent' => 'a')).to eq('User-Agent' => 'a') + expect(Pacto::Extensions.normalize_header_keys('user_agent' => 'a')).to eq('User-Agent' => 'a') + expect(Pacto::Extensions.normalize_header_keys('USER_AGENT' => 'a')).to eq('User-Agent' => 'a') end end end end end