Skip to content

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

License

Notifications You must be signed in to change notification settings

mfpiccolo/minitest-vcr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

76 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages