aboutsummaryrefslogtreecommitdiffstats
path: root/spec/bundler/other/bundle_ruby_spec.rb
blob: 09fa2c223b78f2ff1317b0d953771ce1553fa96e (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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# frozen_string_literal: true
require "spec_helper"

RSpec.describe "bundle_ruby" do
  context "without patchlevel" do
    it "returns the ruby version" do
      gemfile <<-G
        source "file://#{gem_repo1}"
        ruby "1.9.3", :engine => 'ruby', :engine_version => '1.9.3'

        gem "foo"
      G

      bundle_ruby

      expect(out).to include("ruby 1.9.3")
    end

    it "engine defaults to MRI" do
      gemfile <<-G
        source "file://#{gem_repo1}"
        ruby "1.9.3"

        gem "foo"
      G

      bundle_ruby

      expect(out).to include("ruby 1.9.3")
    end

    it "handles jruby" do
      gemfile <<-G
        source "file://#{gem_repo1}"
        ruby "1.8.7", :engine => 'jruby', :engine_version => '1.6.5'

        gem "foo"
      G

      bundle_ruby

      expect(out).to include("ruby 1.8.7 (jruby 1.6.5)")
    end

    it "handles rbx" do
      gemfile <<-G
        source "file://#{gem_repo1}"
        ruby "1.8.7", :engine => 'rbx', :engine_version => '1.2.4'

        gem "foo"
      G

      bundle_ruby

      expect(out).to include("ruby 1.8.7 (rbx 1.2.4)")
    end

    it "raises an error if engine is used but engine version is not" do
      gemfile <<-G
        source "file://#{gem_repo1}"
        ruby "1.8.7", :engine => 'rbx'

        gem "foo"
      G

      bundle_ruby
      expect(exitstatus).not_to eq(0) if exitstatus

      bundle_ruby
      expect(out).to include("Please define :engine_version")
    end

    it "raises an error if engine_version is used but engine is not" do
      gemfile <<-G
        source "file://#{gem_repo1}"
        ruby "1.8.7", :engine_version => '1.2.4'

        gem "foo"
      G

      bundle_ruby
      expect(exitstatus).not_to eq(0) if exitstatus

      bundle_ruby
      expect(out).to include("Please define :engine")
    end

    it "raises an error if engine version doesn't match ruby version for MRI" do
      gemfile <<-G
        source "file://#{gem_repo1}"
        ruby "1.8.7", :engine => 'ruby', :engine_version => '1.2.4'

        gem "foo"
      G

      bundle_ruby
      expect(exitstatus).not_to eq(0) if exitstatus

      bundle_ruby
      expect(out).to include("ruby_version must match the :engine_version for MRI")
    end

    it "should print if no ruby version is specified" do
      gemfile <<-G
        source "file://#{gem_repo1}"

        gem "foo"
      G

      bundle_ruby

      expect(out).to include("No ruby version specified")
    end
  end

  context "when using patchlevel" do
    it "returns the ruby version" do
      gemfile <<-G
        source "file://#{gem_repo1}"
        ruby "1.9.3", :patchlevel => '429', :engine => 'ruby', :engine_version => '1.9.3'

        gem "foo"
      G

      bundle_ruby

      expect(out).to include("ruby 1.9.3p429")
    end

    it "handles an engine" do
      gemfile <<-G
        source "file://#{gem_repo1}"
        ruby "1.9.3", :patchlevel => '392', :engine => 'jruby', :engine_version => '1.7.4'

        gem "foo"
      G

      bundle_ruby

      expect(out).to include("ruby 1.9.3p392 (jruby 1.7.4)")
    end
  end
end