appraisal 1.0.3 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -26,7 +26,7 @@ describe 'Gemfile DSL compatibility' do
26
26
  gem "waffle"
27
27
  end
28
28
 
29
- gem 'appraisal', path: #{PROJECT_ROOT.inspect}
29
+ gem 'appraisal', :path => #{PROJECT_ROOT.inspect}
30
30
 
31
31
  gemspec
32
32
  Gemfile
@@ -111,7 +111,7 @@ describe 'Gemfile DSL compatibility' do
111
111
  build_gem "bacon", "1.2.0"
112
112
 
113
113
  build_gemfile <<-Gemfile
114
- gem "appraisal", path: #{PROJECT_ROOT.inspect}
114
+ gem "appraisal", :path => #{PROJECT_ROOT.inspect}
115
115
  gem "bacon", "1.2.0"
116
116
  Gemfile
117
117
 
@@ -142,7 +142,7 @@ describe 'Gemfile DSL compatibility' do
142
142
  build_gemspec
143
143
 
144
144
  build_gemfile <<-Gemfile
145
- gem "appraisal", path: #{PROJECT_ROOT.inspect}
145
+ gem "appraisal", :path => #{PROJECT_ROOT.inspect}
146
146
 
147
147
  group :plugin do
148
148
  gemspec
@@ -10,7 +10,7 @@ describe 'Gemspec' do
10
10
  build_gemspec
11
11
 
12
12
  write_file 'Gemfile', <<-Gemfile
13
- gem 'appraisal', path: #{PROJECT_ROOT.inspect}
13
+ gem 'appraisal', :path => #{PROJECT_ROOT.inspect}
14
14
 
15
15
  gemspec
16
16
  Gemfile
@@ -26,9 +26,9 @@ describe 'Gemspec' do
26
26
  build_gemspec 'specdir'
27
27
 
28
28
  write_file 'Gemfile', <<-Gemfile
29
- gem 'appraisal', path: #{PROJECT_ROOT.inspect}
29
+ gem 'appraisal', :path => #{PROJECT_ROOT.inspect}
30
30
 
31
- gemspec path: './specdir'
31
+ gemspec :path => './specdir'
32
32
  Gemfile
33
33
 
34
34
  run 'bundle install --local'
@@ -0,0 +1,94 @@
1
+ require "spec_helper"
2
+ require "active_support/core_ext/kernel/reporting"
3
+ require "appraisal/travis_ci_helper"
4
+
5
+ describe "Travis CI integration" do
6
+ before do
7
+ build_appraisal_file <<-Appraisals.strip_heredoc
8
+ appraise "1.0.0" do
9
+ gem "dummy", "1.0.0"
10
+ end
11
+
12
+ appraise "1.1.0" do
13
+ gem "dummy", "1.1.0"
14
+ end
15
+ Appraisals
16
+ end
17
+
18
+ context "when user runs `appraisal generate --travis`" do
19
+ it "displays a correct Gemfile directive" do
20
+ output = run("appraisal generate --travis")
21
+
22
+ expect(output).to include <<-stdout.strip_heredoc
23
+ # Put this in your .travis.yml
24
+ gemfiles:
25
+ - gemfiles/1.0.0.gemfile
26
+ - gemfiles/1.1.0.gemfile
27
+ stdout
28
+ end
29
+ end
30
+
31
+ context "When user has .travis.yml" do
32
+ context "with no gemfiles directive" do
33
+ before do
34
+ write_file ".travis.yml", ""
35
+ end
36
+
37
+ it "displays a warning message when run `appraisal generate`" do
38
+ warning = run "appraisal generate 2>&1"
39
+
40
+ expect(warning).to include no_configuration_warning
41
+ end
42
+ end
43
+
44
+ context "with incorrect gemfiles directive" do
45
+ before do
46
+ write_file ".travis.yml", <<-travis_yml
47
+ gemfiles:
48
+ - gemfiles/1.0.0.gemfile
49
+ - gemfiles/1.0.1.gemfile
50
+ travis_yml
51
+ end
52
+
53
+ it "displays a warning message when run `appraisal generate`" do
54
+ warning = run "appraisal generate 2>&1"
55
+
56
+ expect(warning).to include invalid_configuration_warning
57
+ end
58
+ end
59
+
60
+ context "with correct gemfiles directive" do
61
+ before do
62
+ write_file ".travis.yml", <<-travis_yml
63
+ gemfiles:
64
+ - gemfiles/1.0.0.gemfile
65
+ - gemfiles/1.1.0.gemfile
66
+ travis_yml
67
+ end
68
+
69
+ it "does not display any warning when run `appraisal generate`" do
70
+ warning = run "appraisal generate 2>&1"
71
+
72
+ expect(warning).not_to include no_configuration_warning
73
+ expect(warning).not_to include invalid_configuration_warning
74
+ end
75
+ end
76
+ end
77
+
78
+ context "when user does not have .travis.yml" do
79
+ it "does not display any warning when run `appraisal generate`" do
80
+ warning = run "appraisal generate 2>&1"
81
+
82
+ expect(warning).not_to include no_configuration_warning
83
+ expect(warning).not_to include invalid_configuration_warning
84
+ end
85
+ end
86
+
87
+ def no_configuration_warning
88
+ Appraisal::TravisCIHelper::NO_CONFIGURATION_WARNING
89
+ end
90
+
91
+ def invalid_configuration_warning
92
+ Appraisal::TravisCIHelper::INVALID_CONFIGURATION_WARNING
93
+ end
94
+ end
@@ -17,6 +17,13 @@ describe Appraisal::Gemfile do
17
17
  expect(gemfile.to_s.strip).to eq %{source "one"\nsource "two"}
18
18
  end
19
19
 
20
+ it "ignores duplicate sources" do
21
+ gemfile = Appraisal::Gemfile.new
22
+ gemfile.source "one"
23
+ gemfile.source "one"
24
+ expect(gemfile.to_s.strip).to eq %{source "one"}
25
+ end
26
+
20
27
  it "preserves dependency order" do
21
28
  gemfile = Appraisal::Gemfile.new
22
29
  gemfile.gem "one"
@@ -45,22 +52,36 @@ describe Appraisal::Gemfile do
45
52
  GEMFILE
46
53
  end
47
54
 
48
- it 'supports groups syntax, but with deprecation warning' do
55
+ it "supports nested DSL within group syntax" do
49
56
  gemfile = Appraisal::Gemfile.new
50
57
 
51
- warning = capture(:stderr) do
52
- gemfile.groups :development, :test do
58
+ gemfile.group :development, :test do
59
+ platforms :jruby do
53
60
  gem "one"
54
61
  end
62
+ git "git://example.com/repo.git" do
63
+ gem "two"
64
+ end
65
+ path ".." do
66
+ gem "three"
67
+ end
55
68
  end
56
69
 
57
70
  expect(gemfile.to_s).to eq <<-GEMFILE.strip_heredoc.strip
58
71
  group :development, :test do
59
- gem "one"
72
+ git "git://example.com/repo.git" do
73
+ gem "two"
74
+ end
75
+
76
+ path "../.." do
77
+ gem "three"
78
+ end
79
+
80
+ platforms :jruby do
81
+ gem "one"
82
+ end
60
83
  end
61
84
  GEMFILE
62
-
63
- expect(warning).to match(/deprecated/)
64
85
  end
65
86
 
66
87
  it 'supports platform syntax' do
@@ -77,20 +98,130 @@ describe Appraisal::Gemfile do
77
98
  GEMFILE
78
99
  end
79
100
 
80
- it 'supports platforms syntax' do
101
+ it "supports nested DSL within platform syntax" do
102
+ gemfile = Appraisal::Gemfile.new
103
+
104
+ gemfile.platform :jruby do
105
+ group :development, :test do
106
+ gem "one"
107
+ end
108
+ git "git://example.com/repo.git" do
109
+ gem "two"
110
+ end
111
+ path ".." do
112
+ gem "three"
113
+ end
114
+ end
115
+
116
+ expect(gemfile.to_s).to eq <<-GEMFILE.strip_heredoc.strip
117
+ platforms :jruby do
118
+ git "git://example.com/repo.git" do
119
+ gem "two"
120
+ end
121
+
122
+ path "../.." do
123
+ gem "three"
124
+ end
125
+
126
+ group :development, :test do
127
+ gem "one"
128
+ end
129
+ end
130
+ GEMFILE
131
+ end
132
+
133
+ it "supports git syntax" do
81
134
  gemfile = Appraisal::Gemfile.new
82
135
 
83
- gemfile.platforms :jruby do
136
+ gemfile.git "git://example.com/repo.git" do
84
137
  gem "one"
85
138
  end
86
139
 
87
140
  expect(gemfile.to_s).to eq <<-GEMFILE.strip_heredoc.strip
141
+ git "git://example.com/repo.git" do
142
+ gem "one"
143
+ end
144
+ GEMFILE
145
+ end
146
+
147
+ it "supports nested DSL within git syntax" do
148
+ gemfile = Appraisal::Gemfile.new
149
+
150
+ gemfile.git "git://example.com/repo.git" do
151
+ group :development, :test do
152
+ gem "one"
153
+ end
88
154
  platforms :jruby do
155
+ gem "two"
156
+ end
157
+ path ".." do
158
+ gem "three"
159
+ end
160
+ end
161
+
162
+ expect(gemfile.to_s).to eq <<-GEMFILE.strip_heredoc.strip
163
+ git "git://example.com/repo.git" do
164
+ path "../.." do
165
+ gem "three"
166
+ end
167
+
168
+ group :development, :test do
169
+ gem "one"
170
+ end
171
+
172
+ platforms :jruby do
173
+ gem "two"
174
+ end
175
+ end
176
+ GEMFILE
177
+ end
178
+
179
+ it "supports path syntax" do
180
+ gemfile = Appraisal::Gemfile.new
181
+
182
+ gemfile.path "../path" do
183
+ gem "one"
184
+ end
185
+
186
+ expect(gemfile.to_s).to eq <<-GEMFILE.strip_heredoc.strip
187
+ path "../../path" do
89
188
  gem "one"
90
189
  end
91
190
  GEMFILE
92
191
  end
93
192
 
193
+ it "supports nested DSL within path syntax" do
194
+ gemfile = Appraisal::Gemfile.new
195
+
196
+ gemfile.path "../path" do
197
+ group :development, :test do
198
+ gem "one"
199
+ end
200
+ platforms :jruby do
201
+ gem "two"
202
+ end
203
+ git "git://example.com/repo.git" do
204
+ gem "three"
205
+ end
206
+ end
207
+
208
+ expect(gemfile.to_s).to eq <<-GEMFILE.strip_heredoc.strip
209
+ path "../../path" do
210
+ git "git://example.com/repo.git" do
211
+ gem "three"
212
+ end
213
+
214
+ group :development, :test do
215
+ gem "one"
216
+ end
217
+
218
+ platforms :jruby do
219
+ gem "two"
220
+ end
221
+ end
222
+ GEMFILE
223
+ end
224
+
94
225
  context "excess new line" do
95
226
  context "no contents" do
96
227
  it "shows empty string" do
@@ -123,21 +254,21 @@ describe Appraisal::Gemfile do
123
254
  context "in :path option" do
124
255
  it "handles dot path" do
125
256
  gemfile = Appraisal::Gemfile.new
126
- gemfile.gem "bacon", path: "."
257
+ gemfile.gem "bacon", :path => "."
127
258
 
128
259
  expect(gemfile.to_s).to eq %(gem "bacon", :path => "../")
129
260
  end
130
261
 
131
262
  it "handles relative path" do
132
263
  gemfile = Appraisal::Gemfile.new
133
- gemfile.gem "bacon", path: "../bacon"
264
+ gemfile.gem "bacon", :path => "../bacon"
134
265
 
