summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2020-01-03 10:15:15 +0100
committerDavid Rodríguez <deivid.rodriguez@riseup.net>2020-01-03 10:27:46 +0100
commit2e70a1934e65fff0b1eed36ebf2f9d83e9fbe81b (patch)
treeb68795dd4d754354093a1e8ae2da9131a2079f88
parente70d0f3d02c8c084b61969e71d1fa28a15a6d0ca (diff)
downloadbundler-2e70a1934e65fff0b1eed36ebf2f9d83e9fbe81b.tar.gz
Use standard require paths for names with dashes in specs
-rw-r--r--spec/commands/pristine_spec.rb2
-rw-r--r--spec/install/gemfile/gemspec_spec.rb2
-rw-r--r--spec/plugins/source/example_spec.rb10
-rw-r--r--spec/runtime/require_spec.rb2
-rw-r--r--spec/runtime/setup_spec.rb8
-rw-r--r--spec/support/builders.rb20
-rw-r--r--spec/support/matchers.rb4
7 files changed, 27 insertions, 21 deletions
diff --git a/spec/commands/pristine_spec.rb b/spec/commands/pristine_spec.rb
index 94ceb86e30..1c267ab78f 100644
--- a/spec/commands/pristine_spec.rb
+++ b/spec/commands/pristine_spec.rb
@@ -112,7 +112,7 @@ RSpec.describe "bundle pristine", :ruby_repo do
it "reinstall gemspec dependency" do
spec = Bundler.definition.specs["baz-dev"].first
- changed_file = Pathname.new(spec.full_gem_path).join("lib/baz-dev.rb")
+ changed_file = Pathname.new(spec.full_gem_path).join("lib/baz/dev.rb")
diff = "#Pristine spec changes"
File.open(changed_file, "a") {|f| f.puts "#Pristine spec changes" }
diff --git a/spec/install/gemfile/gemspec_spec.rb b/spec/install/gemfile/gemspec_spec.rb
index c50f8c9668..26a6235166 100644
--- a/spec/install/gemfile/gemspec_spec.rb
+++ b/spec/install/gemfile/gemspec_spec.rb
@@ -210,7 +210,7 @@ RSpec.describe "bundle install from an existing gemspec" do
build_lib("foo", :path => bundled_app)
gemspec = bundled_app("foo.gemspec").read
bundled_app("foo.gemspec").open("w") do |f|
- f.write "#{gemspec.strip}.tap { gem 'rack-obama'; require 'rack-obama' }"
+ f.write "#{gemspec.strip}.tap { gem 'rack-obama'; require 'rack/obama' }"
end
install_gemfile! <<-G
diff --git a/spec/plugins/source/example_spec.rb b/spec/plugins/source/example_spec.rb
index 64002d8f46..f2151a5a73 100644
--- a/spec/plugins/source/example_spec.rb
+++ b/spec/plugins/source/example_spec.rb
@@ -125,14 +125,14 @@ RSpec.describe "real source plugins" do
end
it "installs the gem executables" do
- build_lib "gem-with-bin" do |s|
+ build_lib "gem_with_bin" do |s|
s.executables = ["foo"]
end
install_gemfile <<-G
source "#{file_uri_for(gem_repo2)}" # plugin source
- source "#{lib_path("gem-with-bin-1.0")}", :type => :mpath do
- gem "gem-with-bin"
+ source "#{lib_path("gem_with_bin-1.0")}", :type => :mpath do
+ gem "gem_with_bin"
end
G
@@ -451,7 +451,7 @@ RSpec.describe "real source plugins" do
bundle "install"
run <<-RUBY
- require 'ma-gitp-gem'
+ require 'ma/gitp/gem'
puts "WIN" unless defined?(MAGITPGEM_PREV_REF)
RUBY
expect(out).to eq("WIN")
@@ -462,7 +462,7 @@ RSpec.describe "real source plugins" do
bundle "update ma-gitp-gem"
run <<-RUBY
- require 'ma-gitp-gem'
+ require 'ma/gitp/gem'
puts "WIN" if defined?(MAGITPGEM_PREV_REF)
RUBY
expect(out).to eq("WIN")
diff --git a/spec/runtime/require_spec.rb b/spec/runtime/require_spec.rb
index 490b8c7631..a8d7826123 100644
--- a/spec/runtime/require_spec.rb
+++ b/spec/runtime/require_spec.rb
@@ -168,7 +168,6 @@ RSpec.describe "Bundler.require" do
build_lib "jquery-rails", "1.0.0" do |s|
s.write "lib/jquery/rails.rb", "puts 'jquery/rails'"
end
- lib_path("jquery-rails-1.0.0/lib/jquery-rails.rb").rmtree
end
it "requires gem names that are namespaced" do
@@ -241,7 +240,6 @@ RSpec.describe "Bundler.require" do
build_lib "load-fuuu", "1.0.0" do |s|
s.write "lib/load/fuuu.rb", "raise LoadError.new(\"cannot load such file -- load-bar\")"
end
- lib_path("load-fuuu-1.0.0/lib/load-fuuu.rb").rmtree
gemfile <<-G
path "#{lib_path}" do
diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb
index 39240b7404..0401de6fca 100644
--- a/spec/runtime/setup_spec.rb
+++ b/spec/runtime/setup_spec.rb
@@ -899,17 +899,17 @@ end
describe "with git gems that don't have gemspecs" do
before :each do
- build_git "no-gemspec", :gemspec => false
+ build_git "no_gemspec", :gemspec => false
install_gemfile <<-G
- gem "no-gemspec", "1.0", :git => "#{lib_path("no-gemspec-1.0")}"
+ gem "no_gemspec", "1.0", :git => "#{lib_path("no_gemspec-1.0")}"
G
end
it "loads the library via a virtual spec" do
run <<-R
- require 'no-gemspec'
- puts NOGEMSPEC
+ require 'no_gemspec'
+ puts NO_GEMSPEC
R
expect(out).to eq("1.0")
diff --git a/spec/support/builders.rb b/spec/support/builders.rb
index 76c9fff463..021057cc3c 100644
--- a/spec/support/builders.rb
+++ b/spec/support/builders.rb
@@ -623,7 +623,7 @@ module Spec
unless options[:no_default]
gem_source = options[:source] || "path@#{path}"
@files = _default_files.
- merge("lib/#{name}/source.rb" => "#{Builders.constantize(name)}_SOURCE = #{gem_source.to_s.dump}").
+ merge("lib/#{entrypoint}/source.rb" => "#{Builders.constantize(name)}_SOURCE = #{gem_source.to_s.dump}").
merge(@files)
end
@@ -639,15 +639,20 @@ module Spec
end
def _default_files
- @_default_files ||= begin
- platform_string = " #{@spec.platform}" unless @spec.platform == Gem::Platform::RUBY
- { "lib/#{name}.rb" => "#{Builders.constantize(name)} = '#{version}#{platform_string}'" }
- end
+ @_default_files ||= { "lib/#{entrypoint}.rb" => "#{Builders.constantize(name)} = '#{version}#{platform_string}'" }
+ end
+
+ def entrypoint
+ name.tr("-", "/")
end
def _default_path
@context.tmp("libs", @spec.full_name)
end
+
+ def platform_string
+ " #{@spec.platform}" unless @spec.platform == Gem::Platform::RUBY
+ end
end
class GitBuilder < LibBuilder
@@ -767,7 +772,10 @@ module Spec
class PluginBuilder < GemBuilder
def _default_files
- @_default_files ||= super.merge("plugins.rb" => "")
+ @_default_files ||= {
+ "lib/#{name}.rb" => "#{Builders.constantize(name)} = '#{version}#{platform_string}'",
+ "plugins.rb" => "",
+ }
end
end
diff --git a/spec/support/matchers.rb b/spec/support/matchers.rb
index e1a08a30cc..df35854c2f 100644
--- a/spec/support/matchers.rb
+++ b/spec/support/matchers.rb
@@ -128,7 +128,7 @@ module Spec
groups << opts
@errors = names.map do |name|
name, version, platform = name.split(/\s+/)
- require_path = name == "bundler" ? "#{lib_dir}/bundler" : name
+ require_path = name == "bundler" ? "#{lib_dir}/bundler" : name.tr("-", "/")
version_const = name == "bundler" ? "Bundler::VERSION" : Spec::Builders.constantize(name)
begin
run! "require '#{require_path}.rb'; puts #{version_const}", *groups
@@ -145,7 +145,7 @@ module Spec
next unless source
begin
source_const = "#{Spec::Builders.constantize(name)}_SOURCE"
- run! "require '#{name}/source'; puts #{source_const}", *groups
+ run! "require '#{require_path}/source'; puts #{source_const}", *groups
rescue StandardError
next "#{name} does not have a source defined:\n#{indent(e)}"
end