Sha256: 59f2cd23d6dd12bc60c73ec40ecc16b99be0d888a502c6f6619fc85d3256deb8

Contents?: true

Size: 1.64 KB

Versions: 5

Compression:

Stored size: 1.64 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 = 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 samuel before webmock prints warning" do
    output = capture_output_from_requiring %w(samuel webmock)
    output.should match(%r(Warning: WebMock was loaded after Samuel))
  end

  it "should requiring samuel after webmock does not print warning" do
    output = capture_output_from_requiring %w(webmock samuel)
    output.should be_empty
  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 was loaded after WebMock))
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
webmock-1.0.0 spec/other_net_http_libs_spec.rb
webmock-0.9.1 spec/other_net_http_libs_spec.rb
webmock-0.9.0 spec/other_net_http_libs_spec.rb
webmock-0.8.2 spec/other_net_http_libs_spec.rb
webmock-0.8.1 spec/other_net_http_libs_spec.rb