module VCR

Overview

TODO Write documentation for VCR

Included Modules

Extended Modules

Defined in:

vcr.cr
vcr/methods.cr
vcr/version.cr

Constant Summary

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

Class Method Summary

Instance Method Summary

Class Method Detail

def self.configure(&) #

[View source]
def self.settings #

[View source]

Instance Method Detail

def cassette_name #

The name of the cassette


[View source]
def in_order? #

Returns true if the casset should record requests in order


[View source]
def sequence #

The current sequence, calling this will increment the value


[View source]
def settings #

[View source]
def 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

[View source]