Skip to content

Instantly share code, notes, and snippets.

@julsfelic
Created April 13, 2016 14:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save julsfelic/ade8af817487eff78c98182dbe762225 to your computer and use it in GitHub Desktop.
Save julsfelic/ade8af817487eff78c98182dbe762225 to your computer and use it in GitHub Desktop.

Testing external services with VCR

Why would you want to test an external service (API)?

  • Talk about how API's can change suddenly
  • How VCR can help catch regressions
  • Peace of mind that you are hiting the correct endpoints

Setting up VCR in your Rails project

  • Cloning down the repo
  • Seupt (Gemfile, rails_helper, etc...)

Walking through your first cassette

  • Hitting the DarkSky API w/ Postman
  • Writing your first test
  • Walking through passing the test

Running into problmes using VCR

  • Recording an incorrect cassette
  • Deleting cassettes

Reusing cassettes

  • Using the same cassette for multiple tests

Bypassing VCR in a feature test

  • Conflicts with mocking OAuth & VCR
  • Workaround

Concluding

  • Quick recap on everything covered
  • Sendoff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment