diff options
author | Samuel Giddins <segiddins@segiddins.me> | 2016-11-18 22:09:22 -0600 |
---|---|---|
committer | Samuel Giddins <segiddins@segiddins.me> | 2016-11-18 22:09:22 -0600 |
commit | 032d71f02cc8d5d669e463c325e7e57caf35539b (patch) | |
tree | 73422b7e966e3ca598797690f94e142fbfc6eb6f | |
parent | da2dc28fc3070475a4f258cabfa4a054d0e88a37 (diff) | |
download | bundler-032d71f02cc8d5d669e463c325e7e57caf35539b.tar.gz |
Replace fakeweb in the specs with artifice
-rw-r--r-- | .rubocop_todo.yml | 1 | ||||
-rw-r--r-- | spec/install/gemfile/platform_spec.rb | 2 | ||||
-rw-r--r-- | spec/install/gems/compact_index_spec.rb | 2 | ||||
-rw-r--r-- | spec/install/gems/dependency_api_spec.rb | 2 | ||||
-rw-r--r-- | spec/spec_helper.rb | 2 | ||||
-rw-r--r-- | spec/support/artifice/endpoint.rb | 2 | ||||
-rw-r--r-- | spec/support/artifice/fail.rb | 2 | ||||
-rw-r--r-- | spec/support/artifice/windows.rb | 48 | ||||
-rw-r--r-- | spec/support/fakeweb/rack-1.0.0.marshal | 2 | ||||
-rw-r--r-- | spec/support/fakeweb/windows.rb | 27 | ||||
-rw-r--r-- | spec/support/helpers.rb | 2 | ||||
-rw-r--r-- | spec/support/rubygems_ext.rb | 2 |
12 files changed, 55 insertions, 39 deletions
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 3a23005c..f0419ed0 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -245,4 +245,3 @@ Style/UnneededInterpolation: - 'spec/commands/exec_spec.rb' - 'spec/support/artifice/endpoint.rb' - 'spec/support/artifice/endpoint_500.rb' - - 'spec/support/fakeweb/windows.rb' diff --git a/spec/install/gemfile/platform_spec.rb b/spec/install/gemfile/platform_spec.rb index 9caa0b57..ebf69f40 100644 --- a/spec/install/gemfile/platform_spec.rb +++ b/spec/install/gemfile/platform_spec.rb @@ -233,7 +233,7 @@ describe "when a gem has no architecture" do gem "rcov" G - bundle :install, :fakeweb => "windows" + bundle :install, :artifice => "windows" expect(the_bundle).to include_gems "rcov 1.0.0" end end diff --git a/spec/install/gems/compact_index_spec.rb b/spec/install/gems/compact_index_spec.rb index 001118b5..8cca7690 100644 --- a/spec/install/gems/compact_index_spec.rb +++ b/spec/install/gems/compact_index_spec.rb @@ -144,7 +144,7 @@ describe "compact index api" do gem "rcov" G - bundle! :install, :fakeweb => "windows" + bundle! :install, :artifice => "windows" expect(out).to include("Fetching source index from #{source_uri}") expect(the_bundle).to include_gems "rcov 1.0.0" end diff --git a/spec/install/gems/dependency_api_spec.rb b/spec/install/gems/dependency_api_spec.rb index a7c1aede..9d5b7400 100644 --- a/spec/install/gems/dependency_api_spec.rb +++ b/spec/install/gems/dependency_api_spec.rb @@ -124,7 +124,7 @@ describe "gemcutter's dependency API" do gem "rcov" G - bundle :install, :fakeweb => "windows" + bundle :install, :artifice => "windows" expect(out).to include("Fetching source index from #{source_uri}") expect(the_bundle).to include_gems "rcov 1.0.0" end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 642bfabc..5574c4ae 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -35,7 +35,7 @@ else end Dir["#{File.expand_path("../support", __FILE__)}/*.rb"].each do |file| - require file unless file =~ %r{fakeweb/.*\.rb} + require file unless file.end_with?("hax.rb") end $debug = false diff --git a/spec/support/artifice/endpoint.rb b/spec/support/artifice/endpoint.rb index 99ffac1c..fae72ea4 100644 --- a/spec/support/artifice/endpoint.rb +++ b/spec/support/artifice/endpoint.rb @@ -3,7 +3,7 @@ require File.expand_path("../../path.rb", __FILE__) require File.expand_path("../../../../lib/bundler/deprecate", __FILE__) include Spec::Path -# Set up pretend http gem server with FakeWeb +# Set up pretend http gem server with Artifice $LOAD_PATH.unshift "#{Dir[base_system_gems.join("gems/artifice*/lib")].first}" $LOAD_PATH.unshift "#{Dir[base_system_gems.join("gems/rack-*/lib")].first}" $LOAD_PATH.unshift "#{Dir[base_system_gems.join("gems/rack-*/lib")].last}" diff --git a/spec/support/artifice/fail.rb b/spec/support/artifice/fail.rb index e15768a3..2e29c03c 100644 --- a/spec/support/artifice/fail.rb +++ b/spec/support/artifice/fail.rb @@ -2,7 +2,7 @@ require File.expand_path("../../path.rb", __FILE__) -# Set up pretend http gem server with FakeWeb +# Set up pretend http gem server with Artifice $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 diff --git a/spec/support/artifice/windows.rb b/spec/support/artifice/windows.rb new file mode 100644 index 00000000..c18ca454 --- /dev/null +++ b/spec/support/artifice/windows.rb @@ -0,0 +1,48 @@ +# frozen_string_literal: true +require File.expand_path("../../path.rb", __FILE__) +include Spec::Path + +$LOAD_PATH.unshift Dir[base_system_gems.join("gems/artifice*/lib")].first.to_s +$LOAD_PATH.unshift(*Dir[base_system_gems.join("gems/rack-*/lib")]) +$LOAD_PATH.unshift Dir[base_system_gems.join("gems/tilt*/lib")].first.to_s +$LOAD_PATH.unshift Dir[base_system_gems.join("gems/sinatra*/lib")].first.to_s +require "artifice" +require "sinatra/base" + +Artifice.deactivate + +class Windows < Sinatra::Base + set :raise_errors, true + set :show_exceptions, false + + helpers do + def gem_repo + Pathname.new(ENV["BUNDLER_SPEC_GEM_REPO"] || Spec::Path.gem_repo1) + end + end + + files = ["specs.4.8.gz", + "prerelease_specs.4.8.gz", + "quick/Marshal.4.8/rcov-1.0-mswin32.gemspec.rz", + "gems/rcov-1.0-mswin32.gem"] + + files.each do |file| + get "/#{file}" do + File.read gem_repo.join(file) + end + end + + get "/gems/rcov-1.0-x86-mswin32.gem" do + halt 404 + end + + get "/api/v1/dependencies" do + halt 404 + end + + get "/versions" do + halt 500 + end +end + +Artifice.activate_with(Windows) diff --git a/spec/support/fakeweb/rack-1.0.0.marshal b/spec/support/fakeweb/rack-1.0.0.marshal deleted file mode 100644 index 383ce407..00000000 --- a/spec/support/fakeweb/rack-1.0.0.marshal +++ /dev/null @@ -1,2 +0,0 @@ -[{ :dependencies[[" thin" >= 0["ruby-openid"
~> 2.0.0["mongrel" >= 0["memcache-client" >= 0[" fcgi" >= 0["camping" >= 0["test-spec" >= 0:
platform" ruby: name" rack:number" -1.0.0
\ No newline at end of file diff --git a/spec/support/fakeweb/windows.rb b/spec/support/fakeweb/windows.rb deleted file mode 100644 index f1f21eed..00000000 --- a/spec/support/fakeweb/windows.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true -require File.expand_path("../../path.rb", __FILE__) -include Spec::Path - -files = ["specs.4.8.gz", - "prerelease_specs.4.8.gz", - "quick/Marshal.4.8/rcov-1.0-mswin32.gemspec.rz", - "gems/rcov-1.0-mswin32.gem"] - -# Set up pretend http gem server with FakeWeb -$LOAD_PATH.unshift "#{Dir[base_system_gems.join("gems/fakeweb*/lib")].first}" -require "fakeweb" - -FakeWeb.allow_net_connect = false - -files.each do |file| - FakeWeb.register_uri(:get, "http://localgemserver.test/#{file}", - :body => File.read("#{gem_repo1}/#{file}")) -end -FakeWeb.register_uri(:get, "http://localgemserver.test/gems/rcov-1.0-x86-mswin32.gem", - :status => ["404", "Not Found"]) - -FakeWeb.register_uri(:get, "http://localgemserver.test/api/v1/dependencies", - :status => ["404", "Not Found"]) - -FakeWeb.register_uri(:get, "http://localgemserver.test/versions", - :status => ["500", "Internal Server Error"]) diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb index 6b30afd4..3ec5d368 100644 --- a/spec/support/helpers.rb +++ b/spec/support/helpers.rb @@ -93,7 +93,6 @@ module Spec end requires = options.delete(:requires) || [] - requires << File.expand_path("../fakeweb/" + options.delete(:fakeweb) + ".rb", __FILE__) if options.key?(:fakeweb) requires << File.expand_path("../artifice/" + options.delete(:artifice) + ".rb", __FILE__) if options.key?(:artifice) requires << "support/hax" requires_str = requires.map {|r| "-r#{r}" }.join(" ") @@ -125,7 +124,6 @@ module Spec bundle_bin = File.expand_path("../../../exe/bundle_ruby", __FILE__) requires = options.delete(:requires) || [] - requires << File.expand_path("../fakeweb/" + options.delete(:fakeweb) + ".rb", __FILE__) if options.key?(:fakeweb) requires << File.expand_path("../artifice/" + options.delete(:artifice) + ".rb", __FILE__) if options.key?(:artifice) requires_str = requires.map {|r| "-r#{r}" }.join(" ") diff --git a/spec/support/rubygems_ext.rb b/spec/support/rubygems_ext.rb index e2b8c6a4..f20e051d 100644 --- a/spec/support/rubygems_ext.rb +++ b/spec/support/rubygems_ext.rb @@ -9,7 +9,7 @@ module Spec # rack 2.x requires Ruby version >= 2.2.2. # artifice doesn't support rack 2.x now. "rack" => "< 2", - "fakeweb artifice" => nil, + "artifice" => "~> 0.6.0", "compact_index" => "~> 0.11.0", "sinatra" => "1.2.7", # Rake version has to be consistent for tests to pass |