Sha256: 312a6600e33f26d0dfd0317741c34c39f754f39fc859da1df5dc6b252037da79

Contents?: true

Size: 1.34 KB

Versions: 13

Compression:

Stored size: 1.34 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

describe "loading other Net::HTTP based libraries" do

  def capture_output_from_requiring(libs, additional_code = "")
    requires = libs.map { |lib| "require '#{lib}'" }
    requires << " require 'addressable/uri'"
    requires << " require 'crack'"
    requires = requires.join("; ")
    webmock_dir = "#{File.dirname(__FILE__)}/../lib"
    vendor_dirs = Dir["#{File.dirname(__FILE__)}/vendor/*/lib"]
    load_path_opts = vendor_dirs.unshift(webmock_dir).map { |dir| "-I#{dir}" }.join(" ")

    # TODO: use the same Ruby executable that this test was invoked with
    `ruby #{load_path_opts} -e "#{requires}; #{additional_code}" 2>&1 | cat`
  end

  it "should requiring right http connection before webmock and then connecting does not print warning" do
    additional_code = "Net::HTTP.start('example.com')"
    output = capture_output_from_requiring %w(right_http_connection webmock), additional_code
    output.should be_empty
  end

  it "should requiring right http connection after webmock and then connecting prints warning" do
    additional_code = "Net::HTTP.start('example.com')"
    output = capture_output_from_requiring %w(webmock right_http_connection), additional_code
    output.should match(%r(Warning: RightHttpConnection has to be required before WebMock is required !!!))
  end

end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
vanity-1.7.1 vendor/ruby/1.9.1/gems/webmock-1.6.4/spec/other_net_http_libs_spec.rb
webmock-1.6.4 spec/other_net_http_libs_spec.rb
webmock-1.6.2 spec/other_net_http_libs_spec.rb
webmock-1.6.1 spec/other_net_http_libs_spec.rb
webmock-1.6.0 spec/other_net_http_libs_spec.rb
webmock-1.5.0 spec/other_net_http_libs_spec.rb
webmock-1.4.0 spec/other_net_http_libs_spec.rb
webmock-1.3.5 spec/other_net_http_libs_spec.rb
webmock-1.3.4 spec/other_net_http_libs_spec.rb
webmock-1.3.3 spec/other_net_http_libs_spec.rb
webmock-1.3.2 spec/other_net_http_libs_spec.rb
webmock-1.3.1 spec/other_net_http_libs_spec.rb
webmock-1.3.0 spec/other_net_http_libs_spec.rb