# Adding testing dependencies for plugins

**URL:** https://meta.discourse.org/t/adding-testing-dependencies-for-plugins/119584
**Category:** Development
**Created:** [June 5, 2019, 3:33pm UTC](https://meta.discourse.org/t/adding-testing-dependencies-for-plugins/119584 "2019-06-05T15:33:17Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![edL](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/edl/32/139152_2.png) [@edL](https://meta.discourse.org/u/edL)
#### Post date: [June 5, 2019, 3:33pm UTC](https://meta.discourse.org/t/adding-testing-dependencies-for-plugins/119584/1 "2019-06-05T15:33:18Z")

</div>

I’m writing a plugin that calls to an external api. In the past I’ve used [VCR](https://github.com/vcr/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?

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [June 5, 2019, 3:36pm UTC](https://meta.discourse.org/t/adding-testing-dependencies-for-plugins/119584/2 "2019-06-05T15:36:46Z")

</div>

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

[https://github.com/discourse/discourse-chat-integration/blob/master/spec/lib/discourse\_chat/provider/slack/slack\_provider\_spec.rb#L77](https://github.com/discourse/discourse-chat-integration/blob/master/spec/lib/discourse_chat/provider/slack/slack_provider_spec.rb#L77)

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?`

---

<div class="post-metadata">

### Author: ![edL](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/edl/32/139152_2.png) [@edL](https://meta.discourse.org/u/edL)
#### Post date: [June 5, 2019, 3:45pm UTC](https://meta.discourse.org/t/adding-testing-dependencies-for-plugins/119584/3 "2019-06-05T15:45:51Z")

</div>

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