135
266
  expect(gemfile.to_s).to eq %(gem "bacon", :path => "../../bacon")
136
267
  end
137
268
 
138
269
  it "handles absolute path" do
139
270
  gemfile = Appraisal::Gemfile.new
140
- gemfile.gem "bacon", path: "/tmp"
271
+ gemfile.gem "bacon", :path => "/tmp"
141
272
 
142
273
  expect(gemfile.to_s).to eq %(gem "bacon", :path => "/tmp")
143
274
  end
@@ -146,28 +277,28 @@ describe Appraisal::Gemfile do
146
277
  context "in :git option" do
147
278
  it "handles dot git path" do
148
279
  gemfile = Appraisal::Gemfile.new
149
- gemfile.gem "bacon", git: "."
280
+ gemfile.gem "bacon", :git => "."
150
281
 
151
282
  expect(gemfile.to_s).to eq %(gem "bacon", :git => "../")
152
283
  end
153
284
 
154
285
  it "handles relative git path" do
155
286
  gemfile = Appraisal::Gemfile.new
156
- gemfile.gem "bacon", git: "../bacon"
287
+ gemfile.gem "bacon", :git => "../bacon"
157
288
 
158
289
  expect(gemfile.to_s).to eq %(gem "bacon", :git => "../../bacon")
159
290
  end
160
291
 
161
292
  it "handles absolute git path" do
162
293
  gemfile = Appraisal::Gemfile.new
163
- gemfile.gem "bacon", git: "/tmp"
294
+ gemfile.gem "bacon", :git => "/tmp"
164
295
 
165
296
  expect(gemfile.to_s).to eq %(gem "bacon", :git => "/tmp")
166
297
  end
167
298
 
168
299
  it "handles git uri" do
169
300
  gemfile = Appraisal::Gemfile.new
170
- gemfile.gem "bacon", git: "git@github.com:bacon/bacon.git"
301
+ gemfile.gem "bacon", :git => "git@github.com:bacon/bacon.git"
171
302
 
172
303
  expect(gemfile.to_s).
173
304
  to eq %(gem "bacon", :git => "git@github.com:bacon/bacon.git")
@@ -279,7 +410,7 @@ describe Appraisal::Gemfile do
279
410
  context "in gemspec directive" do
280
411
  it "handles gemspec path" do
281
412
  gemfile = Appraisal::Gemfile.new
282
- gemfile.gemspec path: "."
413
+ gemfile.gemspec :path => "."
283
414
 
284
415
  expect(gemfile.to_s).to eq %(gemspec :path => "../")
285
416
  end
@@ -4,17 +4,18 @@ require 'appraisal/utils'
4
4
  describe Appraisal::Utils do
5
5
  describe '.format_string' do
6
6
  it 'prints out a nice looking hash without a brackets' do
7
- hash = { :foo => 'bar', 'baz' => { :ball => 'boo' } }
7
+ hash = { :foo => 'bar' }
8
+ expect(Appraisal::Utils.format_string(hash)).to eq(':foo => "bar"')
8
9
 
9
- expect(Appraisal::Utils.format_string(hash)).to eq(
10
- ':foo => "bar", "baz" => { :ball => "boo" }'
11
- )
10
+ hash = { 'baz' => { :ball => 'boo' }}
11
+ expect(Appraisal::Utils.format_string(hash)).
12
+ to eq('"baz" => { :ball => "boo" }')
12
13
  end
13
14
  end
14
15
 
15
16
  describe '.format_arguments' do
16
17
  it 'prints out arguments without enclosing square brackets' do
17
- arguments = [:foo, bar: { baz: 'ball' }]
18
+ arguments = [:foo, { :bar => { :baz => 'ball' }}]
18
19
 
