Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
VCR not enough? Record arbitrary method invocations for later playback.
Ruby
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
spec
.gitignore
Gemfile
LICENSE.txt
README.md
Rakefile
camcorder.gemspec

README.md

Camcorder

Need to have VCR-like functionality for more than just http? Wait no more. This gem allows you to record arbitrary method invocations from arbitrary objects.

require 'camcorder'

imap = Camcorder::Proxy.new(Net::IMAP, imap_host, imap_port, imap_ssl, nil, false)
imap.login(username, decrypted_password)
imap.search(query)
imap.disconnect

The above code will create an actual Net::IMAP object the first time around. Subsequent invocations will not, instead using recorded values.

For convenience, Camcorder provides a way to intercept the constructor for a class:

require 'camcorder'

Camcorder.intercept_constructor(Net::IMAP)

imap = Net::IMAP.new(imap_host, imap_port, imap_ssl, nil, false)
imap.login(username, decrypted_password)
imap.search(query)
imap.disconnect

Side Effects

By default, Camcorder matches up a method invocation to a recording based on the passed in arguments. Methods with side effects need to be explicitly noted:

require 'camcorder'

Camcorder.intercept_constructor(Net::IMAP) do
  methods_with_side_effects :examine, :select
end

imap = Net::IMAP.new(imap_host, imap_port, imap_ssl, nil, false)
imap.login(username, decrypted_password)
imap.select('INBOX')
imap.search(query)
imap.select('Sent Items') # will cause the `search` call below to return a different value
imap.search(query)
imap.disconnect

Installation

Add this line to your application's Gemfile:

gem 'camcorder'

And then execute:

bundle

Or install it yourself as:

gem install camcorder

Usage with Rspec

In your spec_helper.rb file:

require 'camcorder/rspec'

Camcorder.config.recordings_dir = 'spec/recordings'

Contributing

  1. Fork it ( http://github.com/ghempton/camcorder/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request
Something went wrong with that request. Please try again.