bundler 1.0.0 → 1.0.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.

Files changed (108) hide show
  1. data/.gitignore +12 -0
  2. data/CHANGELOG.md +28 -6
  3. data/ISSUES.md +1 -1
  4. data/README.md +7 -5
  5. data/Rakefile +173 -0
  6. data/UPGRADING.md +103 -0
  7. data/bundler.gemspec +28 -0
  8. data/lib/bundler.rb +1 -0
  9. data/lib/bundler/capistrano.rb +2 -31
  10. data/lib/bundler/cli.rb +18 -16
  11. data/lib/bundler/deployment.rb +37 -0
  12. data/lib/bundler/dsl.rb +3 -3
  13. data/lib/bundler/gem_helper.rb +4 -7
  14. data/lib/bundler/graph.rb +3 -3
  15. data/lib/bundler/installer.rb +1 -0
  16. data/lib/bundler/lockfile_parser.rb +1 -1
  17. data/lib/bundler/man/bundle +1 -1
  18. data/lib/bundler/man/bundle-config +92 -0
  19. data/lib/bundler/man/bundle-config.txt +72 -30
  20. data/lib/bundler/man/bundle-exec +1 -1
  21. data/lib/bundler/man/bundle-exec.txt +1 -1
  22. data/lib/bundler/man/bundle-install +1 -1
  23. data/lib/bundler/man/bundle-install.txt +1 -1
  24. data/lib/bundler/man/bundle-package +1 -1
  25. data/lib/bundler/man/bundle-package.txt +1 -1
  26. data/lib/bundler/man/bundle-update +1 -1
  27. data/lib/bundler/man/bundle-update.txt +1 -1
  28. data/lib/bundler/man/bundle.txt +1 -1
  29. data/lib/bundler/man/gemfile.5 +2 -2
  30. data/lib/bundler/man/gemfile.5.txt +2 -2
  31. data/lib/bundler/settings.rb +2 -2
  32. data/lib/bundler/source.rb +2 -3
  33. data/lib/bundler/templates/Executable +1 -1
  34. data/lib/bundler/templates/newgem/Gemfile.tt +1 -1
  35. data/lib/bundler/templates/newgem/bin/newgem.tt +3 -0
  36. data/lib/bundler/templates/newgem/newgem.gemspec.tt +11 -12
  37. data/lib/bundler/version.rb +1 -1
  38. data/lib/bundler/vlad.rb +9 -0
  39. data/man/bundle-config.ronn +90 -0
  40. data/man/bundle-exec.ronn +98 -0
  41. data/man/bundle-install.ronn +310 -0
  42. data/man/bundle-package.ronn +59 -0
  43. data/man/bundle-update.ronn +176 -0
  44. data/man/bundle.ronn +77 -0
  45. data/man/gemfile.5.ronn +254 -0
  46. data/man/index.txt +6 -0
  47. data/spec/cache/gems_spec.rb +205 -0
  48. data/spec/cache/git_spec.rb +9 -0
  49. data/spec/cache/path_spec.rb +27 -0
  50. data/spec/cache/platform_spec.rb +57 -0
  51. data/spec/install/deploy_spec.rb +171 -0
  52. data/spec/install/deprecated_spec.rb +43 -0
  53. data/spec/install/gems/c_ext_spec.rb +48 -0
  54. data/spec/install/gems/env_spec.rb +107 -0
  55. data/spec/install/gems/flex_spec.rb +272 -0
  56. data/spec/install/gems/groups_spec.rb +209 -0
  57. data/spec/install/gems/locked_spec.rb +48 -0
  58. data/spec/install/gems/packed_spec.rb +72 -0
  59. data/spec/install/gems/platform_spec.rb +181 -0
  60. data/spec/install/gems/resolving_spec.rb +72 -0
  61. data/spec/install/gems/simple_case_spec.rb +709 -0
  62. data/spec/install/gems/sudo_spec.rb +77 -0
  63. data/spec/install/gems/win32_spec.rb +26 -0
  64. data/spec/install/gemspec_spec.rb +96 -0
  65. data/spec/install/git_spec.rb +552 -0
  66. data/spec/install/invalid_spec.rb +17 -0
  67. data/spec/install/path_spec.rb +335 -0
  68. data/spec/install/upgrade_spec.rb +26 -0
  69. data/spec/lock/flex_spec.rb +625 -0
  70. data/spec/lock/git_spec.rb +35 -0
  71. data/spec/other/check_spec.rb +221 -0
  72. data/spec/other/config_spec.rb +40 -0
  73. data/spec/other/console_spec.rb +102 -0
  74. data/spec/other/exec_spec.rb +241 -0
  75. data/spec/other/ext_spec.rb +16 -0
  76. data/spec/other/gem_helper_spec.rb +116 -0
  77. data/spec/other/help_spec.rb +36 -0
  78. data/spec/other/init_spec.rb +40 -0
  79. data/spec/other/newgem_spec.rb +24 -0
  80. data/spec/other/open_spec.rb +51 -0
  81. data/spec/other/show_spec.rb +99 -0
  82. data/spec/pack/gems_spec.rb +22 -0
  83. data/spec/quality_spec.rb +55 -0
  84. data/spec/resolver/basic_spec.rb +20 -0
  85. data/spec/resolver/platform_spec.rb +57 -0
  86. data/spec/runtime/environment_rb_spec.rb +170 -0
  87. data/spec/runtime/executable_spec.rb +110 -0
  88. data/spec/runtime/load_spec.rb +107 -0
  89. data/spec/runtime/platform_spec.rb +90 -0
  90. data/spec/runtime/require_spec.rb +261 -0
  91. data/spec/runtime/setup_spec.rb +412 -0
  92. data/spec/runtime/with_clean_env_spec.rb +15 -0
  93. data/spec/spec_helper.rb +81 -0
  94. data/spec/support/builders.rb +566 -0
  95. data/spec/support/helpers.rb +243 -0
  96. data/spec/support/indexes.rb +113 -0
  97. data/spec/support/matchers.rb +89 -0
  98. data/spec/support/path.rb +71 -0
  99. data/spec/support/platforms.rb +49 -0
  100. data/spec/support/ruby_ext.rb +19 -0
  101. data/spec/support/rubygems_ext.rb +30 -0
  102. data/spec/support/rubygems_hax/rubygems_plugin.rb +9 -0
  103. data/spec/support/sudo.rb +21 -0
  104. data/spec/update/gems_spec.rb +86 -0
  105. data/spec/update/git_spec.rb +159 -0
  106. data/spec/update/source_spec.rb +50 -0
  107. metadata +170 -32
  108. data/ROADMAP.md +0 -36
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Gem::Specification#match_platform" do
4
+ it "works" do
5
+ darwin = gem "lol", "1.0", "platform_specific-1.0-x86-darwin-10"
6
+ darwin.match_platform(pl('java')).should be_false
7
+ end
8
+ end
9
+
10
+ describe "Bundler::GemHelpers#generic" do
11
+ include Bundler::GemHelpers
12
+
13
+ it "works" do
14
+ generic(pl('x86-darwin-10')).should == pl('ruby')
15
+ end
16
+ end
@@ -0,0 +1,116 @@
1
+ require "spec_helper"
2
+ require 'bundler/gem_helper'
3
+
4
+ describe "Bundler::GemHelper tasks" do
5
+ context "determining gemspec" do
6
+ it "interpolates the name when there is only one gemspec" do
7
+ bundle 'gem test'
8
+ app = bundled_app("test")
9
+ helper = Bundler::GemHelper.new(app.to_s)
10
+ helper.gemspec.name.should == 'test'
11
+ end
12
+
13
+ it "should fail when there is no gemspec" do
14
+ bundle 'gem test'
15
+ app = bundled_app("test")
16
+ FileUtils.rm(File.join(app.to_s, 'test.gemspec'))
17
+ proc { Bundler::GemHelper.new(app.to_s) }.should raise_error(/Unable to determine name/)
18
+ end
19
+
20
+ it "should fail when there are two gemspecs and the name isn't specified" do
21
+ bundle 'gem test'
22
+ app = bundled_app("test")
23
+ File.open(File.join(app.to_s, 'test2.gemspec'), 'w') {|f| f << ''}
24
+ proc { Bundler::GemHelper.new(app.to_s) }.should raise_error(/Unable to determine name/)
25
+ end
26
+ end
27
+
28
+ context "gem management" do
29
+ def mock_confirm_message(message)
30
+ Bundler.ui.should_receive(:confirm).with(message)
31
+ end
32
+
33
+ def mock_build_message
34
+ mock_confirm_message "test 0.0.1 built to pkg/test-0.0.1.gem"
35
+ end
36
+
37
+ before(:each) do
38
+ bundle 'gem test'
39
+ @app = bundled_app("test")
40
+ @gemspec = File.read("#{@app.to_s}/test.gemspec")
41
+ File.open("#{@app.to_s}/test.gemspec", 'w'){|f| f << @gemspec.gsub('TODO: ', '') }
42
+ @helper = Bundler::GemHelper.new(@app.to_s)
43
+ end
44
+
45
+ it "uses a shell UI for output" do
46
+ Bundler.ui.should be_a(Bundler::UI::Shell)
47
+ end
48
+
49
+ describe 'build' do
50
+ it "builds" do
51
+ mock_build_message
52
+ @helper.build_gem
53
+ bundled_app('test/pkg/test-0.0.1.gem').should exist
54
+ end
55
+
56
+ it "raises an appropriate error when the build fails" do
57
+ # break the gemspec by adding back the TODOs...
58
+ File.open("#{@app.to_s}/test.gemspec", 'w'){|f| f << @gemspec }
59
+ proc { @helper.build_gem }.should raise_error(/TODO/)
60
+ end
61
+ end
62
+
63
+ describe 'install' do
64
+ it "installs" do
65
+ mock_build_message
66
+ mock_confirm_message "test (0.0.1) installed"
67
+ @helper.install_gem
68
+ bundled_app('test/pkg/test-0.0.1.gem').should exist
69
+ %x{gem list}.should include("test (0.0.1)")
70
+ end
71
+
72
+ it "raises an appropriate error when the install fails" do
73
+ @helper.should_receive(:build_gem) do
74
+ # write an invalid gem file, so we can simulate install failure...
75
+ FileUtils.mkdir_p(File.join(@app.to_s, 'pkg'))
76
+ File.open("#{@app.to_s}/pkg/test-0.0.1.gem", 'w'){|f| f << "not actually a gem"}
77
+ end
78
+ proc { @helper.install_gem }.should raise_error
79
+ end
80
+ end
81
+
82
+ describe 'release' do
83
+ it "shouldn't push if there are uncommitted files" do
84
+ proc { @helper.release_gem }.should raise_error(/files that need to be committed/)
85
+ end
86
+
87
+ it 'raises an appropriate error if there is no git remote' do
88
+ Bundler.ui.stub(:confirm => nil, :error => nil) # silence messages
89
+
90
+ Dir.chdir(@app) {
91
+ `git init --bare #{gem_repo1}`
92
+ `git commit -a -m "initial commit"`
93
+ }
94
+
95
+ proc { @helper.release_gem }.should raise_error(/No destination configured to push to/)
96
+ end
97
+
98
+ it "releases" do
99
+ mock_build_message
100
+ mock_confirm_message /Tagged [\da-f]+ with v0.0.1/
101
+ mock_confirm_message "Pushed git commits and tags"
102
+
103
+ @helper.should_receive(:rubygem_push).with(bundled_app('test/pkg/test-0.0.1.gem').to_s)
104
+
105
+ Dir.chdir(@app) {
106
+ `git init --bare #{gem_repo1}`
107
+ `git remote add origin file://#{gem_repo1}`
108
+ `git commit -a -m "initial commit"`
109
+ Open3.popen3("git push origin master") # use popen3 to silence output...
110
+ `git commit -a -m "another commit"`
111
+ }
112
+ @helper.release_gem
113
+ end
114
+ end
115
+ end
116
+ end
@@ -0,0 +1,36 @@
1
+ require "spec_helper"
2
+
3
+ describe "bundle help" do
4
+ it "complains if older versions of bundler are installed" do
5
+ system_gems "bundler-0.8.1"
6
+
7
+ bundle "help", :expect_err => true
8
+ err.should == "Please remove older versions of bundler. This can be done by running `gem cleanup bundler`."
9
+ end
10
+
11
+ it "uses groff when available" do
12
+ fake_groff!
13
+
14
+ bundle "help gemfile"
15
+ out.should == %|["-Wall", "-mtty-char", "-mandoc", "-Tascii", "#{root}/lib/bundler/man/gemfile.5"]|
16
+ end
17
+
18
+ it "prefixes bundle commands with bundle- when finding the groff files" do
19
+ fake_groff!
20
+
21
+ bundle "help install"
22
+ out.should == %|["-Wall", "-mtty-char", "-mandoc", "-Tascii", "#{root}/lib/bundler/man/bundle-install"]|
23
+ end
24
+
25
+ it "simply outputs the txt file when there is no groff on the path" do
26
+ kill_path!
27
+
28
+ bundle "help install"
29
+ out.should =~ /BUNDLE-INSTALL/
30
+ end
31
+
32
+ it "still outputs the old help for commands that do not have man pages yet" do
33
+ bundle "help check"
34
+ out.should include("Check searches the local machine")
35
+ end
36
+ end
@@ -0,0 +1,40 @@
1
+ require "spec_helper"
2
+
3
+ describe "bundle init" do
4
+ it "generates a Gemfile" do
5
+ bundle :init
6
+ bundled_app("Gemfile").should exist
7
+ end
8
+
9
+ it "does not change existing Gemfiles" do
10
+ gemfile <<-G
11
+ gem "rails"
12
+ G
13
+
14
+ lambda {
15
+ bundle :init
16
+ }.should_not change { File.read(bundled_app("Gemfile")) }
17
+ end
18
+
19
+ it "should generate from an existing gemspec" do
20
+ spec_file = tmp.join('test.gemspec')
21
+ File.open(spec_file, 'w') do |file|
22
+ file << <<-S
23
+ Gem::Specification.new do |s|
24
+ s.name = 'test'
25
+ s.add_dependency 'rack', '= 1.0.1'
26
+ s.add_development_dependency 'rspec', '1.2'
27
+ end
28
+ S
29
+ end
30
+
31
+ bundle :init, :gemspec => spec_file
32
+
33
+ gemfile = bundled_app("Gemfile").read
34
+ gemfile.should =~ /source :gemcutter/
35
+ gemfile.scan(/gem "rack", "= 1.0.1"/).size.should == 1
36
+ gemfile.scan(/gem "rspec", "= 1.2"/).size.should == 1
37
+ gemfile.scan(/group :development/).size.should == 1
38
+ end
39
+
40
+ end
@@ -0,0 +1,24 @@
1
+ require "spec_helper"
2
+
3
+ describe "bundle gem" do
4
+ before :each do
5
+ bundle 'gem test-gem'
6
+ end
7
+
8
+ it "generates a gem skeleton" do
9
+ bundled_app("test-gem/test-gem.gemspec").should exist
10
+ bundled_app("test-gem/Gemfile").should exist
11
+ bundled_app("test-gem/Rakefile").should exist
12
+ bundled_app("test-gem/lib/test-gem.rb").should exist
13
+ bundled_app("test-gem/lib/test-gem/version.rb").should exist
14
+ end
15
+
16
+ it "starts with version 0.0.1" do
17
+ bundled_app("test-gem/lib/test-gem/version.rb").read.should =~ /VERSION = "0.0.1"/
18
+ end
19
+
20
+ it "nests constants so they work" do
21
+ bundled_app("test-gem/lib/test-gem/version.rb").read.should =~ /module Test\n module Gem/
22
+ bundled_app("test-gem/lib/test-gem.rb").read.should =~ /module Test\n module Gem/
23
+ end
24
+ end
@@ -0,0 +1,51 @@
1
+ require "spec_helper"
2
+
3
+ describe "bundle open" do
4
+ before :each do
5
+ install_gemfile <<-G
6
+ source "file://#{gem_repo1}"
7
+ gem "rails"
8
+ G
9
+ end
10
+
11
+ it "opens the gem with BUNDLER_EDITOR as highest priority" do
12
+ bundle "open rails", :env => {"EDITOR" => "echo editor", "VISUAL" => "echo visual", "BUNDLER_EDITOR" => "echo bundler_editor"}
13
+ out.should == "bundler_editor #{default_bundle_path('gems', 'rails-2.3.2')}"
14
+ end
15
+
16
+ it "opens the gem with VISUAL as 2nd highest priority" do
17
+ bundle "open rails", :env => {"EDITOR" => "echo editor", "VISUAL" => "echo visual", "BUNDLER_EDITOR" => ""}
18
+ out.should == "visual #{default_bundle_path('gems', 'rails-2.3.2')}"
19
+ end
20
+
21
+ it "opens the gem with EDITOR as 3rd highest priority" do
22
+ bundle "open rails", :env => {"EDITOR" => "echo editor", "VISUAL" => "", "BUNDLER_EDITOR" => ""}
23
+ out.should == "editor #{default_bundle_path('gems', 'rails-2.3.2')}"
24
+ end
25
+
26
+ it "complains if no EDITOR is set" do
27
+ bundle "open rails", :env => {"EDITOR" => "", "VISUAL" => "", "BUNDLER_EDITOR" => ""}
28
+ out.should == "To open a bundled gem, set $EDITOR or $BUNDLER_EDITOR"
29
+ end
30
+
31
+ it "complains if gem not in bundle" do
32
+ bundle "open missing", :env => {"EDITOR" => "echo editor", "VISUAL" => "", "BUNDLER_EDITOR" => ""}
33
+ out.should match(/could not find gem 'missing'/i)
34
+ end
35
+
36
+ describe "while locked" do
37
+ before :each do
38
+ bundle :lock
39
+ end
40
+
41
+ it "opens the gem with EDITOR if set" do
42
+ bundle "open rails", :env => {"EDITOR" => "echo editor", "VISUAL" => "", "BUNDLER_EDITOR" => ""}
43
+ out.should == "editor #{default_bundle_path('gems', 'rails-2.3.2')}"
44
+ end
45
+
46
+ it "complains if gem not in bundle" do
47
+ bundle "open missing", :env => {"EDITOR" => "echo editor", "VISUAL" => "", "BUNDLER_EDITOR" => ""}
48
+ out.should match(/could not find gem 'missing'/i)
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,99 @@
1
+ require "spec_helper"
2
+
3
+ describe "bundle show" do
4
+ before :each do
5
+ install_gemfile <<-G
6
+ source "file://#{gem_repo1}"
7
+ gem "rails"
8
+ G
9
+ end
10
+
11
+ it "creates a Gemfile.lock if one did not exist" do
12
+ FileUtils.rm("Gemfile.lock")
13
+
14
+ bundle "show"
15
+
16
+ bundled_app("Gemfile.lock").should exist
17
+ end
18
+
19
+ it "creates a Gemfile.lock if one did not exist and we're doing bundle show rails" do
20
+ FileUtils.rm("Gemfile.lock")
21
+
22
+ bundle "show rails"
23
+
24
+ bundled_app("Gemfile.lock").should exist
25
+ end
26
+
27
+ it "prints path if gem exists in bundle" do
28
+ bundle "show rails"
29
+ out.should == default_bundle_path('gems', 'rails-2.3.2').to_s
30
+ end
31
+
32
+ it "prints the path to the running bundler" do
33
+ bundle "show bundler"
34
+ out.should == File.expand_path('../../../', __FILE__)
35
+ end
36
+
37
+ it "complains if gem not in bundle" do
38
+ bundle "show missing"
39
+ out.should =~ /could not find gem 'missing'/i
40
+ end
41
+
42
+ describe "while locked" do
43
+ before :each do
44
+ bundle :lock
45
+ end
46
+
47
+ it "prints path if gem exists in bundle" do
48
+ bundle "show rails"
49
+ out.should == default_bundle_path('gems', 'rails-2.3.2').to_s
50
+ end
51
+
52
+ it "complains if gem not in bundle" do
53
+ bundle "show missing"
54
+ out.should =~ /could not find gem 'missing'/i
55
+ end
56
+ end
57
+
58
+ end
59
+
60
+ describe "bundle show with a git repo" do
61
+ before :each do
62
+ @git = build_git "foo", "1.0"
63
+ end
64
+
65
+ it "prints out git info" do
66
+ install_gemfile <<-G
67
+ gem "foo", :git => "#{lib_path('foo-1.0')}"
68
+ G
69
+ should_be_installed "foo 1.0"
70
+
71
+ bundle :show
72
+ out.should include("foo (1.0 #{@git.ref_for('master', 6)}")
73
+ end
74
+
75
+ it "prints out branch names other than master" do
76
+ update_git "foo", :branch => "omg" do |s|
77
+ s.write "lib/foo.rb", "FOO = '1.0.omg'"
78
+ end
79
+ @revision = revision_for(lib_path("foo-1.0"))[0...6]
80
+
81
+ install_gemfile <<-G
82
+ gem "foo", :git => "#{lib_path('foo-1.0')}", :branch => "omg"
83
+ G
84
+ should_be_installed "foo 1.0.omg"
85
+
86
+ bundle :show
87
+ out.should include("foo (1.0 #{@git.ref_for('omg', 6)}")
88
+ end
89
+
90
+ it "doesn't print the branch when tied to a ref" do
91
+ sha = revision_for(lib_path("foo-1.0"))
92
+ install_gemfile <<-G
93
+ gem "foo", :git => "#{lib_path('foo-1.0')}", :ref => "#{sha}"
94
+ G
95
+
96
+ bundle :show
97
+ out.should include("foo (1.0 #{sha[0..6]})")
98
+ end
99
+ end
@@ -0,0 +1,22 @@
1
+ require "spec_helper"
2
+
3
+ describe "bundle pack with gems" do
4
+ describe "when there are only gemsources" do
5
+ before :each do
6
+ gemfile <<-G
7
+ gem 'rack'
8
+ G
9
+
10
+ system_gems "rack-1.0.0"
11
+ bundle :pack
12
+ end
13
+
14
+ it "locks the gemfile" do
15
+ bundled_app("Gemfile.lock").should exist
16
+ end
17
+
18
+ it "caches the gems" do
19
+ bundled_app("vendor/cache/rack-1.0.0.gem").should exist
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,55 @@
1
+ require "spec_helper"
2
+
3
+ describe "The library itself" do
4
+ def check_for_tab_characters(filename)
5
+ failing_lines = []
6
+ File.readlines(filename).each_with_index do |line,number|
7
+ failing_lines << number + 1 if line =~ /\t/
8
+ end
9
+
10
+ unless failing_lines.empty?
11
+ "#{filename} has tab characters on lines #{failing_lines.join(', ')}"
12
+ end
13
+ end
14
+
15
+ def check_for_extra_spaces(filename)
16
+ failing_lines = []
17
+ File.readlines(filename).each_with_index do |line,number|
18
+ next if line =~ /^\s+#.*\s+\n$/
19
+ failing_lines << number + 1 if line =~ /\s+\n$/
20
+ end
21
+
22
+ unless failing_lines.empty?
23
+ "#{filename} has spaces on the EOL on lines #{failing_lines.join(', ')}"
24
+ end
25
+ end
26
+
27
+ RSpec::Matchers.define :be_well_formed do
28
+ failure_message_for_should do |actual|
29
+ actual.join("\n")
30
+ end
31
+
32
+ match do |actual|
33
+ actual.empty?
34
+ end
35
+ end
36
+
37
+ it "has no malformed whitespace" do
38
+ error_messages = []
39
+ Dir.chdir(File.expand_path("../..", __FILE__)) do
40
+ `git ls-files`.split("\n").each do |filename|
41
+ next if filename =~ /\.gitmodules|fixtures/
42
+ error_messages << check_for_tab_characters(filename)
43
+ error_messages << check_for_extra_spaces(filename)
44
+ end
45
+ end
46
+ error_messages.compact.should be_well_formed
47
+ end
48
+
49
+ it "can still be built" do
50
+ Dir.chdir(root) do
51
+ `gem build bundler.gemspec`
52
+ $?.should == 0
53
+ end
54
+ end
55
+ end