Skip to content

Instantly share code, notes, and snippets.

@tommeier
Created April 16, 2012 04:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tommeier/2396327 to your computer and use it in GitHub Desktop.
Save tommeier/2396327 to your computer and use it in GitHub Desktop.
VCR with placeholders
use_vcr_cassette 'some/cassette', :tag => :bad_staging_api
VCR.configure do |c|
c.cassette_library_dir = Rails.root.join('spec/fixtures/vcr_cassettes')
c.hook_into :webmock
c.default_cassette_options = { :record => :new_episodes }
c.before_record(:bad_staging_api) do |interaction, cassette|
interaction.response.body.gsub!(/TotalRate\=["']([^"']+)["']/, %q{TotalRate="<TOTAL_RATE>"})
end
c.before_playback(:bad_staging_api) do |interaction|
interaction.filter!('<TOTAL_RATE>', "836.00")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment