Skip to content

Commit

Permalink
Use VCR for faster testing
Browse files Browse the repository at this point in the history
  • Loading branch information
rylwin committed May 2, 2012
1 parent 1e031d4 commit b4e7cb9
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Original file line Diff line number Diff line change
@@ -1 +1,2 @@
*.swp *.swp
spec/cassettes
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ gem "activesupport", ">= 2.3.5"
# Add dependencies to develop your gem here. # Add dependencies to develop your gem here.
# Include everything needed to run rake, tests, features, etc. # Include everything needed to run rake, tests, features, etc.
group :development do group :development do
gem "rspec", "~> 2.8.0" gem "rspec", "~> 2.8.0"
gem 'vcr', '~> 2.1.0'
gem 'fakeweb'
gem "rdoc", "~> 3.12" gem "rdoc", "~> 3.12"
gem "bundler", "~> 1.0.0" gem "bundler", "~> 1.0.0"
gem "jeweler", "~> 1.8.3" gem "jeweler", "~> 1.8.3"
Expand Down
4 changes: 4 additions & 0 deletions Gemfile.lock
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ GEM
i18n (~> 0.6) i18n (~> 0.6)
multi_json (~> 1.0) multi_json (~> 1.0)
diff-lcs (1.1.3) diff-lcs (1.1.3)
fakeweb (1.3.0)
git (1.2.5) git (1.2.5)
i18n (0.6.0) i18n (0.6.0)
jeweler (1.8.3) jeweler (1.8.3)
Expand All @@ -26,14 +27,17 @@ GEM
rspec-expectations (2.8.0) rspec-expectations (2.8.0)
diff-lcs (~> 1.1.2) diff-lcs (~> 1.1.2)
rspec-mocks (2.8.0) rspec-mocks (2.8.0)
vcr (2.1.1)


PLATFORMS PLATFORMS
ruby ruby


DEPENDENCIES DEPENDENCIES
activesupport (>= 2.3.5) activesupport (>= 2.3.5)
bundler (~> 1.0.0) bundler (~> 1.0.0)
fakeweb
jeweler (~> 1.8.3) jeweler (~> 1.8.3)
rcov rcov
rdoc (~> 3.12) rdoc (~> 3.12)
rspec (~> 2.8.0) rspec (~> 2.8.0)
vcr (~> 2.1.0)
3 changes: 2 additions & 1 deletion spec/merchant_account_spec.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,6 +1,6 @@
require File.expand_path(File.dirname(__FILE__) + '/spec_helper') require File.expand_path(File.dirname(__FILE__) + '/spec_helper')


describe PaymentsGateway::MerchantAccount do describe PaymentsGateway::MerchantAccount, :vcr => { :re_record_interval => 1.day } do


before(:each) do before(:each) do
# Test account data # Test account data
Expand All @@ -13,6 +13,7 @@
end end


context "when I create a new client" do context "when I create a new client" do

before(:each) do before(:each) do
@client = PaymentsGateway::Client.new( @client = PaymentsGateway::Client.new(
:first_name => 'John', :first_name => 'John',
Expand Down
9 changes: 9 additions & 0 deletions spec/spec_helper.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,12 +1,21 @@
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__)) $LOAD_PATH.unshift(File.dirname(__FILE__))
require 'rspec' require 'rspec'
require 'vcr'
require 'payments_gateway' require 'payments_gateway'


VCR.configure do |c|
c.cassette_library_dir = 'spec/cassettes'
c.hook_into :fakeweb
c.configure_rspec_metadata!
end

# Requires supporting files with custom matchers and macros, etc, # Requires supporting files with custom matchers and macros, etc,
# in ./support/ and its subdirectories. # in ./support/ and its subdirectories.
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f} Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}


RSpec.configure do |config| RSpec.configure do |config|
config.extend VCR::RSpec::Macros
config.treat_symbols_as_metadata_keys_with_true_values = true
#config.backtrace_clean_patterns = [] #config.backtrace_clean_patterns = []
end end

0 comments on commit b4e7cb9

Please sign in to comment.