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

Use CaptureBackend in Test environment #55

Closed
nTraum opened this issue Mar 17, 2015 · 2 comments
Closed

Use CaptureBackend in Test environment #55

nTraum opened this issue Mar 17, 2015 · 2 comments

Comments

@nTraum
Copy link

nTraum commented Mar 17, 2015

Hi statsd-instrument team,

I want to provide convenient RSpec matchers for this gem (similar to your minitest assertions) and was wondering why the CaptureBackend is not used by default in test environments (but the NullBackend instead).

In my opinion this would simplify the implementation a lot, instead of mocking & replacing the NullBackend with a CaptureBackend in a block (as done currently), you'd just need to configure the Backend once (either in a spec_helper explicitly or via ENVs implicitly).

What do you think?

@nTraum nTraum changed the title Use CaptureBackend in Test Use CaptureBackend in Test environment Mar 17, 2015
@wvanbergen
Copy link
Contributor

Two reasons:

  • First of all, we want to make sure the StatsD packet is actually generated inside the code block of the assert call, not before or after. So we should only capture inside the block.
  • Second: our test suite is big, and we generate lots of StatsD calls. This would require a lot of memory during the test run as we accumulate thousands of metrics.

In RSpec, I'd expect something like expect { ... }.to generate_statsd_call(...). You can easily do the same trick with the block here.

@nTraum
Copy link
Author

nTraum commented Mar 17, 2015

Valid points, thanks for the quick response!

@nTraum nTraum closed this as completed Mar 17, 2015
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

No branches or pull requests

2 participants