summaryrefslogtreecommitdiff
path: root/spec/other/show_spec.rb
blob: 4a7711754b1e2a686fd87267e4a0df27192594e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
require "spec_helper"

describe "bundle show" do
  before :each do
    install_gemfile <<-G
      source "file://#{gem_repo1}"
      gem "rails"
    G
  end

  it "creates a Gemfile.lock if one did not exist" do
    FileUtils.rm("Gemfile.lock")

    bundle "show"

    bundled_app("Gemfile.lock").should exist
  end

  it "creates a Gemfile.lock if one did not exist and we're doing bundle show rails" do
    FileUtils.rm("Gemfile.lock")

    bundle "show rails"

    bundled_app("Gemfile.lock").should exist
  end

  it "prints path if gem exists in bundle" do
    bundle "show rails"
    out.should match /\n#{default_bundle_path('gems', 'rails-2.3.2').to_s}\Z/
  end

  it "prints the path to the running bundler" do
    bundle "show bundler"
    out.should match /\n#{File.expand_path('../../../', __FILE__)}\Z/
  end

  it "complains if gem not in bundle" do
    bundle "show missing"
    out.should =~ /could not find gem 'missing'/i
  end
end

describe "bundle show with a git repo" do
  before :each do
    @git = build_git "foo", "1.0"
  end

  it "prints out git info" do
    install_gemfile <<-G
      gem "foo", :git => "file://#{lib_path('foo-1.0')}/.git"
    G
    should_be_installed "foo 1.0"

    bundle :show
    out.should include("foo (1.0 #{@git.ref_for('master', 6)}")
  end

  it "prints out branch names other than master" do
    update_git "foo", :branch => "omg" do |s|
      s.write "lib/foo.rb", "FOO = '1.0.omg'"
    end
    @revision = revision_for(lib_path("foo-1.0"))[0...6]

    install_gemfile <<-G
      gem "foo", :git => "file://#{lib_path('foo-1.0')}/.git", :branch => "omg"
    G
    should_be_installed "foo 1.0.omg"

    bundle :show
    out.should include("foo (1.0 #{@git.ref_for('omg', 6)}")
  end

  it "doesn't print the branch when tied to a ref" do
    sha = revision_for(lib_path("foo-1.0"))
    install_gemfile <<-G
      gem "foo", :git => "file://#{lib_path('foo-1.0')}/.git", :ref => "#{sha}"
    G

    bundle :show
    out.should include("foo (1.0 #{sha[0..6]})")
  end
end