diff options
author | Adam Prescott <adam@aprescott.com> | 2015-05-07 16:51:45 -0400 |
---|---|---|
committer | Andre Arko <andre@arko.net> | 2015-05-11 18:57:44 -0700 |
commit | e3e9f4add3ab25776c43816b916543995db8fb4e (patch) | |
tree | cac30b1aa3bde1f48fd5c0b24c3cf59c989ee2ac /spec | |
parent | 62987f84dc6d34c94956a5f4a54338abcf240e8f (diff) | |
download | bundler-e3e9f4add3ab25776c43816b916543995db8fb4e.tar.gz |
Allow bundle viz to work with dependencies satisfied by prereleases.
Suppose a Gemfile specifies a dependency, `foo`:
foo
Let's say `foo` requires a certain `bar`:
foo
bar (>= 0.5)
If this dependency happens to be satisfied by a prerelease `bar`, e.g.,
0.6.pre, then `bundle viz` will error.
The cause of this error is that `Bundler::Graph#_populate_relations`
executes
child_dependencies = dependency.to_spec.runtime_dependencies.to_set
and if `dependency` (here, `bar`), is a prerelease, then
`dependency.to_spec` will be `nil` on Rubygems 2.4.0 and higher because
of changes to `#to_spec`.
By forcing `dependency.prerelease = true`, then `to_spec` won't ignore
the prerelease `bar` dependency, which prevents `dependency.to_spec` to
from being `nil`.
This should address GitHub issues 3621 and 3217.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/commands/viz_spec.rb | 34 | ||||
-rw-r--r-- | spec/support/rubygems_ext.rb | 4 |
2 files changed, 37 insertions, 1 deletions
diff --git a/spec/commands/viz_spec.rb b/spec/commands/viz_spec.rb new file mode 100644 index 00000000..8039b055 --- /dev/null +++ b/spec/commands/viz_spec.rb @@ -0,0 +1,34 @@ +require "spec_helper" + +describe "bundle viz", :if => Bundler.which("dot") do + let(:graphviz_lib) do + graphviz_glob = base_system_gems.join("gems/ruby-graphviz*/lib") + Dir[graphviz_glob].first + end + + it "graphs gems from the Gemfile" do + install_gemfile <<-G + source "file://#{gem_repo1}" + gem "rack" + gem "rack-obama" + G + + bundle "viz", :env => {"RUBYOPT" => "-I #{graphviz_lib}"} + expect(out).to include("gem_graph.png") + end + + it "graphs gems that are prereleases" do + update_repo(gem_repo1) do + build_gem "rack", "1.3.pre" + end + + install_gemfile <<-G + source "file://#{gem_repo1}" + gem "rack", "= 1.3.pre" + gem "rack-obama" + G + + bundle "viz", :env => {"RUBYOPT" => "-I #{graphviz_lib}"} + expect(out).to include("gem_graph.png") + end +end diff --git a/spec/support/rubygems_ext.rb b/spec/support/rubygems_ext.rb index 6d71d32e..3426deff 100644 --- a/spec/support/rubygems_ext.rb +++ b/spec/support/rubygems_ext.rb @@ -12,7 +12,7 @@ module Spec unless File.exist?("#{Path.base_system_gems}") FileUtils.mkdir_p(Path.base_system_gems) - puts "fetching fakeweb, artifice, sinatra, rake, rack, and builder for the tests to use..." + puts "installing gems for the tests to use..." `gem install fakeweb artifice --no-rdoc --no-ri` `gem install sinatra --version 1.2.7 --no-rdoc --no-ri` # Rake version has to be consistent for tests to pass @@ -20,6 +20,8 @@ module Spec # 3.0.0 breaks 1.9.2 specs `gem install builder --version 2.1.2 --no-rdoc --no-ri` `gem install rack --no-rdoc --no-ri` + # ruby-graphviz is used by the viz tests + `gem install ruby-graphviz --no-rdoc --no-ri` end ENV['HOME'] = Path.home.to_s |