require 'vcr'

module Core::Repositories
  class VCR < SimpleDelegator
    def method_missing(method_name, *args, &block)
      klass = if __getobj__.class.superclass == SimpleDelegator
                __getobj__.__getobj__.class
              else
                __getobj__.class
              end

      cassette_name = [klass.name.underscore, method_name, *args].join('/')

      ::VCR.use_cassette(cassette_name) { super }
    end
  end
end

Introduce a VCR repository for acceptance tests
Introduce a VCR repository for acceptance tests

We'll use our VCR repository to wrap HTTP backed repositories at
runtime to provide us with fast, deterministic repositories when we
perform our acceptance tests.
