Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Merge #7235
Browse files Browse the repository at this point in the history
7235: Spec improvements r=deivid-rodriguez a=deivid-rodriguez

This is a bunch of miscelaneous commits that fix and improve some stuff in our test suite. I could open separate PRs for them but they are so small that I figured I could compile them all on a single PR.

Co-authored-by: David Rodríguez <[email protected]>
  • Loading branch information
bundlerbot and deivid-rodriguez committed Jul 6, 2019
2 parents adf0e25 + 1bd9660 commit 6ea383f
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 29 deletions.
12 changes: 5 additions & 7 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@
$:.unshift File.expand_path("../lib", __FILE__)
require "benchmark"

RUBYGEMS_REPO = if `git -C "#{File.expand_path("..")}" remote --verbose 2> #{IO::NULL}` =~ /rubygems/i
File.expand_path("..")
else
File.expand_path("tmp/rubygems")
end

def development_dependencies
@development_dependencies ||= Gem::Specification.load("bundler.gemspec").development_dependencies
end
Expand Down Expand Up @@ -139,7 +133,11 @@ namespace :spec do
end

task "setup_co" do
ENV["RGV"] = RUBYGEMS_REPO
ENV["RGV"] = if `git -C "#{File.expand_path("..")}" remote --verbose 2> #{IO::NULL}` =~ /rubygems/i
File.expand_path("..")
else
File.expand_path("tmp/rubygems")
end
end

task "co" => "setup_co"
Expand Down
8 changes: 4 additions & 4 deletions spec/bundler/plugin/installer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
expect(spec.full_name).to eq "ga-plugin-1.0"
end

it "has expected full gem path" do
it "has expected full_gem_path" do
rev = revision_for(lib_path("ga-plugin"))
expect(result["ga-plugin"].full_gem_path).
to eq(Bundler::Plugin.root.join("bundler", "gems", "ga-plugin-#{rev[0..11]}").to_s)
Expand All @@ -89,7 +89,7 @@
expect(spec.full_name).to eq "ga-plugin-1.0"
end

it "has expected full gem path" do
it "has expected full_gem_path" do
rev = revision_for(lib_path("ga-plugin"))
expect(result["ga-plugin"].full_gem_path).
to eq(Bundler::Plugin.root.join("bundler", "gems", "ga-plugin-#{rev[0..11]}").to_s)
Expand All @@ -105,7 +105,7 @@
expect(result["re-plugin"]).to be_kind_of(Bundler::RemoteSpecification)
end

it "has expected full_gem)path" do
it "has expected full_gem_path" do
expect(result["re-plugin"].full_gem_path).
to eq(global_plugin_gem("re-plugin-1.0").to_s)
end
Expand All @@ -121,7 +121,7 @@
expect(result["ma-plugin"]).to be_kind_of(Bundler::RemoteSpecification)
end

it "has expected full_gem)path" do
it "has expected full_gem_path" do
expect(result["re-plugin"].full_gem_path).to eq(global_plugin_gem("re-plugin-1.0").to_s)
expect(result["ma-plugin"].full_gem_path).to eq(global_plugin_gem("ma-plugin-1.0").to_s)
end
Expand Down
4 changes: 1 addition & 3 deletions spec/commands/clean_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -568,9 +568,7 @@ def should_not_have_gems(*gems)
gemfile_lock.each_with_index do |line, index|
gemfile_lock[index] = line[0..(11 + 7)] if line.include?(" revision:")
end
File.open(bundled_app("Gemfile.lock"), "w") do |file|
file.print gemfile_lock.join("\n")
end
lockfile(bundled_app("Gemfile.lock"), gemfile_lock.join("\n"))

bundle "install", forgotten_command_line_options(:path => "vendor/bundle")

Expand Down
10 changes: 4 additions & 6 deletions spec/commands/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -478,12 +478,10 @@
RSpec.describe "setting gemfile via config" do
context "when only the non-default Gemfile exists" do
it "persists the gemfile location to .bundle/config" do
File.open(bundled_app("NotGemfile"), "w") do |f|
f.write <<-G
source "#{file_uri_for(gem_repo1)}"
gem 'rack'
G
end
gemfile bundled_app("NotGemfile"), <<-G
source "#{file_uri_for(gem_repo1)}"
gem 'rack'
G

bundle "config set --local gemfile #{bundled_app("NotGemfile")}"
expect(File.exist?(".bundle/config")).to eq(true)
Expand Down
5 changes: 2 additions & 3 deletions spec/commands/exec_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

bundle "exec 'cd #{tmp("gems")} && rackup'"

expect(out).to include("1.0.0")
expect(out).to eq("1.0.0")
end

it "works when exec'ing something else" do
Expand Down Expand Up @@ -453,13 +453,12 @@
it "works when unlocked" do
bundle "exec 'cd #{tmp("gems")} && rackup'"
expect(out).to eq("1.0.0")
expect(out).to include("1.0.0")
end

it "works when locked" do
expect(the_bundle).to be_locked
bundle "exec 'cd #{tmp("gems")} && rackup'"
expect(out).to include("1.0.0")
expect(out).to eq("1.0.0")
end
end

Expand Down
6 changes: 2 additions & 4 deletions spec/install/gemfile/git_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1003,10 +1003,8 @@
update_git "valim"
new_revision = revision_for(lib_path("valim-1.0"))

lockfile = File.read(bundled_app("Gemfile.lock"))
File.open(bundled_app("Gemfile.lock"), "w") do |file|
file.puts lockfile.gsub(/revision: #{old_revision}/, "revision: #{new_revision}")
end
old_lockfile = File.read(bundled_app("Gemfile.lock"))
lockfile(bundled_app("Gemfile.lock"), old_lockfile.gsub(/revision: #{old_revision}/, "revision: #{new_revision}"))

bundle "install"

Expand Down
4 changes: 3 additions & 1 deletion spec/runtime/setup_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,9 @@ def clean_load_path(lp)

ruby <<-R, :env => { "GEM_PATH" => symlinked_gem_home }, :no_lib => true
TracePoint.trace(:class) do |tp|
puts "OMG" if tp.path.include?("bundler") && !tp.path.start_with?("#{File.expand_path("../..", __dir__)}")
if tp.path.include?("bundler") && !tp.path.start_with?("#{File.expand_path("../..", __dir__)}")
puts "OMG. Defining a class from another bundler at \#{tp.path}:\#{tp.lineno}"
end
end
gem 'bundler', '#{Bundler::VERSION}'
require 'bundler/setup'
Expand Down
1 change: 0 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ def self.ruby=(ruby)
config.filter_run_excluding :ruby => RequirementChecker.against(RUBY_VERSION)
config.filter_run_excluding :rubygems => RequirementChecker.against(Gem::VERSION)
config.filter_run_excluding :git => RequirementChecker.against(git_version)
config.filter_run_excluding :rubygems_master => (ENV["RGV"] != "master")
config.filter_run_excluding :bundler => RequirementChecker.against(Bundler::VERSION.split(".")[0])
config.filter_run_excluding :ruby_repo => !(ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"]).nil?
config.filter_run_excluding :non_windows => Gem.win_platform?
Expand Down

0 comments on commit 6ea383f

Please sign in to comment.