Sha256: 4084f1d4141e2ae315a51fcafeb01097fb54931baee1e25fc9452f456073cc11

Contents?: true

Size: 1.59 KB

Versions: 20

Compression:

Stored size: 1.59 KB

Contents

require 'spec_helper'

describe ActiveRestClient::ConnectionManager do
  before(:each) do
    ActiveRestClient::ConnectionManager.reset!
  end

  it "should have a get_connection method" do
    expect(ActiveRestClient::ConnectionManager).to respond_to("get_connection")
  end

  it "should return a connection for a given base url" do
    connection = ActiveRestClient::ConnectionManager.get_connection("http://www.example.com")
    expect(connection).to be_kind_of(ActiveRestClient::Connection)
  end

  it "should return the same connection for each base url when re-requested" do
    connection = ActiveRestClient::ConnectionManager.get_connection("http://www.example.com")
    expect(ActiveRestClient::ConnectionManager.get_connection("http://www.example.com")).to eq(connection)
  end

  it "should return different connections for each base url when requested" do
    base_url = "http://www.example.com"
    other_base_url = "http://other.example.com"
    expect(ActiveRestClient::ConnectionManager.get_connection(base_url).base_url).to eq(base_url)
    expect(ActiveRestClient::ConnectionManager.get_connection(other_base_url).base_url).to eq(other_base_url)
    expect(Thread.current[:_connections].size).to eq(2)
  end

  it "should find a connection if you pass in URLs containing an existing connection's base_url" do
    base_url         = "http://www.example.com"
    connection       = ActiveRestClient::ConnectionManager.get_connection(base_url)
    found_connection = ActiveRestClient::ConnectionManager.find_connection_for_url("#{base_url}:8080/people/test")
    expect(found_connection).to eq(connection)
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
active_rest_client-1.0.9 spec/lib/connection_manager_spec.rb
active_rest_client-1.0.8 spec/lib/connection_manager_spec.rb
active_rest_client-1.0.7 spec/lib/connection_manager_spec.rb
active_rest_client-1.0.6 spec/lib/connection_manager_spec.rb
active_rest_client-1.0.5 spec/lib/connection_manager_spec.rb
active_rest_client-1.0.4 spec/lib/connection_manager_spec.rb
active_rest_client-1.0.3 spec/lib/connection_manager_spec.rb
active_rest_client-1.0.2 spec/lib/connection_manager_spec.rb
active_rest_client-1.0.1 spec/lib/connection_manager_spec.rb
active_rest_client-1.0.0 spec/lib/connection_manager_spec.rb
active_rest_client-0.9.75 spec/lib/connection_manager_spec.rb
active_rest_client-0.9.73 spec/lib/connection_manager_spec.rb
active_rest_client-0.9.72 spec/lib/connection_manager_spec.rb
active_rest_client-0.9.71 spec/lib/connection_manager_spec.rb
active_rest_client-0.9.70 spec/lib/connection_manager_spec.rb
active_rest_client-0.9.69 spec/lib/connection_manager_spec.rb
active_rest_client-0.9.68 spec/lib/connection_manager_spec.rb
active_rest_client-0.9.67 spec/lib/connection_manager_spec.rb
active_rest_client-0.9.66 spec/lib/connection_manager_spec.rb
active_rest_client-0.9.65 spec/lib/connection_manager_spec.rb