bundler 1.3.0.pre → 1.3.0.pre.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of bundler might be problematic. Click here for more details.
- data/.rspec +2 -0
- data/.travis.yml +13 -10
- data/CHANGELOG.md +15 -0
- data/CONTRIBUTING.md +13 -0
- data/ISSUES.md +8 -2
- data/README.md +12 -16
- data/Rakefile +54 -14
- data/UPGRADING.md +1 -1
- data/lib/bundler.rb +13 -10
- data/lib/bundler/cli.rb +33 -24
- data/lib/bundler/dsl.rb +5 -1
- data/lib/bundler/fetcher.rb +1 -1
- data/lib/bundler/rubygems_integration.rb +5 -0
- data/lib/bundler/runtime.rb +10 -4
- data/lib/bundler/source/git.rb +6 -3
- data/lib/bundler/source/git/git_proxy.rb +4 -2
- data/lib/bundler/source/path.rb +2 -0
- data/lib/bundler/templates/newgem/bin/newgem.tt +1 -1
- data/lib/bundler/templates/newgem/lib/newgem.rb.tt +1 -1
- data/lib/bundler/templates/newgem/newgem.gemspec.tt +1 -1
- data/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +1 -1
- data/lib/bundler/templates/newgem/test/minitest_helper.rb.tt +1 -1
- data/lib/bundler/ui.rb +4 -0
- data/lib/bundler/version.rb +1 -1
- data/spec/bundler/bundler_spec.rb +39 -9
- data/spec/bundler/dsl_spec.rb +17 -5
- data/spec/bundler/gem_helper_spec.rb +1 -1
- data/spec/cache/git_spec.rb +19 -0
- data/spec/install/gems/dependency_api_spec.rb +26 -4
- data/spec/other/config_spec.rb +12 -0
- data/spec/other/newgem_spec.rb +262 -101
- data/spec/other/show_spec.rb +9 -0
- data/spec/runtime/require_spec.rb +22 -0
- data/spec/runtime/setup_spec.rb +0 -57
- data/spec/support/builders.rb +1 -1
- data/spec/support/helpers.rb +0 -2
- metadata +28 -101
data/lib/bundler/fetcher.rb
CHANGED
@@ -201,7 +201,7 @@ module Bundler
|
|
201
201
|
# fetch from modern index: specs.4.8.gz
|
202
202
|
def fetch_all_remote_specs
|
203
203
|
@has_api = false
|
204
|
-
|
204
|
+
Bundler.rubygems.sources = ["#{@remote_uri}"]
|
205
205
|
|
206
206
|
begin
|
207
207
|
Bundler.rubygems.fetch_all_remote_specs
|
@@ -35,6 +35,11 @@ module Bundler
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def sources=(val)
|
38
|
+
# Gem.configuration creates a new Gem::ConfigFile, which by default will read ~/.gemrc
|
39
|
+
# If that file exists, its settings (including sources) will overwrite the values we
|
40
|
+
# are about to set here. In order to avoid that, we force memoizing the config file now.
|
41
|
+
configuration
|
42
|
+
|
38
43
|
Gem.sources = val
|
39
44
|
end
|
40
45
|
|
data/lib/bundler/runtime.rb
CHANGED
@@ -68,6 +68,9 @@ module Bundler
|
|
68
68
|
Kernel.require file
|
69
69
|
end
|
70
70
|
rescue LoadError => e
|
71
|
+
REGEXPS.find { |r| r =~ e.message }
|
72
|
+
raise if dep.autorequire || $1 != required_file
|
73
|
+
|
71
74
|
if dep.autorequire.nil? && dep.name.include?('-')
|
72
75
|
begin
|
73
76
|
namespaced_file = dep.name.gsub('-', '/')
|
@@ -78,9 +81,6 @@ module Bundler
|
|
78
81
|
raise if dep.autorequire || (regex_name && regex_name.gsub('-', '/') != namespaced_file)
|
79
82
|
raise e if regex_name.nil?
|
80
83
|
end
|
81
|
-
else
|
82
|
-
REGEXPS.find { |r| r =~ e.message }
|
83
|
-
raise if dep.autorequire || $1 != required_file
|
84
84
|
end
|
85
85
|
end
|
86
86
|
end
|
@@ -104,6 +104,12 @@ module Bundler
|
|
104
104
|
next if spec.name == 'bundler'
|
105
105
|
spec.source.cache(spec) if spec.source.respond_to?(:cache)
|
106
106
|
end
|
107
|
+
|
108
|
+
Dir[cache_path.join("*/.git")].each do |git_dir|
|
109
|
+
FileUtils.rm_rf(git_dir)
|
110
|
+
FileUtils.touch(File.expand_path("../.bundlecache", git_dir))
|
111
|
+
end
|
112
|
+
|
107
113
|
prune_cache unless Bundler.settings[:no_prune]
|
108
114
|
end
|
109
115
|
|
@@ -246,7 +252,7 @@ module Bundler
|
|
246
252
|
end
|
247
253
|
|
248
254
|
if cached.any?
|
249
|
-
Bundler.ui.info "Removing outdated
|
255
|
+
Bundler.ui.info "Removing outdated git and path gems from vendor/cache"
|
250
256
|
|
251
257
|
cached.each do |path|
|
252
258
|
path = File.dirname(path)
|
data/lib/bundler/source/git.rb
CHANGED
@@ -166,8 +166,11 @@ module Bundler
|
|
166
166
|
FileUtils.rm_rf(app_cache_path)
|
167
167
|
git_proxy.checkout if requires_checkout?
|
168
168
|
git_proxy.copy_to(app_cache_path, @submodules)
|
169
|
-
|
170
|
-
|
169
|
+
# Evaluate gemspecs and cache the result. Gemspecs
|
170
|
+
# in git might require git or other dependencies.
|
171
|
+
# The gemspecs we cache should already be evaluated.
|
172
|
+
spec_path = app_cache_path.join(File.basename(spec.loaded_from))
|
173
|
+
File.open(spec_path, 'wb') {|file| file.print spec.to_ruby }
|
171
174
|
end
|
172
175
|
|
173
176
|
def load_spec_files
|
@@ -264,4 +267,4 @@ module Bundler
|
|
264
267
|
end
|
265
268
|
|
266
269
|
end
|
267
|
-
end
|
270
|
+
end
|
@@ -44,7 +44,9 @@ module Bundler
|
|
44
44
|
else
|
45
45
|
Bundler.ui.info "Fetching #{uri}"
|
46
46
|
FileUtils.mkdir_p(path.dirname)
|
47
|
-
|
47
|
+
clone_command = %|clone #{uri_escaped} "#{path}" --bare --no-hardlinks|
|
48
|
+
clone_command = "#{clone_command} --quiet" if Bundler.ui.quiet?
|
49
|
+
git clone_command
|
48
50
|
end
|
49
51
|
end
|
50
52
|
|
@@ -139,4 +141,4 @@ module Bundler
|
|
139
141
|
|
140
142
|
end
|
141
143
|
end
|
142
|
-
end
|
144
|
+
end
|
data/lib/bundler/source/path.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
lib = File.expand_path('../lib', __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require '<%=config[:
|
4
|
+
require '<%=config[:namespaced_path]%>/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |gem|
|
7
7
|
gem.name = <%=config[:name].inspect%>
|
@@ -1,2 +1,2 @@
|
|
1
1
|
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
2
|
-
require '<%= config[:
|
2
|
+
require '<%= config[:namespaced_path] %>'
|
data/lib/bundler/ui.rb
CHANGED
data/lib/bundler/version.rb
CHANGED
@@ -2,5 +2,5 @@ module Bundler
|
|
2
2
|
# We're doing this because we might write tests that deal
|
3
3
|
# with other versions of bundler and we are unsure how to
|
4
4
|
# handle this better.
|
5
|
-
VERSION = "1.3.0.pre" unless defined?(::Bundler::VERSION)
|
5
|
+
VERSION = "1.3.0.pre.2" unless defined?(::Bundler::VERSION)
|
6
6
|
end
|
@@ -3,17 +3,47 @@ require 'bundler'
|
|
3
3
|
|
4
4
|
describe Bundler do
|
5
5
|
describe "#load_gemspec_uncached" do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
6
|
+
|
7
|
+
before do
|
8
|
+
@gemspec = tmp("test.gemspec")
|
9
|
+
@gemspec.open('wb') do |f|
|
10
|
+
f.write strip_whitespace(<<-GEMSPEC)
|
11
|
+
---
|
12
|
+
{:!00 ao=gu\g1= 7~f
|
13
|
+
GEMSPEC
|
12
14
|
end
|
15
|
+
end
|
13
16
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
+
describe "on Ruby 1.8", :ruby => "1.8" do
|
18
|
+
it "should catch YAML syntax errors" do
|
19
|
+
expect { Bundler.load_gemspec_uncached(@gemspec) }.
|
20
|
+
to raise_error(Bundler::GemspecError)
|
21
|
+
end
|
17
22
|
end
|
23
|
+
|
24
|
+
context "on Ruby 1.9", :ruby => "1.9" do
|
25
|
+
context "with Syck as YAML::Engine" do
|
26
|
+
it "raises a GemspecError after YAML load throws ArgumentError" do
|
27
|
+
orig_yamler, YAML::ENGINE.yamler = YAML::ENGINE.yamler, 'syck'
|
28
|
+
|
29
|
+
expect { Bundler.load_gemspec_uncached(@gemspec) }.
|
30
|
+
to raise_error(Bundler::GemspecError)
|
31
|
+
|
32
|
+
YAML::ENGINE.yamler = orig_yamler
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context "with Psych as YAML::Engine" do
|
37
|
+
it "raises a GemspecError after YAML load throws Psych::SyntaxError" do
|
38
|
+
orig_yamler, YAML::ENGINE.yamler = YAML::ENGINE.yamler, 'psych'
|
39
|
+
|
40
|
+
expect { Bundler.load_gemspec_uncached(@gemspec) }.
|
41
|
+
to raise_error(Bundler::GemspecError)
|
42
|
+
|
43
|
+
YAML::ENGINE.yamler = orig_yamler
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
18
48
|
end
|
19
49
|
end
|
data/spec/bundler/dsl_spec.rb
CHANGED
@@ -7,19 +7,31 @@ describe Bundler::Dsl do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
describe '#_normalize_options' do
|
10
|
-
it "
|
10
|
+
it "converts :github to :git" do
|
11
11
|
subject.gem("sparks", :github => "indirect/sparks")
|
12
12
|
github_uri = "git://github.com/indirect/sparks.git"
|
13
13
|
expect(subject.dependencies.first.source.uri).to eq(github_uri)
|
14
14
|
end
|
15
15
|
|
16
|
-
it "
|
16
|
+
it "converts numeric :gist to :git" do
|
17
|
+
subject.gem("not-really-a-gem", :gist => 2859988)
|
18
|
+
github_uri = "git://gist.github.com/2859988.git"
|
19
|
+
expect(subject.dependencies.first.source.uri).to eq(github_uri)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "converts :gist to :git" do
|
23
|
+
subject.gem("not-really-a-gem", :gist => "2859988")
|
24
|
+
github_uri = "git://gist.github.com/2859988.git"
|
25
|
+
expect(subject.dependencies.first.source.uri).to eq(github_uri)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "converts 'rails' to 'rails/rails'" do
|
17
29
|
subject.gem("rails", :github => "rails")
|
18
30
|
github_uri = "git://github.com/rails/rails.git"
|
19
31
|
expect(subject.dependencies.first.source.uri).to eq(github_uri)
|
20
32
|
end
|
21
33
|
|
22
|
-
it "
|
34
|
+
it "interprets slashless 'github:' value as account name" do
|
23
35
|
subject.gem("bundler", :github => "carlhuda")
|
24
36
|
github_uri = "git://github.com/carlhuda/bundler.git"
|
25
37
|
expect(subject.dependencies.first.source.uri).to eq(github_uri)
|
@@ -28,7 +40,7 @@ describe Bundler::Dsl do
|
|
28
40
|
end
|
29
41
|
|
30
42
|
describe '#method_missing' do
|
31
|
-
it '
|
43
|
+
it 'raises an error for unknown DSL methods' do
|
32
44
|
Bundler.should_receive(:read_file).with("Gemfile").and_return("unknown")
|
33
45
|
error_msg = "Undefined local variable or method `unknown'" \
|
34
46
|
" for Gemfile\\s+from Gemfile:1"
|
@@ -46,7 +58,7 @@ describe Bundler::Dsl do
|
|
46
58
|
end
|
47
59
|
|
48
60
|
describe "syntax errors" do
|
49
|
-
it "
|
61
|
+
it "raise a Bundler::GemfileError" do
|
50
62
|
gemfile "gem 'foo', :path => /unquoted/string/syntax/error"
|
51
63
|
expect { Bundler::Dsl.evaluate(bundled_app("Gemfile"), nil, true) }.
|
52
64
|
to raise_error(Bundler::GemfileError)
|
@@ -35,7 +35,7 @@ describe "Bundler::GemHelper tasks" do
|
|
35
35
|
|
36
36
|
it "handles namespaces and converting to CamelCase" do
|
37
37
|
bundle 'gem test-foo_bar'
|
38
|
-
lib = bundled_app('test-foo_bar').join('lib/test
|
38
|
+
lib = bundled_app('test-foo_bar').join('lib/test/foo_bar.rb').read
|
39
39
|
expect(lib).to include("module Test")
|
40
40
|
expect(lib).to include("module FooBar")
|
41
41
|
end
|
data/spec/cache/git_spec.rb
CHANGED
@@ -165,5 +165,24 @@ end
|
|
165
165
|
|
166
166
|
expect(out).not_to include("Your Gemfile contains path and git dependencies.")
|
167
167
|
end
|
168
|
+
|
169
|
+
it "evaluates gemspecs and writes them out" do
|
170
|
+
git = build_git "foo"
|
171
|
+
|
172
|
+
# Insert a gemspec method that shells out
|
173
|
+
spec_lines = lib_path("foo-1.0/foo.gemspec").read.split("\n")
|
174
|
+
spec_lines.insert(-2, "s.description = `echo bob`")
|
175
|
+
update_git("foo"){ |s| s.write "foo.gemspec", spec_lines.join("\n") }
|
176
|
+
|
177
|
+
install_gemfile <<-G
|
178
|
+
gem "foo", :git => '#{lib_path("foo-1.0")}'
|
179
|
+
G
|
180
|
+
bundle "#{cmd} --all"
|
181
|
+
|
182
|
+
ref = git.ref_for("master", 11)
|
183
|
+
gemspec = bundled_app("vendor/cache/foo-1.0-#{ref}/foo.gemspec").read
|
184
|
+
expect(gemspec).to_not match("`echo bob`")
|
185
|
+
end
|
186
|
+
|
168
187
|
end
|
169
188
|
end
|
@@ -216,10 +216,10 @@ describe "gemcutter's dependency API" do
|
|
216
216
|
|
217
217
|
bundle :install, :artifice => "endpoint_extra"
|
218
218
|
|
219
|
-
output =
|
220
|
-
Fetching gem metadata from http://localgemserver.test/..
|
221
|
-
Fetching gem metadata from http://localgemserver.test/extra/.
|
222
|
-
OUTPUT
|
219
|
+
output = <<-OUTPUT.gsub(/^ +/,'')
|
220
|
+
Fetching gem metadata from http://localgemserver.test/..
|
221
|
+
Fetching gem metadata from http://localgemserver.test/extra/.
|
222
|
+
OUTPUT
|
223
223
|
expect(out).to include(output)
|
224
224
|
end
|
225
225
|
|
@@ -433,4 +433,26 @@ OUTPUT
|
|
433
433
|
end
|
434
434
|
end
|
435
435
|
|
436
|
+
context ".gemrc with sources is present" do
|
437
|
+
before do
|
438
|
+
File.open(home('.gemrc'), 'w') do |file|
|
439
|
+
file.puts({:sources => ["http://rubygems.org"]}.to_yaml)
|
440
|
+
end
|
441
|
+
end
|
442
|
+
|
443
|
+
after do
|
444
|
+
home('.gemrc').rmtree
|
445
|
+
end
|
446
|
+
|
447
|
+
it "uses other sources declared in the Gemfile" do
|
448
|
+
gemfile <<-G
|
449
|
+
source "#{source_uri}"
|
450
|
+
gem 'rack'
|
451
|
+
G
|
452
|
+
|
453
|
+
bundle "install", :exitstatus => true, :artifice => "endpoint_marshal_fail"
|
454
|
+
|
455
|
+
expect(exitstatus).to eq(0)
|
456
|
+
end
|
457
|
+
end
|
436
458
|
end
|
data/spec/other/config_spec.rb
CHANGED
@@ -95,6 +95,12 @@ describe ".bundle/config" do
|
|
95
95
|
run "puts Bundler.settings[:foo]"
|
96
96
|
expect(out).to eq("global")
|
97
97
|
end
|
98
|
+
|
99
|
+
it "expands the path at time of setting" do
|
100
|
+
bundle "config --global local.foo .."
|
101
|
+
run "puts Bundler.settings['local.foo']"
|
102
|
+
expect(out).to eq(File.expand_path(Dir.pwd + "/.."))
|
103
|
+
end
|
98
104
|
end
|
99
105
|
|
100
106
|
describe "local" do
|
@@ -134,5 +140,11 @@ describe ".bundle/config" do
|
|
134
140
|
run "puts Bundler.settings[:foo]"
|
135
141
|
expect(out).to eq("local")
|
136
142
|
end
|
143
|
+
|
144
|
+
it "expands the path at time of setting" do
|
145
|
+
bundle "config --local local.foo .."
|
146
|
+
run "puts Bundler.settings['local.foo']"
|
147
|
+
expect(out).to eq(File.expand_path(Dir.pwd + "/.."))
|
148
|
+
end
|
137
149
|
end
|
138
150
|
end
|
data/spec/other/newgem_spec.rb
CHANGED
@@ -1,168 +1,329 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe "bundle gem" do
|
4
|
-
before
|
4
|
+
before do
|
5
5
|
@git_name = `git config --global user.name`.chomp
|
6
6
|
`git config --global user.name "Bundler User"`
|
7
7
|
@git_email = `git config --global user.email`.chomp
|
8
8
|
`git config --global user.email user@example.com`
|
9
|
-
bundle 'gem test-gem'
|
10
|
-
# reset gemspec cache for each test because of commit 3d4163a
|
11
|
-
Bundler.clear_gemspec_cache
|
12
9
|
end
|
13
10
|
|
14
|
-
after
|
11
|
+
after do
|
15
12
|
`git config --global user.name "#{@git_name}"`
|
16
13
|
`git config --global user.email #{@git_email}`
|
17
14
|
end
|
18
15
|
|
19
|
-
|
16
|
+
shared_examples_for "git config is present" do
|
17
|
+
context "git config user.{name,email} present" do
|
18
|
+
it "sets gemspec author to git user.name if available" do
|
19
|
+
expect(generated_gem.gemspec.authors.first).to eq("Bundler User")
|
20
|
+
end
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
expect(bundled_app("test-gem/Rakefile")).to exist
|
26
|
-
expect(bundled_app("test-gem/lib/test-gem.rb")).to exist
|
27
|
-
expect(bundled_app("test-gem/lib/test-gem/version.rb")).to exist
|
22
|
+
it "sets gemspec email to git user.email if available" do
|
23
|
+
expect(generated_gem.gemspec.email.first).to eq("user@example.com")
|
24
|
+
end
|
25
|
+
end
|
28
26
|
end
|
29
27
|
|
30
|
-
|
31
|
-
|
32
|
-
|
28
|
+
shared_examples_for "git config is absent" do |hoge|
|
29
|
+
it "sets gemspec author to default message if git user.name is not set or empty" do
|
30
|
+
expect(generated_gem.gemspec.authors.first).to eq("TODO: Write your name")
|
31
|
+
end
|
33
32
|
|
34
|
-
|
35
|
-
|
36
|
-
|
33
|
+
it "sets gemspec email to default message if git user.email is not set or empty" do
|
34
|
+
expect(generated_gem.gemspec.email.first).to eq("TODO: Write your email address")
|
35
|
+
end
|
37
36
|
end
|
38
37
|
|
39
|
-
context "
|
40
|
-
|
41
|
-
|
38
|
+
context "gem naming with underscore" do
|
39
|
+
let(:gem_name) { 'test_gem' }
|
40
|
+
|
41
|
+
before do
|
42
|
+
bundle "gem #{gem_name}"
|
43
|
+
# reset gemspec cache for each test because of commit 3d4163a
|
44
|
+
Bundler.clear_gemspec_cache
|
42
45
|
end
|
43
46
|
|
44
|
-
|
45
|
-
|
47
|
+
let(:generated_gem) { Bundler::GemHelper.new(bundled_app(gem_name).to_s) }
|
48
|
+
|
49
|
+
it "generates a gem skeleton" do
|
50
|
+
expect(bundled_app("test_gem/test_gem.gemspec")).to exist
|
51
|
+
expect(bundled_app("test_gem/LICENSE.txt")).to exist
|
52
|
+
expect(bundled_app("test_gem/Gemfile")).to exist
|
53
|
+
expect(bundled_app("test_gem/Rakefile")).to exist
|
54
|
+
expect(bundled_app("test_gem/lib/test_gem.rb")).to exist
|
55
|
+
expect(bundled_app("test_gem/lib/test_gem/version.rb")).to exist
|
46
56
|
end
|
47
|
-
end
|
48
57
|
|
49
|
-
|
50
|
-
|
51
|
-
`git config --global --unset user.name`
|
52
|
-
`git config --global --unset user.email`
|
53
|
-
reset!
|
54
|
-
in_app_root
|
55
|
-
bundle 'gem test-gem'
|
58
|
+
it "starts with version 0.0.1" do
|
59
|
+
expect(bundled_app("test_gem/lib/test_gem/version.rb").read).to match(/VERSION = "0.0.1"/)
|
56
60
|
end
|
57
61
|
|
58
|
-
it "
|
59
|
-
expect(
|
62
|
+
it "does not nest constants" do
|
63
|
+
expect(bundled_app("test_gem/lib/test_gem/version.rb").read).to match(/module TestGem/)
|
64
|
+
expect(bundled_app("test_gem/lib/test_gem.rb").read).to match(/module TestGem/)
|
60
65
|
end
|
61
66
|
|
62
|
-
|
63
|
-
|
67
|
+
it_should_behave_like "git config is present"
|
68
|
+
|
69
|
+
context "git config user.{name,email} is not set" do
|
70
|
+
before do
|
71
|
+
`git config --global --unset user.name`
|
72
|
+
`git config --global --unset user.email`
|
73
|
+
reset!
|
74
|
+
in_app_root
|
75
|
+
bundle "gem #{gem_name}"
|
76
|
+
end
|
77
|
+
|
78
|
+
it_should_behave_like "git config is absent"
|
64
79
|
end
|
65
|
-
end
|
66
80
|
|
67
|
-
|
68
|
-
|
69
|
-
|
81
|
+
it "sets gemspec license to MIT by default" do
|
82
|
+
expect(generated_gem.gemspec.license).to eq("MIT")
|
83
|
+
end
|
70
84
|
|
71
|
-
|
72
|
-
|
73
|
-
|
85
|
+
it "requires the version file" do
|
86
|
+
expect(bundled_app("test_gem/lib/test_gem.rb").read).to match(/require "test_gem\/version"/)
|
87
|
+
end
|
74
88
|
|
75
|
-
|
76
|
-
|
89
|
+
it "runs rake without problems" do
|
90
|
+
system_gems ["rake-10.0.2"]
|
77
91
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
92
|
+
rakefile = <<-RAKEFILE
|
93
|
+
task :default do
|
94
|
+
puts 'SUCCESS'
|
95
|
+
end
|
82
96
|
RAKEFILE
|
83
|
-
|
84
|
-
|
97
|
+
File.open(bundled_app("test_gem/Rakefile"), 'w') do |file|
|
98
|
+
file.puts rakefile
|
99
|
+
end
|
100
|
+
|
101
|
+
Dir.chdir(bundled_app(gem_name)) do
|
102
|
+
sys_exec("rake")
|
103
|
+
expect(out).to include("SUCCESS")
|
104
|
+
end
|
85
105
|
end
|
86
106
|
|
87
|
-
|
88
|
-
|
89
|
-
|
107
|
+
context "--bin parameter set" do
|
108
|
+
before do
|
109
|
+
reset!
|
110
|
+
in_app_root
|
111
|
+
bundle "gem #{gem_name} --bin"
|
112
|
+
end
|
113
|
+
|
114
|
+
it "builds bin skeleton" do
|
115
|
+
expect(bundled_app("test_gem/bin/test_gem")).to exist
|
116
|
+
end
|
117
|
+
|
118
|
+
it "requires 'test-gem'" do
|
119
|
+
expect(bundled_app("test_gem/bin/test_gem").read).to match(/require 'test_gem'/)
|
120
|
+
end
|
90
121
|
end
|
91
|
-
end
|
92
122
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
123
|
+
context "--test parameter set to rspec" do
|
124
|
+
before do
|
125
|
+
reset!
|
126
|
+
in_app_root
|
127
|
+
bundle "gem #{gem_name} --test=rspec"
|
128
|
+
end
|
129
|
+
|
130
|
+
it "builds spec skeleton" do
|
131
|
+
expect(bundled_app("test_gem/.rspec")).to exist
|
132
|
+
expect(bundled_app("test_gem/spec/test_gem_spec.rb")).to exist
|
133
|
+
expect(bundled_app("test_gem/spec/spec_helper.rb")).to exist
|
134
|
+
end
|
135
|
+
|
136
|
+
it "requires 'test-gem'" do
|
137
|
+
expect(bundled_app("test_gem/spec/spec_helper.rb").read).to match(/require 'test_gem'/)
|
138
|
+
end
|
139
|
+
|
140
|
+
it "creates a default test which fails" do
|
141
|
+
expect(bundled_app("test_gem/spec/test_gem_spec.rb").read).to match(/false.should be_true/)
|
142
|
+
end
|
98
143
|
end
|
99
144
|
|
100
|
-
|
101
|
-
|
145
|
+
context "--test parameter set to minitest" do
|
146
|
+
before do
|
147
|
+
reset!
|
148
|
+
in_app_root
|
149
|
+
bundle "gem #{gem_name} --test=minitest"
|
150
|
+
end
|
151
|
+
|
152
|
+
it "builds spec skeleton" do
|
153
|
+
expect(bundled_app("test_gem/test/test_test_gem.rb")).to exist
|
154
|
+
expect(bundled_app("test_gem/test/minitest_helper.rb")).to exist
|
155
|
+
end
|
156
|
+
|
157
|
+
it "requires 'test-gem'" do
|
158
|
+
expect(bundled_app("test_gem/test/minitest_helper.rb").read).to match(/require 'test_gem'/)
|
159
|
+
end
|
160
|
+
|
161
|
+
it "requires 'minitest_helper'" do
|
162
|
+
expect(bundled_app("test_gem/test/test_test_gem.rb").read).to match(/require '.\/minitest_helper'/)
|
163
|
+
end
|
164
|
+
|
165
|
+
it "creates a default test which fails" do
|
166
|
+
expect(bundled_app("test_gem/test/test_test_gem.rb").read).to match(/assert false/)
|
167
|
+
end
|
102
168
|
end
|
103
169
|
|
104
|
-
|
105
|
-
|
170
|
+
context "--test with no arguments" do
|
171
|
+
before do
|
172
|
+
reset!
|
173
|
+
in_app_root
|
174
|
+
bundle "gem #{gem_name} --test"
|
175
|
+
end
|
176
|
+
|
177
|
+
it "defaults to rspec" do
|
178
|
+
expect(bundled_app("test_gem/spec/spec_helper.rb")).to exist
|
179
|
+
expect(bundled_app("test_gem/test/minitest_helper.rb")).to_not exist
|
180
|
+
end
|
106
181
|
end
|
107
182
|
end
|
108
183
|
|
109
|
-
context "
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
bundle "gem
|
184
|
+
context "gem naming with dashed" do
|
185
|
+
let(:gem_name) { 'test-gem' }
|
186
|
+
|
187
|
+
before do
|
188
|
+
bundle "gem #{gem_name}"
|
189
|
+
# reset gemspec cache for each test because of commit 3d4163a
|
190
|
+
Bundler.clear_gemspec_cache
|
114
191
|
end
|
115
192
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
expect(bundled_app("test-gem/
|
193
|
+
let(:generated_gem) { Bundler::GemHelper.new(bundled_app(gem_name).to_s) }
|
194
|
+
|
195
|
+
it "generates a gem skeleton" do
|
196
|
+
expect(bundled_app("test-gem/test-gem.gemspec")).to exist
|
197
|
+
expect(bundled_app("test-gem/LICENSE.txt")).to exist
|
198
|
+
expect(bundled_app("test-gem/Gemfile")).to exist
|
199
|
+
expect(bundled_app("test-gem/Rakefile")).to exist
|
200
|
+
expect(bundled_app("test-gem/lib/test/gem.rb")).to exist
|
201
|
+
expect(bundled_app("test-gem/lib/test/gem/version.rb")).to exist
|
120
202
|
end
|
121
203
|
|
122
|
-
it "
|
123
|
-
expect(bundled_app("test-gem/
|
204
|
+
it "starts with version 0.0.1" do
|
205
|
+
expect(bundled_app("test-gem/lib/test/gem/version.rb").read).to match(/VERSION = "0.0.1"/)
|
124
206
|
end
|
125
207
|
|
126
|
-
it "
|
127
|
-
expect(bundled_app("test-gem/
|
208
|
+
it "nests constants so they work" do
|
209
|
+
expect(bundled_app("test-gem/lib/test/gem/version.rb").read).to match(/module Test\n module Gem/)
|
210
|
+
expect(bundled_app("test-gem/lib/test/gem.rb").read).to match(/module Test\n module Gem/)
|
128
211
|
end
|
129
|
-
end
|
130
212
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
213
|
+
it_should_behave_like "git config is present"
|
214
|
+
|
215
|
+
context "git config user.{name,email} is not set" do
|
216
|
+
before do
|
217
|
+
`git config --global --unset user.name`
|
218
|
+
`git config --global --unset user.email`
|
219
|
+
reset!
|
220
|
+
in_app_root
|
221
|
+
bundle "gem #{gem_name}"
|
222
|
+
end
|
223
|
+
|
224
|
+
it_should_behave_like "git config is absent"
|
136
225
|
end
|
137
226
|
|
138
|
-
it "
|
139
|
-
expect(
|
140
|
-
expect(bundled_app("test-gem/test/minitest_helper.rb")).to exist
|
227
|
+
it "sets gemspec license to MIT by default" do
|
228
|
+
expect(generated_gem.gemspec.license).to eq("MIT")
|
141
229
|
end
|
142
230
|
|
143
|
-
it "requires
|
144
|
-
expect(bundled_app("test-gem/test/
|
231
|
+
it "requires the version file" do
|
232
|
+
expect(bundled_app("test-gem/lib/test/gem.rb").read).to match(/require "test\/gem\/version"/)
|
145
233
|
end
|
146
234
|
|
147
|
-
it "
|
148
|
-
|
235
|
+
it "runs rake without problems" do
|
236
|
+
system_gems ["rake-10.0.2"]
|
237
|
+
|
238
|
+
rakefile = <<-RAKEFILE
|
239
|
+
task :default do
|
240
|
+
puts 'SUCCESS'
|
241
|
+
end
|
242
|
+
RAKEFILE
|
243
|
+
File.open(bundled_app("test-gem/Rakefile"), 'w') do |file|
|
244
|
+
file.puts rakefile
|
245
|
+
end
|
246
|
+
|
247
|
+
Dir.chdir(bundled_app(gem_name)) do
|
248
|
+
sys_exec("rake")
|
249
|
+
expect(out).to include("SUCCESS")
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
253
|
+
context "--bin parameter set" do
|
254
|
+
before do
|
255
|
+
reset!
|
256
|
+
in_app_root
|
257
|
+
bundle "gem #{gem_name} --bin"
|
258
|
+
end
|
259
|
+
|
260
|
+
it "builds bin skeleton" do
|
261
|
+
expect(bundled_app("test-gem/bin/test-gem")).to exist
|
262
|
+
end
|
263
|
+
|
264
|
+
it "requires 'test/gem'" do
|
265
|
+
expect(bundled_app("test-gem/bin/test-gem").read).to match(/require 'test\/gem'/)
|
266
|
+
end
|
149
267
|
end
|
150
268
|
|
151
|
-
|
152
|
-
|
269
|
+
context "--test parameter set to rspec" do
|
270
|
+
before do
|
271
|
+
reset!
|
272
|
+
in_app_root
|
273
|
+
bundle "gem #{gem_name} --test=rspec"
|
274
|
+
end
|
275
|
+
|
276
|
+
it "builds spec skeleton" do
|
277
|
+
expect(bundled_app("test-gem/.rspec")).to exist
|
278
|
+
expect(bundled_app("test-gem/spec/test/gem_spec.rb")).to exist
|
279
|
+
expect(bundled_app("test-gem/spec/spec_helper.rb")).to exist
|
280
|
+
end
|
281
|
+
|
282
|
+
it "requires 'test/gem'" do
|
283
|
+
expect(bundled_app("test-gem/spec/spec_helper.rb").read).to match(/require 'test\/gem'/)
|
284
|
+
end
|
285
|
+
|
286
|
+
it "creates a default test which fails" do
|
287
|
+
expect(bundled_app("test-gem/spec/test/gem_spec.rb").read).to match(/false.should be_true/)
|
288
|
+
end
|
153
289
|
end
|
154
|
-
end
|
155
290
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
291
|
+
context "--test parameter set to minitest" do
|
292
|
+
before do
|
293
|
+
reset!
|
294
|
+
in_app_root
|
295
|
+
bundle "gem #{gem_name} --test=minitest"
|
296
|
+
end
|
297
|
+
|
298
|
+
it "builds spec skeleton" do
|
299
|
+
expect(bundled_app("test-gem/test/test_test/gem.rb")).to exist
|
300
|
+
expect(bundled_app("test-gem/test/minitest_helper.rb")).to exist
|
301
|
+
end
|
302
|
+
|
303
|
+
it "requires 'test/gem'" do
|
304
|
+
expect(bundled_app("test-gem/test/minitest_helper.rb").read).to match(/require 'test\/gem'/)
|
305
|
+
end
|
306
|
+
|
307
|
+
it "requires 'minitest_helper'" do
|
308
|
+
expect(bundled_app("test-gem/test/test_test/gem.rb").read).to match(/require '.\/minitest_helper'/)
|
309
|
+
end
|
310
|
+
|
311
|
+
it "creates a default test which fails" do
|
312
|
+
expect(bundled_app("test-gem/test/test_test/gem.rb").read).to match(/assert false/)
|
313
|
+
end
|
161
314
|
end
|
162
315
|
|
163
|
-
|
164
|
-
|
165
|
-
|
316
|
+
context "--test with no arguments" do
|
317
|
+
before do
|
318
|
+
reset!
|
319
|
+
in_app_root
|
320
|
+
bundle "gem #{gem_name} --test"
|
321
|
+
end
|
322
|
+
|
323
|
+
it "defaults to rspec" do
|
324
|
+
expect(bundled_app("test-gem/spec/spec_helper.rb")).to exist
|
325
|
+
expect(bundled_app("test-gem/test/minitest_helper.rb")).to_not exist
|
326
|
+
end
|
166
327
|
end
|
167
328
|
end
|
168
329
|
end
|