Adding testing dependencies for plugins

I’m writing a plugin that calls to an external api. In the past I’ve used VCR to record requests & responses so I don’t hammer the service every 15 seconds as my tests autorun.

I’ve seen that I can use gem 'vcr', '5.0.0' in my plugin.rb, but I’m not sure what the best way is to ensure this dependency is only requested in test environments.

Does anyone else use VCR or something similar when testing plugins that call external APIs? How do you manage the dependency?

We stub requests to external APIs is quite a few places. Here’s one example:

If you really want to add a plugin dev-only dependency, you should be able to do something like gem 'vcr', '5.0.0' if Rails.env.development?


Thanks, I’d rather stick to ‘the discourse way’ for now, so I’ll do that instead :slight_smile: