Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove workaround for rspec-mocks issue and bump RSpec to 3.12 #2346

Merged
merged 4 commits into from
Nov 2, 2022

Conversation

ivoanjo
Copy link
Member

@ivoanjo ivoanjo commented Nov 2, 2022

What does this PR do?:

This PR removes the workaround added in #2327 and #2337 to lock us out of using the latest version of rspec-mocks.

It then bumps the minimum version of RSpec used to the latest 3.12 series (which still works on all Ruby versions we support).

Motivation:

I was planning on reporting the RSpec bug we saw in #2327 and #2337 upstream, but then could no longer reproduce the issue in the latest version.

When I pushed the upgrade to 3.12 to CI, I still saw an incompatibility with Ruby 2.7, but that seems to have already been reported upstream rspec/rspec-mocks#1492 and because it only happened in a couple of places I just tweaked the code to avoid triggering the issue.

Additional Notes:

(Nothing to add)

How to test the change?:

Validate that CI is still green.

On Ruby 2.7 and some RSpec versions, we were getting failures due to:

```
       Datadog::Tracing received :trace with unexpected arguments
         expected: (#<Double "span_name">, {})
              got: (#<Double "span_name">)
       Diff:
       @@ -1 +1 @@
       -[#<Double "span_name">, {}]
       +[#<Double "span_name">]
```

There seems to be a weird incompatibility between RSpec and Ruby 2.7.

To solve this, I instead improved the test by passing an actual
argument. This works around the RSpec incompatibility and actually
improves coverage because previously we didn't actually test that
the `options` were correctly propagated (e.g. if we changed the
production code to set the options to always empty, the tests would
still pass).
@ivoanjo ivoanjo requested a review from a team November 2, 2022 12:11
@codecov-commenter
Copy link

Codecov Report

Merging #2346 (158f165) into master (2b30f97) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #2346      +/-   ##
==========================================
- Coverage   98.31%   98.30%   -0.01%     
==========================================
  Files        1100     1100              
  Lines       58332    58331       -1     
==========================================
- Hits        57347    57344       -3     
- Misses        985      987       +2     
Impacted Files Coverage Δ
spec/datadog/core/metrics/client_spec.rb 100.00% <100.00%> (ø)
.../active_support/notifications/subscription_spec.rb 100.00% <100.00%> (ø)
spec/support/synchronization_helpers.rb 81.57% <0.00%> (-2.64%) ⬇️
lib/datadog/core/diagnostics/environment_logger.rb 98.42% <0.00%> (-1.58%) ⬇️
lib/datadog/core/workers/polling.rb 100.00% <0.00%> (+3.44%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Contributor

@TonyCTHsu TonyCTHsu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking into this!

@@ -11,7 +11,7 @@
subject(:subscription) { described_class.new(span_name, options, &block) }

let(:span_name) { double('span_name') }
let(:options) { {} }
let(:options) { { resource: 'dummy_resource' } }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change also necessary?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes -- see 158f165 for why :)

@ivoanjo ivoanjo merged commit a9b0aa6 into master Nov 2, 2022
@ivoanjo ivoanjo deleted the ivoanjo/remove-rspec-workaround branch November 2, 2022 13:27
@github-actions github-actions bot added this to the 1.6.0 milestone Nov 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants