Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

unit spec for query mapper examples

  • Loading branch information...
commit a85ca8bb3155d3cae5cc8aa89d4fa16fe85dc2dd 1 parent e89d0ec
@JonRowe JonRowe authored
Showing with 30 additions and 0 deletions.
  1. +30 −0 spec/unit/util/query_mapper_spec.rb
View
30 spec/unit/util/query_mapper_spec.rb
@@ -0,0 +1,30 @@
+require 'spec_helper'
+
+describe WebMock::Util::QueryMapper do
+ let(:query_mapper) { described_class }
+
+ it "converts query to values" do
+ query = "key=value&other_key=other_value"
+ values = { 'key' => 'value', 'other_key' => 'other_value' }
+ expect(query_mapper.query_to_values query).to eq values
+ end
+
+ it 'converts values to a query string' do
+ query = "key=value&other_key=other_value"
+ values = [['key','value'],['other_key','other_value']]
+ expect(query_mapper.values_to_query values).to eq query
+ end
+
+ it 'converts values with missing keys to a query string' do
+ query = "=value"
+ values = { '' => 'value' }
+ expect(query_mapper.values_to_query values).to eq query
+ end
+
+ it 'converts values with nil keys to a query string' do
+ query = "=value"
+ values = { nil => 'value' }
+ expect(query_mapper.values_to_query values).to eq query
+ end
+
+end
Please sign in to comment.
Something went wrong with that request. Please try again.