spec/query_spec.rb in relax-0.0.4 vs spec/query_spec.rb in relax-0.0.5
- old
+ new
@@ -21,11 +21,11 @@
end
it 'should escape its values using "+" instead of "%20"' do
Relax::Query.send(:escape_value, 'two words').should == 'two+words'
end
-
+
it 'should sort its parameters' do
@query[:charlie] = 3
@query[:alpha] = 1
@query[:bravo] = 2
@query.to_s.should eql('alpha=1&bravo=2&charlie=3')
@@ -39,7 +39,22 @@
it 'should be able to parse query strings' do
parsed_query = Relax::Query.parse(@uri)
parsed_query[:action].should eql('search')
parsed_query[:query].should eql('keyword')
+ end
+
+ it 'should parse key value pairs into only two parts' do
+ parsed_query = Relax::Query.parse(URI.parse("http://example.com/?action=test=&foo=bar"))
+ parsed_query[:action].should eql('test=')
+ end
+
+ it 'should unescape query string key-value pair keys' do
+ parsed_query = Relax::Query.parse(URI.parse("http://example.com/?action%20helper=test"))
+ parsed_query[:"action helper"].should eql('test')
+ end
+
+ it 'should unescape query string key-value pair values' do
+ parsed_query = Relax::Query.parse(URI.parse("http://example.com/?action=test%20action"))
+ parsed_query[:action].should eql('test action')
end
end