Skip to content

Commit ec2c75a

Browse files
committed
Improve brittle assertion
1 parent a519a4a commit ec2c75a

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

spec/datadog/core/environment/execution_spec.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@
5757

5858
context 'when in an IRB session' do
5959
it 'returns true' do
60-
_, err = Bundler.with_clean_env do # Ruby 2.6 does not have irb by default in a bundle, but has it outside of it.
61-
Open3.capture3('irb', '--noprompt', '--noverbose', stdin_data: repl_script)
60+
_, err, = Bundler.with_clean_env do # Ruby 2.6 does not have irb by default in a bundle, but has it outside of it.
61+
Open3.capture3('irb', '--noprompt', '--noverbose', '--noecho', stdin_data: repl_script)
6262
end
63-
expect(err).to end_with('true')
63+
expect(err).to end_with('ACTUAL:true')
6464
end
6565
end
6666

@@ -70,8 +70,8 @@
7070
f.write(repl_script)
7171
f.close
7272

73-
out, = Open3.capture2e('pry', '-f', '--noprompt', f.path)
74-
expect(out).to include('ACTUAL:true')
73+
_, err, = Open3.capture3('pry', '-f', '--noprompt', f.path)
74+
expect(err).to end_with('ACTUAL:true')
7575
end
7676
end
7777
end
@@ -128,7 +128,7 @@ def test_it_does_something_useful
128128

129129
it 'returns true' do
130130
_, err, = Open3.capture3('ruby', stdin_data: script)
131-
expect(err).to end_with('true')
131+
expect(err).to end_with('ACTUAL:true')
132132
end
133133
end
134134

@@ -186,9 +186,10 @@ def test_it_does_something_useful
186186
# Add our script to `env.rb`, which is always run before any feature is executed.
187187
File.write('features/support/env.rb', repl_script)
188188

189-
_, err = Bundler.with_clean_env do
189+
_, err, = Bundler.with_clean_env do
190190
Open3.capture3('ruby', stdin_data: script)
191191
end
192+
192193
expect(err).to include('ACTUAL:true')
193194
end
194195
end
@@ -252,7 +253,7 @@ def test_it_does_something_useful
252253

253254
context 'when given WebMock', skip: Gem::Version.new(Bundler::VERSION) < Gem::Version.new('2') do
254255
it do
255-
out, err = Bundler.with_clean_env do
256+
out, = Bundler.with_clean_env do
256257
Open3.capture3('ruby', stdin_data: <<-RUBY
257258
require 'bundler/inline'
258259
@@ -268,13 +269,12 @@ def test_it_does_something_useful
268269
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
269270
require 'datadog/core/environment/execution'
270271
271-
STDOUT.print Datadog::Core::Environment::Execution.webmock_enabled?
272+
STDOUT.print "ACTUAL:\#{Datadog::Core::Environment::Execution.webmock_enabled?}"
272273
RUBY
273274
)
274275
end
275276

276-
expect(err).to be_empty
277-
expect(out).to eq('true')
277+
expect(out).to end_with('ACTUAL:true')
278278
end
279279
end
280280
end

0 commit comments

Comments
 (0)