Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Use VCR for faster testing

  • Loading branch information...
commit b4e7cb9fca6ddcff270edf5e1ddddc70bf828e3a 1 parent 1e031d4
rylwin authored May 01, 2012
1  .gitignore
... ...
@@ -1 +1,2 @@
1 1
 *.swp
  2
+spec/cassettes
4  Gemfile
@@ -6,7 +6,9 @@ gem "activesupport", ">= 2.3.5"
6 6
 # Add dependencies to develop your gem here.
7 7
 # Include everything needed to run rake, tests, features, etc.
8 8
 group :development do
9  
-  gem "rspec", "~> 2.8.0"
  9
+  gem "rspec", "~> 2.8.0" 
  10
+  gem 'vcr', '~> 2.1.0'
  11
+  gem 'fakeweb'
10 12
   gem "rdoc", "~> 3.12"
11 13
   gem "bundler", "~> 1.0.0"
12 14
   gem "jeweler", "~> 1.8.3"
4  Gemfile.lock
@@ -5,6 +5,7 @@ GEM
5 5
       i18n (~> 0.6)
6 6
       multi_json (~> 1.0)
7 7
     diff-lcs (1.1.3)
  8
+    fakeweb (1.3.0)
8 9
     git (1.2.5)
9 10
     i18n (0.6.0)
10 11
     jeweler (1.8.3)
@@ -26,6 +27,7 @@ GEM
26 27
     rspec-expectations (2.8.0)
27 28
       diff-lcs (~> 1.1.2)
28 29
     rspec-mocks (2.8.0)
  30
+    vcr (2.1.1)
29 31
 
30 32
 PLATFORMS
31 33
   ruby
@@ -33,7 +35,9 @@ PLATFORMS
33 35
 DEPENDENCIES
34 36
   activesupport (>= 2.3.5)
35 37
   bundler (~> 1.0.0)
  38
+  fakeweb
36 39
   jeweler (~> 1.8.3)
37 40
   rcov
38 41
   rdoc (~> 3.12)
39 42
   rspec (~> 2.8.0)
  43
+  vcr (~> 2.1.0)
3  spec/merchant_account_spec.rb
... ...
@@ -1,6 +1,6 @@
1 1
 require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2 2
 
3  
-describe PaymentsGateway::MerchantAccount do
  3
+describe PaymentsGateway::MerchantAccount, :vcr => { :re_record_interval => 1.day } do
4 4
 
5 5
   before(:each) do
6 6
     # Test account data
@@ -13,6 +13,7 @@
13 13
   end
14 14
 
15 15
   context "when I create a new client" do
  16
+
16 17
     before(:each) do
17 18
       @client = PaymentsGateway::Client.new(
18 19
         :first_name => 'John', 
9  spec/spec_helper.rb
... ...
@@ -1,12 +1,21 @@
1 1
 $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2 2
 $LOAD_PATH.unshift(File.dirname(__FILE__))
3 3
 require 'rspec'
  4
+require 'vcr'
4 5
 require 'payments_gateway'
5 6
 
  7
+VCR.configure do |c|
  8
+  c.cassette_library_dir     = 'spec/cassettes'
  9
+  c.hook_into                :fakeweb
  10
+  c.configure_rspec_metadata!
  11
+end
  12
+
6 13
 # Requires supporting files with custom matchers and macros, etc,
7 14
 # in ./support/ and its subdirectories.
8 15
 Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9 16
 
10 17
 RSpec.configure do |config|
  18
+  config.extend VCR::RSpec::Macros
  19
+  config.treat_symbols_as_metadata_keys_with_true_values = true
11 20
   #config.backtrace_clean_patterns = []
12 21
 end

0 notes on commit b4e7cb9

Please sign in to comment.
Something went wrong with that request. Please try again.