module

VCR

Inherits Habitat::SettingsHelpers < Habitat::TempConfig

TODO: Write documentation for VCR

Constants

HABITAT_SETTINGS = [{decl: cassette_library_dir : String = "spec/fixtures/vcr", example: nil, validation: nil}] of Nil
VERSION = "0.2.2"

Class methods

configure
Source
settings
Source

Instance methods

cassette_name

The name of the cassette

Source
in_order?

Returns true if the casset should record requests in order

Source
sequence

The current sequence, calling this will increment the value

Source
settings
Source
use_cassette(cassette_name : String, *args, &block)

Defines the cassette to load for recording. Optional arguments can also be passed.

Options:

  • :record - will delete any VCR files in this cassette so new ones can be generated
  • :in_order - will record requests in order (allows multiple records of the same request). Should be used when you expect the result to be different on a second request

Example:

VCR.use_cassette("cassette-one") do
  r1 = HTTP::Client.get("https://jsonplaceholder.typicode.com/todos")
end

Record new responses, in order, so i can verify the delete worked

VCR.use_cassette("cassette-one", :record, :in_order) do
  r1 = HTTP::Client.get("https://jsonplaceholder.typicode.com/todos")
  HTTP::Client.delete("https://jsonplaceholder.typicode.com/todos/1")
  r2 = HTTP::Client.get("https://jsonplaceholder.typicode.com/todos")
end
Source

Nested types