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 6, 2024
1 parent 9e5ba0c commit d2bd61a
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 @@ -58,10 +58,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 @@ -71,8 +71,8 @@
f.write(repl_script)
f.close

out, = Open3.capture2e('pry', '-f', '--noprompt', f.path)
expect(out).to eq('ACTUAL:true')
_, err, = Open3.capture3('pry', '-f', '--noprompt', f.path)
expect(err).to end_with('ACTUAL:true')
end
end
end
Expand Down Expand Up @@ -129,7 +129,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 @@ -187,9 +187,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 @@ -253,7 +254,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 @@ -269,13 +270,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 d2bd61a

Please sign in to comment.