Sha256: 23f617787b920c8c4cd98477e14442ec7e75cdd014ef1ecf8510706c9e71a510

Contents?: true

Size: 1.54 KB

Versions: 3

Compression:

Stored size: 1.54 KB

Contents

require 'rubygems'
require 'httpclient'
require 'patron' unless RUBY_PLATFORM =~ /java/

$LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'spec'
require 'spec/autorun'

require 'webmock/rspec'

require 'json'

include WebMock

def fail()
  raise_error(Spec::Expectations::ExpectationNotMetError)
end

def fail_with(message)
  raise_error(Spec::Expectations::ExpectationNotMetError, message)
end

class Proc
  def should_pass
    lambda { self.call }.should_not raise_error
  end
end

def setup_expectations_for_real_example_com_request(options = {})
  defaults = { :host => "www.example.com", :port => 80, :method => "GET",
    :path => "/",
    :response_code => 200, :response_message => "OK",
    :response_body => "<title>example</title>" }
  setup_expectations_for_real_request(defaults.merge(options))
end

def client_specific_request_string(string)
  method = string.gsub(/.*Unregistered request: ([^ ]+).+/, '\1')
  has_body = string.include?(" with body")
  default_headers = default_client_request_headers(method, has_body)
  if default_headers
    if string.include?(" with headers")
      current_headers = JSON.parse(string.gsub(/.*with headers (\{[^}]+\}).*/, '\1').gsub("=>",":").gsub("'","\""))
      default_headers = WebMock::Util::Headers.normalize_headers(default_headers)
      default_headers.merge!(current_headers)
      string.gsub!(/(.*) with headers.*/,'\1')
    end
    string << " with headers #{WebMock::Util::Headers.sorted_headers_string(default_headers)}"
  end
  string
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
webmock-1.2.0 spec/spec_helper.rb
webmock-1.1.0 spec/spec_helper.rb
webmock-1.0.0 spec/spec_helper.rb