aboutsummaryrefslogtreecommitdiffstats
path: root/spec/cache/svn_spec.rb
blob: e798e0e9a2e5d82161baf8f5cc85573693bb9fc6 (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"

%w(cache package).each do |cmd|
  describe "bundle #{cmd} with svn" do
    it "copies repository to vendor cache and uses it" do
      svn = build_svn "foo"
      ref = svn.ref_for("HEAD")

      install_gemfile <<-G
        gem "foo", :svn => 'file://#{lib_path("foo-1.0")}'
      G

      bundle "#{cmd} --all"
      expect(bundled_app("vendor/cache/foo-1.0-#{ref}")).to exist
      expect(bundled_app("vendor/cache/foo-1.0-#{ref}/.svn")).to exist

      FileUtils.rm_rf lib_path("foo-1.0")
      should_be_installed "foo 1.0"
    end

    it "copies repository to vendor cache and uses it even when installed with bundle --path" do
      svn = build_svn "foo"
      ref = svn.ref_for("HEAD")

      install_gemfile <<-G
        gem "foo", :svn => 'file://#{lib_path("foo-1.0")}'
      G

      bundle "install --path vendor/bundle"
      bundle "#{cmd} --all"

      expect(bundled_app("vendor/cache/foo-1.0-#{ref}")).to exist
      expect(bundled_app("vendor/cache/foo-1.0-#{ref}/.svn")).to exist

      FileUtils.rm_rf lib_path("foo-1.0")
      should_be_installed "foo 1.0"
    end

    it "runs twice without exploding" do
      build_svn "foo"

      install_gemfile <<-G
        gem "foo", :svn => 'file://#{lib_path("foo-1.0")}'
      G

      bundle "#{cmd} --all"
      bundle "#{cmd} --all"

      expect(err).to eq("")
      FileUtils.rm_rf lib_path("foo-1.0")
      should_be_installed "foo 1.0"
    end

    it "tracks updates" do
      svn = build_svn "foo"
      old_ref = svn.ref_for("HEAD")

      install_gemfile <<-G
        gem "foo", :svn => 'file://#{lib_path("foo-1.0")}'
      G

      bundle "#{cmd} --all"

      update_svn "foo" do |s|
        s.write "lib/foo.rb", "puts :CACHE"
      end

      ref = svn.ref_for("HEAD")
      expect(ref).not_to eq(old_ref)

      bundle "update"
      bundle "#{cmd} --all"

      expect(bundled_app("vendor/cache/foo-1.0-#{ref}")).to exist

      FileUtils.rm_rf lib_path("foo-1.0")
      run "require 'foo'"
      expect(out).to eq("CACHE")
    end

  end
end