1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/spec/bundler/runtime/gem_tasks_spec.rb

79 lines
2 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
RSpec.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"
2019-12-14 05:49:16 -05:00
s.version = "1.0"
s.summary = "dummy"
s.author = "Perry Mason"
end
GEMSPEC
end
2019-12-14 05:49:16 -05:00
bundled_app("Rakefile").open("w") do |f|
f.write <<-RAKEFILE
$:.unshift("#{lib_dir}")
require "bundler/gem_tasks"
RAKEFILE
end
2019-12-14 05:49:16 -05:00
install_gemfile! <<-G
source "#{file_uri_for(gem_repo1)}"
gem "rake"
G
end
it "includes the relevant tasks" do
with_gem_path_as(Spec::Path.base_system_gems.to_s) do
sys_exec "#{rake} -T", :env => { "RUBYOPT" => opt_add("-I#{lib_dir}", ENV["RUBYOPT"]) }
end
2019-12-14 05:49:16 -05:00
expect(err).to be_empty
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)
expect(exitstatus).to eq(0) if exitstatus
end
2019-12-14 05:49:16 -05:00
it "defines a working `rake install` task" do
with_gem_path_as(Spec::Path.base_system_gems.to_s) do
sys_exec "#{rake} install", :env => { "RUBYOPT" => opt_add("-I#{lib_dir}", ENV["RUBYOPT"]) }
2019-12-14 05:49:16 -05:00
end
expect(err).to be_empty
bundle! "exec rake install"
expect(err).to be_empty
end
2020-01-08 02:11:52 -05:00
context "rake build when path has spaces" do
before do
spaced_bundled_app = tmp.join("bundled app")
FileUtils.cp_r bundled_app, spaced_bundled_app
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
it "adds 'pkg' to rake/clean's CLOBBER" do
with_gem_path_as(Spec::Path.base_system_gems.to_s) do
sys_exec! %(#{rake} -e 'load "Rakefile"; puts CLOBBER.inspect')
end
expect(out).to eq '["pkg"]'
end
end