summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorAndre Arko <andre@arko.net>2015-04-13 21:23:01 -0700
committerAndre Arko <andre@arko.net>2015-04-13 22:50:16 -0700
commite41edd133a737ed95581a4e850076c7160289269 (patch)
tree896f72d91172eea039efd8052dc1362ee5a05402 /spec
parent3c3d5c635c23abd43c1e2f1b72d55f6d38956119 (diff)
downloadbundler-e41edd133a737ed95581a4e850076c7160289269.tar.gz
Merge tag 'v1.9.4'
Version 1.9.4 Conflicts: lib/bundler/installer.rb lib/bundler/match_platform.rb lib/bundler/source/rubygems.rb
Diffstat (limited to 'spec')
-rw-r--r--spec/bundler/bundler_spec.rb8
-rw-r--r--spec/bundler/friendly_errors_spec.rb17
-rw-r--r--spec/bundler/gem_helper_spec.rb19
-rw-r--r--spec/commands/lock_spec.rb4
-rw-r--r--spec/commands/newgem_spec.rb30
-rw-r--r--spec/install/gems/sources_spec.rb60
-rw-r--r--spec/install/post_bundle_message_spec.rb16
-rw-r--r--spec/other/ext_spec.rb16
-rw-r--r--spec/quality_spec.rb2
-rw-r--r--spec/runtime/gem_tasks_spec.rb35
-rw-r--r--spec/support/builders.rb13
11 files changed, 195 insertions, 25 deletions
diff --git a/spec/bundler/bundler_spec.rb b/spec/bundler/bundler_spec.rb
index f26183e073..fa226002cc 100644
--- a/spec/bundler/bundler_spec.rb
+++ b/spec/bundler/bundler_spec.rb
@@ -17,13 +17,11 @@ describe Bundler do
end
end
- context "on Ruby 1.8", :ruby => "1.8" do
- it "catches YAML syntax errors" do
- expect { subject }.to raise_error(Bundler::GemspecError)
- end
+ it "catches YAML syntax errors" do
+ expect { subject }.to raise_error(Bundler::GemspecError)
end
- context "on Ruby 1.9", :ruby => "1.9", :if => defined?(YAML::ENGINE) do
+ context "on Rubies with a settable YAML engine", :if => defined?(YAML::ENGINE) do
context "with Syck as YAML::Engine" do
it "raises a GemspecError after YAML load throws ArgumentError" do
orig_yamler, YAML::ENGINE.yamler = YAML::ENGINE.yamler, 'syck'
diff --git a/spec/bundler/friendly_errors_spec.rb b/spec/bundler/friendly_errors_spec.rb
index 96c333a739..ee0667cb2f 100644
--- a/spec/bundler/friendly_errors_spec.rb
+++ b/spec/bundler/friendly_errors_spec.rb
@@ -10,4 +10,21 @@ describe Bundler, "friendly errors" do
end
}.to raise_error(SystemExit)
end
+
+ describe "#issues_url" do
+ it "generates a search URL for the exception message" do
+ exception = Exception.new("Exception message")
+
+ expect(Bundler.issues_url(exception)).to eq("https://github.com/bundler/bundler/search?q=Exception+message&type=Issues")
+ end
+
+ it "generates a search URL for only the first line of a multi-line exception message" do
+ exception = Exception.new(<<END)
+First line of the exception message
+Second line of the exception message
+END
+
+ expect(Bundler.issues_url(exception)).to eq("https://github.com/bundler/bundler/search?q=First+line+of+the+exception+message&type=Issues")
+ end
+ end
end
diff --git a/spec/bundler/gem_helper_spec.rb b/spec/bundler/gem_helper_spec.rb
index 2b0f3d97aa..8cfacbac01 100644
--- a/spec/bundler/gem_helper_spec.rb
+++ b/spec/bundler/gem_helper_spec.rb
@@ -28,6 +28,15 @@ describe Bundler::GemHelper do
end
context "interpolates the name" do
+ before do
+ # Remove exception that prevents public pushes on older RubyGems versions
+ if Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.0")
+ content = File.read(app_gemspec_path)
+ content.sub!(/raise "RubyGems 2\.0 or newer.*/, "")
+ File.open(app_gemspec_path, "w"){|f| f.write(content) }
+ end
+ end
+
it "when there is only one gemspec" do
expect(subject.gemspec.name).to eq(app_name)
end
@@ -62,7 +71,7 @@ describe Bundler::GemHelper do
let(:app_version) { "0.1.0" }
let(:app_gem_dir) { app_path.join("pkg") }
let(:app_gem_path) { app_gem_dir.join("#{app_name}-#{app_version}.gem") }
- let(:app_gemspec_content) { File.read(app_gemspec_path) }
+ let(:app_gemspec_content) { remove_push_guard(File.read(app_gemspec_path)) }
before(:each) do
content = app_gemspec_content.gsub("TODO: ", "")
@@ -70,6 +79,14 @@ describe Bundler::GemHelper do
File.open(app_gemspec_path, "w") { |file| file << content }
end
+ def remove_push_guard(gemspec_content)
+ # Remove exception that prevents public pushes on older RubyGems versions
+ if Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.0")
+ gemspec_content.sub!(/raise "RubyGems 2\.0 or newer.*/, "")
+ end
+ gemspec_content
+ end
+
it "uses a shell UI for output" do
expect(Bundler.ui).to be_a(Bundler::UI::Shell)
end
diff --git a/spec/commands/lock_spec.rb b/spec/commands/lock_spec.rb
index 4545b8ce7f..07d92fb6cf 100644
--- a/spec/commands/lock_spec.rb
+++ b/spec/commands/lock_spec.rb
@@ -49,7 +49,7 @@ describe "bundle lock" do
with_license
BUNDLED WITH
- 1.9.1
+ #{Bundler::VERSION}
L
end
@@ -84,7 +84,7 @@ describe "bundle lock" do
it "does not fetch remote specs when using the --local option" do
bundle "lock --update --local"
- expect(out).to include("in the gems available on this machine.")
+ expect(out).to include("available on this machine.")
end
it "writes to a custom location using --lockfile" do
diff --git a/spec/commands/newgem_spec.rb b/spec/commands/newgem_spec.rb
index ef653d306d..b28a9f4f02 100644
--- a/spec/commands/newgem_spec.rb
+++ b/spec/commands/newgem_spec.rb
@@ -7,6 +7,15 @@ describe "bundle gem" do
global_config "BUNDLE_GEM__MIT" => "false", "BUNDLE_GEM__TEST" => "false", "BUNDLE_GEM__COC" => "false"
end
+ def remove_push_guard(gem_name)
+ # Remove exception that prevents public pushes on older RubyGems versions
+ if Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.0")
+ path = "#{gem_name}/#{gem_name}.gemspec"
+ content = File.read(path).sub(/raise "RubyGems 2\.0 or newer.*/, "")
+ File.open(path, "w"){|f| f.write(content) }
+ end
+ end
+
before do
@git_name = `git config --global user.name`.chomp
`git config --global user.name "Bundler User"`
@@ -48,7 +57,6 @@ describe "bundle gem" do
bundle "gem newgem --bin"
process_file(bundled_app('newgem', "newgem.gemspec")) do |line|
- next line unless line =~ /TODO/
# Simulate replacing TODOs with real values
case line
when /spec\.metadata\['allowed_push_host'\]/, /spec\.homepage/
@@ -57,6 +65,9 @@ describe "bundle gem" do
line.gsub(/\=.*$/, "= %q{A short summary of my new gem.}")
when /spec\.description/
line.gsub(/\=.*$/, "= %q{A longer description of my new gem.}")
+ # Remove exception that prevents public pushes on older RubyGems versions
+ when /raise "RubyGems 2.0 or newer/
+ line.gsub(/.*/, '') if Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.0")
else
line
end
@@ -112,6 +123,7 @@ describe "bundle gem" do
before do
bundle "gem #{gem_name}"
+ remove_push_guard(gem_name)
# reset gemspec cache for each test because of commit 3d4163a
Bundler.clear_gemspec_cache
end
@@ -125,6 +137,11 @@ describe "bundle gem" do
expect(bundled_app("test_gem/lib/test_gem.rb")).to exist
expect(bundled_app("test_gem/lib/test_gem/version.rb")).to exist
expect(bundled_app("test_gem/.gitignore")).to exist
+
+ expect(bundled_app("test_gem/bin/setup")).to exist
+ expect(bundled_app("test_gem/bin/console")).to exist
+ expect(bundled_app("test_gem/bin/setup")).to be_executable
+ expect(bundled_app("test_gem/bin/console")).to be_executable
end
it "starts with version 0.1.0" do
@@ -145,6 +162,7 @@ describe "bundle gem" do
reset!
in_app_root
bundle "gem #{gem_name}"
+ remove_push_guard(gem_name)
end
it_should_behave_like "git config is absent"
@@ -152,7 +170,7 @@ describe "bundle gem" do
it "sets gemspec metadata['allowed_push_host']", :rubygems => "2.0" do
expect(generated_gem.gemspec.metadata['allowed_push_host']).
- to match("delete to allow pushes to any server")
+ to match(/mygemserver\.com/)
end
it "requires the version file" do
@@ -318,6 +336,7 @@ describe "bundle gem" do
before do
bundle "gem #{gem_name} --mit"
+ remove_push_guard(gem_name)
# reset gemspec cache for each test because of commit 3d4163a
Bundler.clear_gemspec_cache
end
@@ -359,6 +378,7 @@ describe "bundle gem" do
before do
bundle "gem #{gem_name}"
+ remove_push_guard(gem_name)
# reset gemspec cache for each test because of commit 3d4163a
Bundler.clear_gemspec_cache
end
@@ -392,16 +412,12 @@ describe "bundle gem" do
reset!
in_app_root
bundle "gem #{gem_name}"
+ remove_push_guard(gem_name)
end
it_should_behave_like "git config is absent"
end
- it "sets gemspec metadata['allowed_push_host']", :rubygems => "2.0" do
- expect(generated_gem.gemspec.metadata['allowed_push_host']).
- to match("delete to allow pushes to any server")
- end
-
it "requires the version file" do
expect(bundled_app("test-gem/lib/test/gem.rb").read).to match(/require "test\/gem\/version"/)
end
diff --git a/spec/install/gems/sources_spec.rb b/spec/install/gems/sources_spec.rb
index cca00a914d..45e3a43e5d 100644
--- a/spec/install/gems/sources_spec.rb
+++ b/spec/install/gems/sources_spec.rb
@@ -319,4 +319,64 @@ describe "bundle install with gems on multiple sources" do
should_be_installed("rack 1.0.0")
end
end
+
+ context "when a single source contains multiple locked gems" do
+ before do
+ # 1. With these gems,
+ build_repo4 do
+ build_gem "foo", "0.1"
+ build_gem "bar", "0.1"
+ end
+
+ # 2. Installing this gemfile will produce...
+ gemfile <<-G
+ source 'file://#{gem_repo1}'
+ gem 'rack'
+ gem 'foo', '~> 0.1', :source => 'file://#{gem_repo4}'
+ gem 'bar', '~> 0.1', :source => 'file://#{gem_repo4}'
+ G
+
+ # 3. this lockfile.
+ lockfile <<-L
+ GEM
+ remote: file:/Users/andre/src/bundler/bundler/tmp/gems/remote1/
+ remote: file:/Users/andre/src/bundler/bundler/tmp/gems/remote4/
+ specs:
+ bar (0.1)
+ foo (0.1)
+ rack (1.0.0)
+
+ PLATFORMS
+ ruby
+
+ DEPENDENCIES
+ bar (~> 0.1)!
+ foo (~> 0.1)!
+ rack
+ L
+
+ bundle "install --path ../gems/system"
+
+ # 4. Then we add some new versions...
+ update_repo4 do
+ build_gem "foo", "0.2"
+ build_gem "bar", "0.3"
+ end
+ end
+
+ it "allows them to be unlocked separately" do
+ # 5. and install this gemfile, updating only foo.
+ install_gemfile <<-G
+ source 'file://#{gem_repo1}'
+ gem 'rack'
+ gem 'foo', '~> 0.2', :source => 'file://#{gem_repo4}'
+ gem 'bar', '~> 0.1', :source => 'file://#{gem_repo4}'
+ G
+
+ # 6. Which should update foo to 0.2, but not the (locked) bar 0.1
+ should_be_installed("foo 0.2")
+ should_be_installed("bar 0.1")
+ end
+ end
+
end
diff --git a/spec/install/post_bundle_message_spec.rb b/spec/install/post_bundle_message_spec.rb
index 78133d9283..408e518894 100644
--- a/spec/install/post_bundle_message_spec.rb
+++ b/spec/install/post_bundle_message_spec.rb
@@ -81,6 +81,22 @@ describe "post bundle message" do
expect(out).to include(bundle_complete_message)
end
end
+
+ describe "with misspelled or non-existent gem name" do
+ before :each do
+ gemfile <<-G
+ source 'https://rubygems.org/'
+ gem "rails"
+ gem "misspelled-gem-name", :group => :development
+ G
+ end
+
+ it "should report a helpufl error message" do
+ bundle :install
+ expect(out).to include("Fetching gem metadata from https://rubygems.org/")
+ expect(out).to include("Could not find gem 'misspelled-gem-name (>= 0) ruby' in any of the gem sources listed in your Gemfile or installed on this machine.")
+ end
+ end
end
describe "for second bundle install run" do
diff --git a/spec/other/ext_spec.rb b/spec/other/ext_spec.rb
index cbee163771..dca6c80a59 100644
--- a/spec/other/ext_spec.rb
+++ b/spec/other/ext_spec.rb
@@ -5,6 +5,14 @@ describe "Gem::Specification#match_platform" do
darwin = gem "lol", "1.0", "platform_specific-1.0-x86-darwin-10"
expect(darwin.match_platform(pl('java'))).to eq(false)
end
+
+ context "when platform is a string" do
+ it "matches when platform is a string" do
+ lazy_spec = Bundler::LazySpecification.new("lol", "1.0", "universal-mingw32")
+ expect(lazy_spec.match_platform(pl('x86-mingw32'))).to eq(true)
+ expect(lazy_spec.match_platform(pl('x64-mingw32'))).to eq(true)
+ end
+ end
end
describe "Bundler::GemHelpers#generic" do
@@ -49,12 +57,12 @@ describe "Gem::SourceIndex#refresh!" do
end
it "does not explode when called", :if => rubygems_1_7 do
- run "Gem.source_index.refresh!"
- run "Gem::SourceIndex.new([]).refresh!"
+ run "Gem.source_index.refresh!", :expect_err => true
+ run "Gem::SourceIndex.new([]).refresh!", :expect_err => true
end
it "does not explode when called", :unless => rubygems_1_7 do
- run "Gem.source_index.refresh!"
- run "Gem::SourceIndex.from_gems_in([]).refresh!"
+ run "Gem.source_index.refresh!", :expect_err => true
+ run "Gem::SourceIndex.from_gems_in([]).refresh!", :expect_err => true
end
end
diff --git a/spec/quality_spec.rb b/spec/quality_spec.rb
index 79d3e0bd2a..b84e543670 100644
--- a/spec/quality_spec.rb
+++ b/spec/quality_spec.rb
@@ -97,7 +97,7 @@ describe "The library itself" do
end
end
- expect(@err.split("\n").reject { |f| f =~ %r{(lib|\.)/bundler/vendor} }).to eq([])
+ expect(@err.split("\n")).to eq([])
expect(@out).to eq("")
end
end
diff --git a/spec/runtime/gem_tasks_spec.rb b/spec/runtime/gem_tasks_spec.rb
new file mode 100644
index 0000000000..5124b05a3c
--- /dev/null
+++ b/spec/runtime/gem_tasks_spec.rb
@@ -0,0 +1,35 @@
+require "spec_helper"
+
+describe "require 'bundler/gem_tasks'" do
+ before :each do
+ bundled_app("foo.gemspec").open("w") do |f|
+ f.write <<-GEMSPEC
+ Gem::Specification.new do |s|
+ s.name = "foo"
+ end
+ GEMSPEC
+ end
+ bundled_app("Rakefile").open("w") do |f|
+ f.write <<-RAKEFILE
+ $:.unshift("#{bundler_path}")
+ require "bundler/gem_tasks"
+ RAKEFILE
+ end
+ end
+
+ it "includes the relevant tasks" do
+ with_gem_path_as(Spec::Path.base_system_gems.to_s) do
+ sys_exec "ruby -S rake -T"
+ end
+
+ expect(err).to eq("")
+ expected_tasks = [
+ "rake build",
+ "rake install",
+ "rake release",
+ ]
+ tasks = out.lines.to_a.map { |s| s.split('#').first.strip }
+ expect(tasks & expected_tasks).to eq(expected_tasks)
+ expect(exitstatus).to eq(0) if exitstatus
+ end
+end
diff --git a/spec/support/builders.rb b/spec/support/builders.rb
index 5490a2b976..1a1c916779 100644
--- a/spec/support/builders.rb
+++ b/spec/support/builders.rb
@@ -260,12 +260,15 @@ module Spec
FileUtils.rm_rf Dir[gem_repo3("prerelease*")]
end
- # A repo that has no pre-installed gems included. (The caller completely determines the contents with the block)
- def build_repo4(&blk)
+ # A repo that has no pre-installed gems included. (The caller completely
+ # determines the contents with the block.)
+ def build_repo4
FileUtils.rm_rf gem_repo4
- build_repo(gem_repo4) do
- yield if block_given?
- end
+ build_repo(gem_repo4) { yield }
+ end
+
+ def update_repo4
+ update_repo(gem_repo4) { yield }
end
def update_repo2