Allows VCR to automatically make cassetes with proper file paths using Minitest.
Ruby
Latest commit c485494 Nov 12, 2015 @mfpiccolo Bump version
Permalink
Failed to load latest commit information.
lib
test
.coveralls.yml
.gitignore
.travis.yml
Gemfile
LICENSE.txt
README.md
Rakefile
minitest-vcr.gemspec

README.md

minitest-vcr

Project Gem Release
Gem name minitest-vcr
License MIT
Version Gem Version
Continuous Integration Build Status
Test Coverage Coverage Status
Grade Code Climate
Dependencies Dependency Status
Homepage http://mfpiccolo.github.io/minitest-vcr
Documentation http://rdoc.info/github/mfpiccolo/minitest-vcr/frames
Issues https://github.com/mfpiccolo/minitest-vcr/issues

Description

Allows VCR to automatically make cassetes with proper file paths using Minitest.

Examples

Two main steps:

  1. Install and require the gem
  2. Add MinitestVcr::Spec.configure! before your tests load

The setup below will create a directory structre that looks like this:

|-- app_name
|  |-- test/
|    |-- cassettes/
|      |-- Example_Spec/
|        |-- an_example_group/
|          |-- with_a_nested_example_group/
|          `-- uses_a_cassette_for_an_example_group.yml
|    `-- example_test.rb
|    `-- test_helper.rb

An example test_helper file: app_name/test/test_helper.rb

require "minitest/autorun"
require "minispec-metadata"
require "vcr"
require "minitest-vcr"
require "webmock"
require "mocha/setup"
require "faraday"

VCR.configure do |c|
  c.cassette_library_dir = 'test/cassettes'
  c.hook_into :webmock
end

MinitestVcr::Spec.configure!

An example test file: app_name/test/example_test.rb

require "test_helper"

describe Example::Spec do

  # Notice here symbols are treated as true values
  # You could also do vcr: true
  describe 'an example group', :vcr do
    describe 'with a nested example group' do
      before do
        conn = Faraday.new
        @response = conn.get 'http://example.com'
      end
      it 'uses a cassette for any examples' do
        @response.wont_equal nil
      end
    end
  end

  # setting config
  describe 'an example group', vcr: { record: :all } do
    describe 'with a nested example group' do
      before do
        conn = Faraday.new
        @response = conn.get 'http://example.com'
      end
      it 'uses a cassette for any examples' do
        @response.wont_equal nil
      end
    end
  end
end

Requirements

Installation

Add this line to your application's Gemfile:

gem "minitest-vcr"

And then execute:

$ bundle

Or install it yourself as:

$ gem install minitest-vcr

Donating

Support this project and others by mfpiccolo via gittip.

Copyright

Copyright (c) 2013 Mike Piccolo

See LICENSE.txt for details.

Contributing

  1. Fork it ( http://github.com/mfpiccolo/minitest-vcr/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

githalytics.com alpha