Skip to content

Commit

Permalink
Improve brittle assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyCTHsu committed Sep 13, 2024
1 parent b1d07e9 commit 09151e4
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions spec/datadog/core/environment/execution_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@

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

Expand All @@ -70,8 +70,8 @@
f.write(repl_script)
f.close

out, = Open3.capture2e('pry', '-f', '--noprompt', f.path)
expect(out).to include('ACTUAL:true')
_, err, = Open3.capture3('pry', '-f', '--noprompt', f.path)
expect(err).to end_with('ACTUAL:true')
end
end
end
Expand Down Expand Up @@ -128,7 +128,7 @@ def test_it_does_something_useful

it 'returns true' do
_, err, = Open3.capture3('ruby', stdin_data: script)
expect(err).to end_with('true')
expect(err).to end_with('ACTUAL:true')
end
end

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

_, err = Bundler.with_clean_env do
_, err, = Bundler.with_clean_env do
Open3.capture3('ruby', stdin_data: script)
end

expect(err).to include('ACTUAL:true')
end
end
Expand Down Expand Up @@ -252,7 +253,7 @@ def test_it_does_something_useful

context 'when given WebMock', skip: Gem::Version.new(Bundler::VERSION) < Gem::Version.new('2') do
it do
out, err = Bundler.with_clean_env do
out, = Bundler.with_clean_env do
Open3.capture3('ruby', stdin_data: <<-RUBY
require 'bundler/inline'
Expand All @@ -268,13 +269,12 @@ def test_it_does_something_useful
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'datadog/core/environment/execution'
STDOUT.print Datadog::Core::Environment::Execution.webmock_enabled?
STDOUT.print "ACTUAL:\#{Datadog::Core::Environment::Execution.webmock_enabled?}"
RUBY
)
end

expect(err).to be_empty
expect(out).to eq('true')
expect(out).to end_with('ACTUAL:true')
end
end
end
Expand Down

0 comments on commit 09151e4

Please sign in to comment.