Skip to content

Commit ef96c08

Browse files
authored
Merge pull request #4 from deivid-rodriguez/no_bundler_warnings
No bundler warnings
2 parents 19e6055 + ecc4cb9 commit ef96c08

File tree

5 files changed

+31
-39
lines changed

5 files changed

+31
-39
lines changed

.mvn/extensions.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
<extension>
99
<groupId>io.takari.polyglot</groupId>
1010
<artifactId>polyglot-ruby</artifactId>
11-
<version>0.4.4</version>
11+
<version>0.4.8</version>
1212
</extension>
1313
</extensions>

lib/ruby_maven.rb

+8-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,14 @@ def self.exec( *args )
3535
elsif defined? Bundler
3636
# it can be switching from ruby to jruby with invoking maven
3737
# just keep it clean
38-
Bundler.with_clean_env do
39-
launch( *args )
38+
if Bundler.respond_to?(:with_unbundled_env)
39+
Bundler.with_unbundled_env do
40+
launch( *args )
41+
end
42+
else
43+
Bundler.with_clean_env do
44+
launch( *args )
45+
end
4046
end
4147
else
4248
launch( *args )

spec/maven_ruby_maven_spec.rb

+16-8
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,23 @@
55

66
subject { Maven::Ruby::Maven.new }
77

8+
let(:pkg) { File.expand_path("../pkg", __dir__) }
9+
810
it 'shows mvn commandline with verbose flag' do
9-
CatchStdout.exec do
11+
out, _ = capture_subprocess_io do
1012
subject.exec( '-Dverbose', 'validate' )
1113
end
1214
subject.verbose = false
13-
_(CatchStdout.result).must_match /mvn -Dverbose validate/
15+
_(out).must_match /mvn -Dverbose validate/
1416
end
1517

1618
it 'takes declared jruby version' do
1719
begin
1820
subject.inherit_jruby_version '9.0.4.0'
19-
subject.exec( '-X', 'initialize', '-l', 'pkg/log1.txt' )
20-
_(File.read('pkg/log1.txt')).must_match /resolve jruby for version 9.0.4.0/
21+
out, _ = capture_subprocess_io do
22+
subject.exec( '-X', 'initialize')
23+
end
24+
_(out).must_match /resolve jruby for version 9.0.4.0/
2125
ensure
2226
subject['jruby.version'] = nil
2327
end
@@ -26,14 +30,18 @@
2630
if defined? JRUBY_VERSION
2731
it 'inherits jruby version' do
2832
subject.inherit_jruby_version
29-
subject.exec( '-X', 'initialize', '-l', 'pkg/log2.txt' )
30-
_(File.read('pkg/log2.txt')).must_match /resolve jruby for version #{JRUBY_VERSION}/
33+
out, _ = capture_subprocess_io do
34+
subject.exec( '-X', 'initialize')
35+
end
36+
_(out).must_match /resolve jruby for version #{JRUBY_VERSION}/
3137
end
3238
else
3339
it 'takes default jruby version with inherit jruby version' do
3440
subject.inherit_jruby_version
35-
subject.exec( '-X', 'initialize', '-l', 'pkg/log3.txt' )
36-
_(File.read('pkg/log3.txt')).must_match /resolve jruby for version 9.3.1.0/
41+
out, _ = capture_subprocess_io do
42+
subject.exec( '-X', 'initialize')
43+
end
44+
_(out).must_match /resolve jruby for version 9.3.1.0/
3745
end
3846
end
3947
end

spec/ruby_maven_spec.rb

+4-5
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77

88
it 'displays the version info' do
99
Dir.chdir 'spec' do
10-
CatchStdout.exec do
10+
_, err = capture_io do
1111
RubyMaven.exec( '--version' )
1212
end
13-
_(CatchStdout.result).must_match /Polyglot Maven Extension 0.4.4/
13+
_(err).must_match /Polyglot Maven Extension 0.4.8/
1414
xml = File.read('.mvn/extensions.xml')
1515
_(xml).must_equal "dummy\n"
1616
end
@@ -24,12 +24,11 @@
2424

2525
it 'pack the gem' do
2626
FileUtils.rm_f gem_name
27-
CatchStdout.exec do
27+
out, _ = capture_subprocess_io do
2828
# need newer jruby version
2929
RubyMaven.exec( '-Dverbose', 'package', '-Djruby.version=9.3.0.0' )
3030
end
31-
#puts CatchStdout.result
32-
_(CatchStdout.result).must_match /mvn -Dverbose package/
31+
_(out).must_match /mvn -Dverbose package/
3332
_(File.exists?( gem_name )).must_equal true
3433
_(File.exists?( '.mvn/extensions.xml' )).must_equal true
3534
_(File.exists?( '.mvn/extensions.xml.orig' )).wont_equal true

spec/setup.rb

+2-23
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,5 @@
11
$LOAD_PATH.unshift File.expand_path( '../../lib', __FILE__ )
2-
begin
3-
require 'minitest'
4-
rescue LoadError
5-
end
6-
require 'minitest/autorun'
7-
82

9-
module CatchStdout
3+
ENV["MT_NO_PLUGINS"] = "true"
104

11-
def self.exec
12-
out = $stdout
13-
err = $stderr
14-
@result = StringIO.new
15-
$stdout = @result
16-
$stderr = @result
17-
yield
18-
ensure
19-
$stdout = out
20-
$stderr = err
21-
end
22-
23-
def self.result
24-
@result.string
25-
end
26-
end
5+
require 'minitest/autorun'

0 commit comments

Comments
 (0)