2018-11-02 19:07:56 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-04-14 02:05:27 -04:00
|
|
|
RSpec.describe "require 'bundler/gem_tasks'" do
|
2018-11-02 19:07:56 -04:00
|
|
|
before :each do
|
|
|
|
bundled_app("foo.gemspec").open("w") do |f|
|
|
|
|
f.write <<-GEMSPEC
|
|
|
|
Gem::Specification.new do |s|
|
|
|
|
s.name = "foo"
|
2019-12-14 05:49:16 -05:00
|
|
|
s.version = "1.0"
|
|
|
|
s.summary = "dummy"
|
|
|
|
s.author = "Perry Mason"
|
2018-11-02 19:07:56 -04:00
|
|
|
end
|
|
|
|
GEMSPEC
|
|
|
|
end
|
2019-12-14 05:49:16 -05:00
|
|
|
|
2018-11-02 19:07:56 -04:00
|
|
|
bundled_app("Rakefile").open("w") do |f|
|
|
|
|
f.write <<-RAKEFILE
|
|
|
|
require "bundler/gem_tasks"
|
|
|
|
RAKEFILE
|
|
|
|
end
|
2019-12-14 05:49:16 -05:00
|
|
|
|
2020-06-03 14:46:03 -04:00
|
|
|
install_gemfile <<-G
|
2019-12-14 05:49:16 -05:00
|
|
|
source "#{file_uri_for(gem_repo1)}"
|
|
|
|
|
|
|
|
gem "rake"
|
|
|
|
G
|
2018-11-02 19:07:56 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "includes the relevant tasks" do
|
2021-12-22 19:21:36 -05:00
|
|
|
with_gem_path_as(base_system_gem_path.to_s) do
|
2020-05-21 08:05:07 -04:00
|
|
|
sys_exec "#{rake} -T", :env => { "GEM_HOME" => system_gem_path.to_s }
|
2018-11-02 19:07:56 -04:00
|
|
|
end
|
|
|
|
|
2019-12-14 05:49:16 -05:00
|
|
|
expect(err).to be_empty
|
2018-11-02 19:07:56 -04:00
|
|
|
expected_tasks = [
|
|
|
|
"rake build",
|
|
|
|
"rake clean",
|
|
|
|
"rake clobber",
|
|
|
|
"rake install",
|
|
|
|
"rake release[remote]",
|
|
|
|
]
|
|
|
|
tasks = out.lines.to_a.map {|s| s.split("#").first.strip }
|
|
|
|
expect(tasks & expected_tasks).to eq(expected_tasks)
|
|
|
|
end
|
|
|
|
|
2020-05-21 08:57:47 -04:00
|
|
|
it "defines a working `rake install` task", :ruby_repo do
|
2021-12-22 19:21:36 -05:00
|
|
|
with_gem_path_as(base_system_gem_path.to_s) do
|
2020-05-21 08:05:07 -04:00
|
|
|
sys_exec "#{rake} install", :env => { "GEM_HOME" => system_gem_path.to_s }
|
2019-12-14 05:49:16 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
expect(err).to be_empty
|
|
|
|
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle "exec rake install"
|
2019-12-14 05:49:16 -05:00
|
|
|
|
|
|
|
expect(err).to be_empty
|
|
|
|
end
|
|
|
|
|
2020-05-21 08:57:47 -04:00
|
|
|
context "rake build when path has spaces", :ruby_repo do
|
2020-01-08 02:11:52 -05:00
|
|
|
before do
|
|
|
|
spaced_bundled_app = tmp.join("bundled app")
|
2020-05-08 01:19:04 -04:00
|
|
|
FileUtils.cp_r bundled_app, spaced_bundled_app
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle "exec rake build", :dir => spaced_bundled_app
|
2020-01-08 02:11:52 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it "still runs successfully" do
|
|
|
|
expect(err).to be_empty
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-10-15 00:20:25 -04:00
|
|
|
context "rake build when path has brackets", :ruby_repo do
|
|
|
|
before do
|
|
|
|
bracketed_bundled_app = tmp.join("bundled[app")
|
|
|
|
FileUtils.cp_r bundled_app, bracketed_bundled_app
|
|
|
|
bundle "exec rake build", :dir => bracketed_bundled_app
|
|
|
|
end
|
|
|
|
|
|
|
|
it "still runs successfully" do
|
|
|
|
expect(err).to be_empty
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-05-21 08:05:07 -04:00
|
|
|
context "bundle path configured locally" do
|
|
|
|
before do
|
|
|
|
bundle "config set path vendor/bundle"
|
|
|
|
end
|
|
|
|
|
2020-05-21 08:57:47 -04:00
|
|
|
it "works", :ruby_repo do
|
2020-06-03 14:46:03 -04:00
|
|
|
install_gemfile <<-G
|
2020-05-21 08:05:07 -04:00
|
|
|
source "#{file_uri_for(gem_repo1)}"
|
|
|
|
|
|
|
|
gem "rake"
|
|
|
|
G
|
|
|
|
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle "exec rake -T"
|
2020-05-21 08:05:07 -04:00
|
|
|
|
|
|
|
expect(err).to be_empty
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-11-02 19:07:56 -04:00
|
|
|
it "adds 'pkg' to rake/clean's CLOBBER" do
|
2021-12-22 19:21:36 -05:00
|
|
|
with_gem_path_as(base_system_gem_path.to_s) do
|
2020-06-03 14:46:35 -04:00
|
|
|
sys_exec %(#{rake} -e 'load "Rakefile"; puts CLOBBER.inspect'), :env => { "GEM_HOME" => system_gem_path.to_s }
|
2018-11-02 19:07:56 -04:00
|
|
|
end
|
2019-06-01 05:49:40 -04:00
|
|
|
expect(out).to eq '["pkg"]'
|
2018-11-02 19:07:56 -04:00
|
|
|
end
|
|
|
|
end
|