summaryrefslogtreecommitdiff
path: root/spec/support/artifice/fail.rb
blob: 9443d953e1ae69b68033cf3ba7a4811960b13ab2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# frozen_string_literal: true

require File.expand_path("../../path.rb", __FILE__)

# Set up pretend http gem server with FakeWeb
$LOAD_PATH.unshift Dir[Spec::Path.base_system_gems.join("gems/artifice*/lib")].first.to_s
$LOAD_PATH.unshift Dir[Spec::Path.base_system_gems.join("gems/rack-*/lib")].first.to_s
$LOAD_PATH.unshift Dir[Spec::Path.base_system_gems.join("gems/rack-*/lib")].last.to_s
$LOAD_PATH.unshift Dir[Spec::Path.base_system_gems.join("gems/tilt*/lib")].first.to_s
require "artifice"

class Fail
  def call(env)
    raise(exception(env))
  end

  def exception(env)
    Object.const_get(ENV.fetch("BUNDLER_SPEC_EXCEPTION") { "Errno::ENETUNREACH" }).new("host down: Bundler spec artifice fail! #{env["PATH_INFO"]}")
  end
end
Artifice.activate_with(Fail.new)