bundler 1.6.0.pre.1 → 1.6.0.pre.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of bundler might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -3
- data/Rakefile +12 -7
- data/lib/bundler.rb +3 -3
- data/lib/bundler/cli.rb +36 -619
- data/lib/bundler/cli/binstubs.rb +36 -0
- data/lib/bundler/cli/cache.rb +34 -0
- data/lib/bundler/cli/check.rb +35 -0
- data/lib/bundler/cli/clean.rb +19 -0
- data/lib/bundler/cli/common.rb +54 -0
- data/lib/bundler/cli/config.rb +84 -0
- data/lib/bundler/cli/console.rb +42 -0
- data/lib/bundler/cli/exec.rb +37 -0
- data/lib/bundler/cli/gem.rb +61 -0
- data/lib/bundler/cli/init.rb +33 -0
- data/lib/bundler/cli/inject.rb +33 -0
- data/lib/bundler/cli/install.rb +123 -0
- data/lib/bundler/cli/open.rb +25 -0
- data/lib/bundler/cli/outdated.rb +80 -0
- data/lib/bundler/cli/package.rb +36 -0
- data/lib/bundler/cli/platform.rb +43 -0
- data/lib/bundler/cli/show.rb +44 -0
- data/lib/bundler/cli/update.rb +73 -0
- data/lib/bundler/cli/viz.rb +27 -0
- data/lib/bundler/dsl.rb +46 -26
- data/lib/bundler/fetcher.rb +50 -4
- data/lib/bundler/installer.rb +1 -1
- data/lib/bundler/parallel_workers/worker.rb +1 -1
- data/lib/bundler/remote_specification.rb +1 -1
- data/lib/bundler/resolver.rb +30 -18
- data/lib/bundler/source/git.rb +0 -4
- data/lib/bundler/source/git/git_proxy.rb +2 -2
- data/lib/bundler/source/rubygems.rb +1 -14
- data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +1 -1
- data/lib/bundler/vendor/thor/base.rb +1 -1
- data/lib/bundler/version.rb +1 -1
- data/spec/bundler/bundler_spec.rb +46 -47
- data/spec/bundler/{cli_rspec.rb → cli_spec.rb} +0 -1
- data/spec/bundler/definition_spec.rb +3 -7
- data/spec/bundler/dsl_spec.rb +43 -21
- data/spec/bundler/gem_helper_spec.rb +152 -123
- data/spec/bundler/retry_spec.rb +6 -7
- data/spec/bundler/settings_spec.rb +0 -2
- data/spec/bundler/source_spec.rb +4 -4
- data/spec/commands/newgem_spec.rb +7 -7
- data/spec/commands/outdated_spec.rb +11 -0
- data/spec/install/gems/dependency_api_spec.rb +41 -0
- data/spec/install/gems/simple_case_spec.rb +1 -17
- data/spec/other/ext_spec.rb +1 -1
- data/spec/support/artifice/endpoint_strict_basic_authentication.rb +18 -0
- data/spec/support/builders.rb +43 -42
- data/spec/support/permissions.rb +0 -1
- data/spec/update/gems_spec.rb +11 -0
- metadata +51 -30
@@ -110,7 +110,7 @@ class Thor
|
|
110
110
|
end
|
111
111
|
|
112
112
|
# Whenever a class inherits from Thor or Thor::Group, we should track the
|
113
|
-
# class and the file on Thor::Base. This is the method
|
113
|
+
# class and the file on Thor::Base. This is the method responsible for it.
|
114
114
|
#
|
115
115
|
def register_klass_file(klass) #:nodoc:
|
116
116
|
file = caller[1].match(/(.*):\d+/)[1]
|
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.6.0.pre.
|
5
|
+
VERSION = "1.6.0.pre.2" unless defined?(::Bundler::VERSION)
|
6
6
|
end
|
@@ -4,71 +4,70 @@ require 'bundler'
|
|
4
4
|
|
5
5
|
describe Bundler do
|
6
6
|
describe "#load_gemspec_uncached" do
|
7
|
+
let(:app_gemspec_path) { tmp("test.gemspec") }
|
8
|
+
subject { Bundler.load_gemspec_uncached(app_gemspec_path) }
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
context "with incorrect YAML file" do
|
11
|
+
before do
|
12
|
+
File.open(app_gemspec_path, "wb") do |f|
|
13
|
+
f.write strip_whitespace(<<-GEMSPEC)
|
14
|
+
---
|
15
|
+
{:!00 ao=gu\g1= 7~f
|
16
|
+
GEMSPEC
|
17
|
+
end
|
15
18
|
end
|
16
|
-
end
|
17
19
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
20
|
+
context "on Ruby 1.8", :ruby => "1.8" do
|
21
|
+
it "catches YAML syntax errors" do
|
22
|
+
expect { subject }.to raise_error(Bundler::GemspecError)
|
23
|
+
end
|
22
24
|
end
|
23
|
-
end
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
context "on Ruby 1.9", :ruby => "1.9" do
|
27
|
+
context "with Syck as YAML::Engine" do
|
28
|
+
it "raises a GemspecError after YAML load throws ArgumentError" do
|
29
|
+
orig_yamler, YAML::ENGINE.yamler = YAML::ENGINE.yamler, 'syck'
|
29
30
|
|
30
|
-
|
31
|
-
to raise_error(Bundler::GemspecError)
|
31
|
+
expect { subject }.to raise_error(Bundler::GemspecError)
|
32
32
|
|
33
|
-
|
33
|
+
YAML::ENGINE.yamler = orig_yamler
|
34
|
+
end
|
34
35
|
end
|
35
|
-
end
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
context "with Psych as YAML::Engine" do
|
38
|
+
it "raises a GemspecError after YAML load throws Psych::SyntaxError" do
|
39
|
+
orig_yamler, YAML::ENGINE.yamler = YAML::ENGINE.yamler, 'psych'
|
40
40
|
|
41
|
-
|
42
|
-
to raise_error(Bundler::GemspecError)
|
41
|
+
expect { subject }.to raise_error(Bundler::GemspecError)
|
43
42
|
|
44
|
-
|
43
|
+
YAML::ENGINE.yamler = orig_yamler
|
44
|
+
end
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
end
|
49
|
+
context "with correct YAML file" do
|
50
|
+
it "can load a gemspec with unicode characters with default ruby encoding" do
|
51
|
+
# spec_helper forces the external encoding to UTF-8 but that's not the
|
52
|
+
# ruby default.
|
53
|
+
if defined?(Encoding)
|
54
|
+
encoding = Encoding.default_external
|
55
|
+
Encoding.default_external = "ASCII"
|
56
|
+
end
|
58
57
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
58
|
+
File.open(app_gemspec_path, "wb") do |file|
|
59
|
+
file.puts <<-GEMSPEC.gsub(/^\s+/, '')
|
60
|
+
# -*- encoding: utf-8 -*-
|
61
|
+
Gem::Specification.new do |gem|
|
62
|
+
gem.author = "André the Giant"
|
63
|
+
end
|
64
|
+
GEMSPEC
|
65
|
+
end
|
67
66
|
|
68
|
-
|
69
|
-
expect(gemspec.author).to eq("André the Giant")
|
67
|
+
expect(subject.author).to eq("André the Giant")
|
70
68
|
|
71
|
-
|
69
|
+
Encoding.default_external = encoding if defined?(Encoding)
|
70
|
+
end
|
72
71
|
end
|
73
72
|
|
74
73
|
end
|
@@ -3,23 +3,19 @@ require 'bundler/definition'
|
|
3
3
|
|
4
4
|
describe Bundler::Definition do
|
5
5
|
before do
|
6
|
-
Bundler.
|
6
|
+
allow(Bundler).to receive(:settings){ Bundler::Settings.new(".") }
|
7
7
|
end
|
8
8
|
|
9
9
|
describe "#lock" do
|
10
10
|
context "when it's not possible to write to the file" do
|
11
11
|
subject{ Bundler::Definition.new(nil, [], [], []) }
|
12
12
|
|
13
|
-
before do
|
14
|
-
File.should_receive(:open).with("Gemfile.lock", "wb").
|
15
|
-
and_raise(Errno::EACCES)
|
16
|
-
end
|
17
|
-
|
18
13
|
it "raises an InstallError with explanation" do
|
14
|
+
expect(File).to receive(:open).with("Gemfile.lock", "wb").
|
15
|
+
and_raise(Errno::EACCES)
|
19
16
|
expect{ subject.lock("Gemfile.lock") }.
|
20
17
|
to raise_error(Bundler::InstallError)
|
21
18
|
end
|
22
19
|
end
|
23
20
|
end
|
24
|
-
|
25
21
|
end
|
data/spec/bundler/dsl_spec.rb
CHANGED
@@ -3,38 +3,60 @@ require 'spec_helper'
|
|
3
3
|
describe Bundler::Dsl do
|
4
4
|
before do
|
5
5
|
@rubygems = double("rubygems")
|
6
|
-
Bundler::Source::Rubygems.
|
6
|
+
allow(Bundler::Source::Rubygems).to receive(:new){ @rubygems }
|
7
7
|
end
|
8
8
|
|
9
|
-
describe "#
|
10
|
-
it "
|
11
|
-
subject.
|
12
|
-
|
13
|
-
|
9
|
+
describe "#register_host" do
|
10
|
+
it "registers custom hosts" do
|
11
|
+
subject.git_source(:example){ |repo_name| "git@git.example.com:#{repo_name}.git" }
|
12
|
+
subject.git_source(:foobar){ |repo_name| "git@foobar.com:#{repo_name}.git" }
|
13
|
+
subject.gem("dobry-pies", :example => "strzalek/dobry-pies")
|
14
|
+
example_uri = "git@git.example.com:strzalek/dobry-pies.git"
|
15
|
+
expect(subject.dependencies.first.source.uri).to eq(example_uri)
|
14
16
|
end
|
15
17
|
|
16
|
-
it "
|
17
|
-
|
18
|
-
|
19
|
-
|
18
|
+
it "raises expection on invalid hostname" do
|
19
|
+
expect {
|
20
|
+
subject.git_source(:group){ |repo_name| "git@git.example.com:#{repo_name}.git" }
|
21
|
+
}.to raise_error(Bundler::InvalidOption)
|
20
22
|
end
|
21
23
|
|
22
|
-
it "
|
23
|
-
subject.
|
24
|
-
github_uri = "https://gist.github.com/2859988.git"
|
25
|
-
expect(subject.dependencies.first.source.uri).to eq(github_uri)
|
24
|
+
it "expects block passed" do
|
25
|
+
expect{ subject.git_source(:example) }.to raise_error(Bundler::InvalidOption)
|
26
26
|
end
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
context "default hosts (git, gist)" do
|
29
|
+
it "converts :github to :git" do
|
30
|
+
subject.gem("sparks", :github => "indirect/sparks")
|
31
|
+
github_uri = "git://github.com/indirect/sparks.git"
|
32
|
+
expect(subject.dependencies.first.source.uri).to eq(github_uri)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "converts numeric :gist to :git" do
|
36
|
+
subject.gem("not-really-a-gem", :gist => 2859988)
|
37
|
+
github_uri = "https://gist.github.com/2859988.git"
|
38
|
+
expect(subject.dependencies.first.source.uri).to eq(github_uri)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "converts :gist to :git" do
|
42
|
+
subject.gem("not-really-a-gem", :gist => "2859988")
|
43
|
+
github_uri = "https://gist.github.com/2859988.git"
|
44
|
+
expect(subject.dependencies.first.source.uri).to eq(github_uri)
|
45
|
+
end
|
46
|
+
|
47
|
+
it "converts 'rails' to 'rails/rails'" do
|
48
|
+
subject.gem("rails", :github => "rails")
|
49
|
+
github_uri = "git://github.com/rails/rails.git"
|
50
|
+
expect(subject.dependencies.first.source.uri).to eq(github_uri)
|
51
|
+
end
|
32
52
|
end
|
33
53
|
end
|
34
54
|
|
35
55
|
describe "#method_missing" do
|
36
56
|
it "raises an error for unknown DSL methods" do
|
37
|
-
Bundler.
|
57
|
+
expect(Bundler).to receive(:read_file).with("Gemfile").
|
58
|
+
and_return("unknown")
|
59
|
+
|
38
60
|
error_msg = "Undefined local variable or method `unknown'" \
|
39
61
|
" for Gemfile\\s+from Gemfile:1"
|
40
62
|
expect { subject.eval_gemfile("Gemfile") }.
|
@@ -44,7 +66,7 @@ describe Bundler::Dsl do
|
|
44
66
|
|
45
67
|
describe "#eval_gemfile" do
|
46
68
|
it "handles syntax errors with a useful message" do
|
47
|
-
Bundler.
|
69
|
+
expect(Bundler).to receive(:read_file).with("Gemfile").and_return("}")
|
48
70
|
expect { subject.eval_gemfile("Gemfile") }.
|
49
71
|
to raise_error(Bundler::GemfileError, /Gemfile syntax error/)
|
50
72
|
end
|
@@ -54,7 +76,7 @@ describe Bundler::Dsl do
|
|
54
76
|
it "will raise a Bundler::GemfileError" do
|
55
77
|
gemfile "gem 'foo', :path => /unquoted/string/syntax/error"
|
56
78
|
expect { Bundler::Dsl.evaluate(bundled_app("Gemfile"), nil, true) }.
|
57
|
-
to raise_error(Bundler::GemfileError)
|
79
|
+
to raise_error(Bundler::GemfileError, /Gemfile syntax error/)
|
58
80
|
end
|
59
81
|
end
|
60
82
|
end
|
@@ -2,194 +2,223 @@ require "spec_helper"
|
|
2
2
|
require 'rake'
|
3
3
|
require 'bundler/gem_helper'
|
4
4
|
|
5
|
-
describe
|
5
|
+
describe Bundler::GemHelper do
|
6
|
+
let(:app_name) { "test" }
|
7
|
+
let(:app_path) { bundled_app app_name }
|
8
|
+
let(:app_gemspec_path) { app_path.join("#{app_name}.gemspec") }
|
9
|
+
|
10
|
+
before(:each) do
|
11
|
+
bundle "gem #{app_name}"
|
12
|
+
end
|
13
|
+
|
6
14
|
context "determining gemspec" do
|
7
|
-
|
8
|
-
bundle 'gem test'
|
9
|
-
app = bundled_app("test")
|
10
|
-
helper = Bundler::GemHelper.new(app.to_s)
|
11
|
-
expect(helper.gemspec.name).to eq('test')
|
12
|
-
end
|
15
|
+
subject { Bundler::GemHelper.new(app_path) }
|
13
16
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
expect(helper.gemspec.name).to eq('test')
|
20
|
-
end
|
17
|
+
context "fails" do
|
18
|
+
it "when there is no gemspec" do
|
19
|
+
FileUtils.rm app_gemspec_path
|
20
|
+
expect { subject }.to raise_error(/Unable to determine name/)
|
21
|
+
end
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
expect { Bundler::GemHelper.new(app.to_s) }.to raise_error(/Unable to determine name/)
|
23
|
+
it "when there are two gemspecs and the name isn't specified" do
|
24
|
+
FileUtils.touch app_path.join("#{app_name}-2.gemspec")
|
25
|
+
expect { subject }.to raise_error(/Unable to determine name/)
|
26
|
+
end
|
27
27
|
end
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
29
|
+
context "interpolates the name" do
|
30
|
+
it "when there is only one gemspec" do
|
31
|
+
expect(subject.gemspec.name).to eq(app_name)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "for a hidden gemspec" do
|
35
|
+
FileUtils.mv app_gemspec_path, app_path.join(".gemspec")
|
36
|
+
expect(subject.gemspec.name).to eq(app_name)
|
37
|
+
end
|
34
38
|
end
|
35
39
|
|
36
|
-
it "handles namespaces and
|
37
|
-
bundle
|
38
|
-
|
39
|
-
|
40
|
+
it "handles namespaces and converts them to CamelCase" do
|
41
|
+
bundle "gem #{app_name}-foo_bar"
|
42
|
+
app_path = bundled_app "#{app_name}-foo_bar"
|
43
|
+
|
44
|
+
lib = app_path.join("lib/#{app_name}/foo_bar.rb").read
|
45
|
+
expect(lib).to include("module #{app_name.capitalize}")
|
40
46
|
expect(lib).to include("module FooBar")
|
41
47
|
end
|
42
48
|
end
|
43
49
|
|
44
50
|
context "gem management" do
|
45
51
|
def mock_confirm_message(message)
|
46
|
-
Bundler.ui.
|
52
|
+
expect(Bundler.ui).to receive(:confirm).with(message)
|
47
53
|
end
|
48
54
|
|
49
|
-
def mock_build_message
|
50
|
-
|
55
|
+
def mock_build_message(name, version)
|
56
|
+
message = "#{name} #{version} built to pkg/#{name}-#{version}.gem."
|
57
|
+
mock_confirm_message message
|
51
58
|
end
|
52
59
|
|
60
|
+
subject! { Bundler::GemHelper.new(app_path) }
|
61
|
+
let(:app_version) { "0.0.1" }
|
62
|
+
let(:app_gem_dir) { app_path.join("pkg") }
|
63
|
+
let(:app_gem_path) { app_gem_dir.join("#{app_name}-#{app_version}.gem") }
|
64
|
+
let(:app_gemspec_content) { File.read(app_gemspec_path) }
|
65
|
+
|
53
66
|
before(:each) do
|
54
|
-
|
55
|
-
|
56
|
-
@gemspec = File.read("#{@app.to_s}/test.gemspec")
|
57
|
-
File.open("#{@app.to_s}/test.gemspec", 'w'){|f| f << @gemspec.gsub('TODO: ', '') }
|
58
|
-
@helper = Bundler::GemHelper.new(@app.to_s)
|
67
|
+
content = app_gemspec_content.gsub("TODO: ", "")
|
68
|
+
File.open(app_gemspec_path, "w") { |file| file << content }
|
59
69
|
end
|
60
70
|
|
61
71
|
it "uses a shell UI for output" do
|
62
72
|
expect(Bundler.ui).to be_a(Bundler::UI::Shell)
|
63
73
|
end
|
64
74
|
|
65
|
-
describe "
|
75
|
+
describe "#install" do
|
76
|
+
let!(:rake_application) { Rake.application }
|
77
|
+
|
66
78
|
before(:each) do
|
67
|
-
|
79
|
+
Rake.application = Rake::Application.new
|
68
80
|
end
|
69
81
|
|
70
82
|
after(:each) do
|
71
|
-
Rake.application =
|
83
|
+
Rake.application = rake_application
|
72
84
|
end
|
73
85
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
names.each { |name|
|
78
|
-
expect { Rake.application[name] }.to raise_error(/Don't know how to build task/)
|
79
|
-
}
|
86
|
+
context "defines Rake tasks" do
|
87
|
+
let(:task_names) { %w[build install release] }
|
80
88
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
89
|
+
context "before installation" do
|
90
|
+
it "raises an error with appropriate message" do
|
91
|
+
task_names.each do |name|
|
92
|
+
expect { Rake.application[name] }.
|
93
|
+
to raise_error("Don't know how to build task '#{name}'")
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
88
97
|
|
89
|
-
|
90
|
-
|
91
|
-
|
98
|
+
context "after installation" do
|
99
|
+
before do
|
100
|
+
subject.install
|
101
|
+
end
|
102
|
+
|
103
|
+
it "adds Rake tasks successfully" do
|
104
|
+
task_names.each do |name|
|
105
|
+
expect { Rake.application[name] }.not_to raise_error
|
106
|
+
expect(Rake.application[name]).to be_instance_of Rake::Task
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
it "provides a way to access the gemspec object" do
|
111
|
+
expect(subject.gemspec.name).to eq(app_name)
|
112
|
+
end
|
113
|
+
end
|
92
114
|
end
|
93
115
|
end
|
94
116
|
|
95
|
-
describe "
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
117
|
+
describe "#build_gem" do
|
118
|
+
context "when build failed" do
|
119
|
+
it "raises an error with appropriate message" do
|
120
|
+
# break the gemspec by adding back the TODOs
|
121
|
+
File.open(app_gemspec_path, "w"){ |file| file << app_gemspec_content }
|
122
|
+
expect { subject.build_gem }.to raise_error(/TODO/)
|
123
|
+
end
|
100
124
|
end
|
101
125
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
126
|
+
context "when build was successful" do
|
127
|
+
it "creates .gem file" do
|
128
|
+
mock_build_message app_name, app_version
|
129
|
+
subject.build_gem
|
130
|
+
expect(app_gem_path).to exist
|
131
|
+
end
|
106
132
|
end
|
107
133
|
end
|
108
134
|
|
109
|
-
describe "
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
135
|
+
describe "#install_gem" do
|
136
|
+
context "when installation was successful" do
|
137
|
+
it "gem is installed" do
|
138
|
+
mock_build_message app_name, app_version
|
139
|
+
mock_confirm_message "#{app_name} (#{app_version}) installed."
|
140
|
+
subject.install_gem
|
141
|
+
expect(app_gem_path).to exist
|
142
|
+
expect(`gem list`).to include("#{app_name} (#{app_version})")
|
143
|
+
end
|
116
144
|
end
|
117
145
|
|
118
|
-
|
119
|
-
|
120
|
-
#
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
146
|
+
context "when installation fails" do
|
147
|
+
it "raises an error with appropriate message" do
|
148
|
+
# create empty gem file in order to simulate install failure
|
149
|
+
allow(subject).to receive(:build_gem) do
|
150
|
+
FileUtils.mkdir_p(app_gem_dir)
|
151
|
+
FileUtils.touch app_gem_path
|
152
|
+
app_gem_path
|
153
|
+
end
|
154
|
+
expect { subject.install_gem }.to raise_error(/Couldn't install gem/)
|
125
155
|
end
|
126
|
-
expect { @helper.install_gem }.to raise_error
|
127
156
|
end
|
128
157
|
end
|
129
158
|
|
130
|
-
describe "
|
159
|
+
describe "#release_gem" do
|
131
160
|
before do
|
132
|
-
Dir.chdir(
|
161
|
+
Dir.chdir(app_path) do
|
133
162
|
`git init`
|
134
163
|
`git config user.email "you@example.com"`
|
135
164
|
`git config user.name "name"`
|
136
165
|
end
|
137
166
|
end
|
138
167
|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
%x{cd test; git add .}
|
145
|
-
expect { @helper.release_gem }.to raise_error(/files that need to be committed/)
|
146
|
-
end
|
168
|
+
context "fails" do
|
169
|
+
it "when there are unstaged files" do
|
170
|
+
expect { subject.release_gem }.
|
171
|
+
to raise_error("There are files that need to be committed first.")
|
172
|
+
end
|
147
173
|
|
148
|
-
|
149
|
-
|
174
|
+
it "when there are uncommitted files" do
|
175
|
+
Dir.chdir(app_path) { `git add .` }
|
176
|
+
expect { subject.release_gem }.
|
177
|
+
to raise_error("There are files that need to be committed first.")
|
178
|
+
end
|
150
179
|
|
151
|
-
|
152
|
-
|
180
|
+
it "when there is no git remote" do
|
181
|
+
# silence messages
|
182
|
+
allow(Bundler.ui).to receive(:confirm)
|
183
|
+
allow(Bundler.ui).to receive(:error)
|
153
184
|
|
154
|
-
|
185
|
+
Dir.chdir(app_path) { `git commit -a -m "initial commit"` }
|
186
|
+
expect { subject.release_gem }.to raise_error
|
187
|
+
end
|
155
188
|
end
|
156
189
|
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
190
|
+
context "succeeds" do
|
191
|
+
before do
|
192
|
+
Dir.chdir(gem_repo1) { `git init --bare` }
|
193
|
+
Dir.chdir(app_path) do
|
194
|
+
`git remote add origin file://#{gem_repo1}`
|
195
|
+
`git commit -a -m "initial commit"`
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
it "on releasing" do
|
200
|
+
mock_build_message app_name, app_version
|
201
|
+
mock_confirm_message "Tagged v#{app_version}."
|
202
|
+
mock_confirm_message "Pushed git commits and tags."
|
203
|
+
expect(subject).to receive(:rubygem_push).with(app_gem_path.to_s)
|
161
204
|
|
162
|
-
|
205
|
+
Dir.chdir(app_path) { sys_exec("git push origin master", true) }
|
163
206
|
|
164
|
-
|
165
|
-
Dir.chdir(@app) do
|
166
|
-
`git remote add origin file://#{gem_repo1}`
|
167
|
-
`git commit -a -m "initial commit"`
|
168
|
-
sys_exec("git push origin master", true)
|
169
|
-
`git commit -a -m "another commit"`
|
207
|
+
subject.release_gem
|
170
208
|
end
|
171
|
-
@helper.release_gem
|
172
|
-
end
|
173
209
|
|
174
|
-
|
175
|
-
|
176
|
-
|
210
|
+
it "even if tag already exists" do
|
211
|
+
mock_build_message app_name, app_version
|
212
|
+
mock_confirm_message "Tag v#{app_version} has already been created."
|
213
|
+
expect(subject).to receive(:rubygem_push).with(app_gem_path.to_s)
|
177
214
|
|
178
|
-
|
215
|
+
Dir.chdir(app_path) do
|
216
|
+
`git tag -a -m \"Version #{app_version}\" v#{app_version}`
|
217
|
+
end
|
179
218
|
|
180
|
-
|
181
|
-
|
182
|
-
}
|
183
|
-
Dir.chdir(@app) {
|
184
|
-
`git init`
|
185
|
-
`git config user.email "you@example.com"`
|
186
|
-
`git config user.name "name"`
|
187
|
-
`git commit -a -m "another commit"`
|
188
|
-
`git tag -a -m \"Version 0.0.1\" v0.0.1`
|
189
|
-
}
|
190
|
-
@helper.release_gem
|
219
|
+
subject.release_gem
|
220
|
+
end
|
191
221
|
end
|
192
|
-
|
193
222
|
end
|
194
223
|
end
|
195
224
|
end
|