File: cucumber_helpers.rb

package info (click to toggle)
ruby-vcr 6.0.0%2Breally5.0.0-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,320 kB
  • sloc: ruby: 8,456; sh: 177; makefile: 7
file content (39 lines) | stat: -rw-r--r-- 969 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
require "rubygems"
require "vcr"
require "support/integer_extension"

module Gem
  def self.win_platform?() false end
end unless defined?(Gem)

# pretend we're always on the internet (so that we don't have an
# internet connection dependency for our cukes)
VCR::InternetConnection.class_eval do
  def available?; true; end
end

if ENV['DATE_STRING']
  require 'timecop'
  Timecop.travel(Date.parse(ENV['DATE_STRING']))
end

def include_http_adapter_for(lib)
  require((lib =~ /faraday/) ? 'faraday' : lib)
  require 'typhoeus' if lib.include?('typhoeus') # for faraday-typhoeus
  require 'support/http_library_adapters'
  include HTTP_LIBRARY_ADAPTERS[lib]
end

def response_body_for(*args)
  get_body_string(make_http_request(*args))
end

def start_sinatra_app(&block)
  require 'sinatra/base'
  require 'support/vcr_localhost_server'
  klass = Class.new(Sinatra::Base)
  klass.disable :protection
  klass.class_eval(&block)

  VCR::LocalhostServer.new(klass.new)
end