Sha256: b4c302a343d74ceaa748e6e2ab869d6da522f8d3e66799301b880b6d571043cf

Contents?: true

Size: 896 Bytes

Versions: 5

Compression:

Stored size: 896 Bytes

Contents

require 'spec_helper'

require 'gscraper/extensions/uri'

describe "URI::QueryParams" do
  before(:each) do
    @uri = URI('http://www.test.com/page.php?x=1&y=one%20two&z')
  end

  it "should provide #query_params" do
    @uri.should respond_to(:query_params)
  end

  it "#query_params should be a Hash" do
    @uri.query_params.class.should == Hash
  end

  it "#query_params should contain params" do
    @uri.query_params.empty?.should == false
  end

  it "#query_params can contain single-word params" do
    @uri.query_params['x'].should == '1'
  end

  it "#query_params can contain multi-word params" do
    @uri.query_params['y'].should == 'one two'
  end

  it "#query_params can contain empty params" do
    @uri.query_params['z'].should be_nil
  end

  it "should update #query_params along with #query=" do
    @uri.query = 'u=3'
    @uri.query_params['u'].should == '3'
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
gscraper-0.2.0 spec/extensions/uri/query_params_spec.rb
gscraper-0.2.3 spec/extensions/uri/query_params_spec.rb
gscraper-0.2.1 spec/extensions/uri/query_params_spec.rb
gscraper-0.2.4 spec/extensions/uri/query_params_spec.rb
gscraper-0.2.2 spec/extensions/uri/query_params_spec.rb