Sha256: c85c0eac94cd6a913f28720e97a7cf359c93456b44a195d884bba5a306e45dcb

Contents?: true

Size: 816 Bytes

Versions: 13

Compression:

Stored size: 816 Bytes

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper.rb')
require 'yajl/http_stream'
require 'socket'

describe "Passing options to HttpStream instance methods" do
  before(:all) do
    @stream = Yajl::HttpStream.new
  end

  it "should not create a new socket it one is provided" do
    TCPSocket.should_not_receive(:new)
    options = {:socket => :my_provided_socket}

    @stream.send(:initialize_socket, URI.parse("http://google.com"), options)

    options[:socket].should == :my_provided_socket
  end

  it "should create a new socket if one is not provided" do
    TCPSocket.should_receive(:new).with("google.com", 80).and_return( :tcp_socket )
    options = {}

    @stream.send(:initialize_socket, URI.parse("http://google.com"), options)

    options[:socket].should == :tcp_socket
  end
end

Version data entries

13 entries across 13 versions & 4 rubygems

Version Path
yajl-ruby-1.2.3 spec/http/http_stream_options_spec.rb
yajl-ruby-1.2.2 spec/http/http_stream_options_spec.rb
tdiary-4.2.1 vendor/bundle/ruby/2.2.0/gems/yajl-ruby-1.2.1/spec/http/http_stream_options_spec.rb
yajl-ruby-1.2.1 spec/http/http_stream_options_spec.rb
yajl-ruby-1.2.0 spec/http/http_stream_options_spec.rb
yajl-ruby-zenjoy-1.1.0 spec/http/http_stream_options_spec.rb
yajl-ruby-maglev--1.1.0 spec/http/http_stream_options_spec.rb
yajl-ruby-1.1.0-x86-mswin32-60 spec/http/http_stream_options_spec.rb
yajl-ruby-1.1.0-x86-mingw32 spec/http/http_stream_options_spec.rb
yajl-ruby-1.1.0 spec/http/http_stream_options_spec.rb
yajl-ruby-1.0.0-x86-mswin32-60 spec/http/http_stream_options_spec.rb
yajl-ruby-1.0.0-x86-mingw32 spec/http/http_stream_options_spec.rb
yajl-ruby-1.0.0 spec/http/http_stream_options_spec.rb