# What is the library used to make external requests?

**URL:** <https://meta.discourse.org/t/what-is-the-library-used-to-make-external-requests/120147>\
**Category:** Development\
**Created:** [12 juni 2019 om 12:53 UTC](https://meta.discourse.org/t/what-is-the-library-used-to-make-external-requests/120147 "2019-06-12T12:53:35Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)\
**Post date:** [14 juni 2019 om 07:30 UTC](https://meta.discourse.org/t/what-is-the-library-used-to-make-external-requests/120147/4 "2019-06-14T07:30:23Z")

</div>

A great trick here that will save you tons of time is to look at existing specs (either for plugins or core)

The magic keyword you are looking for here is `stub_request` it is used lots of places in our spec tests, for example here:

> <https://github.com/discourse/discourse/blob/ecb2fd8222edf67b65c46362dc0b2361e3adf93a/spec/components/file_helper_spec.rb#L36-L48>

We use [GitHub - bblimke/webmock: Library for stubbing and setting expectations on HTTP requests in Ruby. · GitHub](https://github.com/bblimke/webmock) so pretty much anything should work, if you simply need a simple HTTP get, this class has simple example of how we use FinalDestination class that wraps stuff for you.

> <https://github.com/discourse/discourse/blob/ecb2fd8222edf67b65c46362dc0b2361e3adf93a/lib/file_helper.rb#L39-L47>

For a simple get excon may be overkill. We have been slowly winding down on our excon use in core due to strangeness with it. I would recommend avoiding faraday we don’t ever use it in core.

Regarding getting stuck with specs. A huge time saver is

```plaintext
bin/rake autospec

```

Once you run that, save you `plugin.rb` file and right away all the specs will run, same goes for specific controller specs.

---

_[View the full topic](https://meta.discourse.org/t/what-is-the-library-used-to-make-external-requests/120147)._
