Sha256: a17ec6c0b9364125ba6960beed445cedf85289a3d637b603786be243a4dbf3dd

Contents?: true

Size: 1.86 KB

Versions: 44

Compression:

Stored size: 1.86 KB

Contents

require File.join(File.dirname(__FILE__), "test_helper")

class TestFakeWebQueryString < Test::Unit::TestCase

  def test_register_uri_string_with_query_params
    FakeWeb.register_uri(:get, 'http://example.com/?a=1&b=1', :body => 'foo')
    assert FakeWeb.registered_uri?(:get, 'http://example.com/?a=1&b=1')

    FakeWeb.register_uri(:post, URI.parse("http://example.org/?a=1&b=1"), :body => "foo")
    assert FakeWeb.registered_uri?(:post, "http://example.org/?a=1&b=1")
  end

  def test_register_uri_with_query_params_and_check_in_different_order
    FakeWeb.register_uri(:get, 'http://example.com/?a=1&b=1', :body => 'foo')
    assert FakeWeb.registered_uri?(:get, 'http://example.com/?b=1&a=1')

    FakeWeb.register_uri(:post, URI.parse('http://example.org/?a=1&b=1'), :body => 'foo')
    assert FakeWeb.registered_uri?(:post, 'http://example.org/?b=1&a=1')
  end

  def test_registered_uri_gets_recognized_with_empty_query_params
    FakeWeb.register_uri(:get, 'http://example.com/', :body => 'foo')
    assert FakeWeb.registered_uri?(:get, 'http://example.com/?')

    FakeWeb.register_uri(:post, URI.parse('http://example.org/'), :body => 'foo')
    assert FakeWeb.registered_uri?(:post, 'http://example.org/?')
  end

  def test_register_uri_with_empty_query_params_and_check_with_none
    FakeWeb.register_uri(:get, 'http://example.com/?', :body => 'foo')
    assert FakeWeb.registered_uri?(:get, 'http://example.com/')

    FakeWeb.register_uri(:post, URI.parse('http://example.org/?'), :body => 'foo')
    assert FakeWeb.registered_uri?(:post, 'http://example.org/')
  end

  def test_registry_sort_query_params
    assert_equal "a=1&b=2", FakeWeb::Registry.instance.send(:sort_query_params, "b=2&a=1")
  end

  def test_registry_sort_query_params_sorts_by_value_if_keys_collide
    assert_equal "a=1&a=2&b=2", FakeWeb::Registry.instance.send(:sort_query_params, "a=2&b=2&a=1")
  end

end

Version data entries

44 entries across 44 versions & 8 rubygems

Version Path
auser-poolparty-1.3.0 vendor/gems/fakeweb/test/test_query_string.rb
auser-poolparty-1.3.1 vendor/gems/fakeweb/test/test_query_string.rb
auser-poolparty-1.3.10 vendor/gems/fakeweb/test/test_query_string.rb
auser-poolparty-1.3.11 vendor/gems/fakeweb/test/test_query_string.rb
auser-poolparty-1.3.12 vendor/gems/fakeweb/test/test_query_string.rb
auser-poolparty-1.3.13 vendor/gems/fakeweb/test/test_query_string.rb
auser-poolparty-1.3.14 vendor/gems/fakeweb/test/test_query_string.rb
auser-poolparty-1.3.15 vendor/gems/fakeweb/test/test_query_string.rb
auser-poolparty-1.3.16 vendor/gems/fakeweb/test/test_query_string.rb
auser-poolparty-1.3.17 vendor/gems/fakeweb/test/test_query_string.rb
auser-poolparty-1.3.2 vendor/gems/fakeweb/test/test_query_string.rb
auser-poolparty-1.3.3 vendor/gems/fakeweb/test/test_query_string.rb
auser-poolparty-1.3.4 vendor/gems/fakeweb/test/test_query_string.rb
auser-poolparty-1.3.5 vendor/gems/fakeweb/test/test_query_string.rb
auser-poolparty-1.3.6 vendor/gems/fakeweb/test/test_query_string.rb
auser-poolparty-1.3.7 vendor/gems/fakeweb/test/test_query_string.rb
auser-poolparty-1.3.8 vendor/gems/fakeweb/test/test_query_string.rb
benschwarz-smoke-0.5.0 vendor/fakeweb/test/test_query_string.rb
benschwarz-smoke-0.5.1 vendor/fakeweb/test/test_query_string.rb
benschwarz-smoke-0.5.2 vendor/fakeweb-1.2.5/test/test_query_string.rb