19
20
  expect(Appraisal::Utils.format_arguments(arguments)).to eq(
20
21
  ':foo, :bar => { :baz => "ball" }'
@@ -1,7 +1,7 @@
1
1
  require 'rubygems'
2
2
  require 'bundler/setup'
3
- require_relative 'support/acceptance_test_helpers'
4
- require_relative 'support/stream_helpers'
3
+ require "./spec/support/acceptance_test_helpers"
4
+ require "./spec/support/stream_helpers"
5
5
 
6
6
  PROJECT_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..')).freeze
7
7
  TMP_GEM_ROOT = File.join(PROJECT_ROOT, "tmp", "gems")
@@ -14,4 +14,8 @@ RSpec.configure do |config|
14
14
  end
15
15
 
16
16
  config.include AcceptanceTestHelpers, :type => :acceptance
17
+
18
+ config.before :suite do
19
+ FileUtils.rm_rf TMP_GEM_ROOT
20
+ end
17
21
  end
@@ -1,8 +1,9 @@
1
1
  require 'rspec/expectations/expectation_target'
2
2
  require 'active_support/core_ext/string/strip'
3
+ require 'active_support/core_ext/string/filters'
3
4
  require 'active_support/concern'
4
5
  require 'appraisal/utils'
5
- require_relative 'dependency_helpers'
6
+ require "./spec/support/dependency_helpers"
6
7
 
7
8
  module AcceptanceTestHelpers
8
9
  extend ActiveSupport::Concern
@@ -14,15 +15,7 @@ module AcceptanceTestHelpers
14
15
  included do
15
16
  metadata[:type] = :acceptance
16
17
 
17
- before :all do
18
- build_default_dummy_gems
19
- end
20
-
21
- after :all do
22
- cleanup_gem_home
23
- end
24
-
25
- before parallel: true do
18
+ before :parallel => true do
26
19
  unless Appraisal::Utils.support_parallel_installation?
27
20
  pending 'This Bundler version does not support --jobs flag.'
28
21
  end
@@ -32,6 +25,8 @@ module AcceptanceTestHelpers
32
25
  cleanup_artifacts
33
26
  save_environment_variables
34
27
  unset_bundler_environment_variables
28
+ build_default_dummy_gems
29
+ ensure_bundler_is_available
35
30
  add_binstub_path
36
31
  build_default_gemfile
37
32
  end
@@ -115,28 +110,39 @@ module AcceptanceTestHelpers
115
110
  FileUtils.rm_rf current_directory
116
111
  end
117
112
 
118
- def cleanup_gem_home
119
- FileUtils.rm_rf TMP_GEM_ROOT
120
- end
121
-
122
113
  def build_default_dummy_gems
123
- FileUtils.rm_rf(TMP_GEM_ROOT)
124
114
  FileUtils.mkdir_p(TMP_GEM_ROOT)
125
115
 
126
116
  build_gem 'dummy', '1.0.0'
127
117
  build_gem 'dummy', '1.1.0'
128
118
  end
129
119
 
120
+ def ensure_bundler_is_available
121
+ run "bundle -v 2>&1", false
122
+
123
+ if $?.exitstatus != 0
124
+ puts <<-WARNING.squish.strip_heredoc
125
+ Reinstall Bundler to #{TMP_GEM_ROOT} as `BUNDLE_DISABLE_SHARED_GEMS`
126
+ is enabled.
127
+ WARNING
128
+
129
+ run "gem install bundler --install-dir '#{TMP_GEM_ROOT}'"
130
+ end
131
+ end
132
+
130
133
  def build_default_gemfile
131
134
  build_gemfile <<-Gemfile
132
135
  source 'https://rubygems.org'
133
136
 
134
137
  gem 'appraisal', :path => '#{PROJECT_ROOT}'
138
+
139
+ if RUBY_VERSION < "1.9"
140
+ gem "i18n", "~> 0.6.0"
141
+ gem "activesupport", "~> 3.2.21"
142
+ end
135
143
  Gemfile
136
144
 
137
- in_test_directory do
138
- `bundle install --binstubs --local`
139
- end
145
+ run "bundle install --binstubs --local"
140
146
  end
141
147
 
142
148
  def in_test_directory(&block)