No commit activity in last 3 years
No release in over 3 years
Record network responses for easy stubbing of external calls
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 0

Runtime

 Project Readme

NetRecorder¶ ↑

Record network responses for easy stubbing of external calls.

Net recorder hooks into NetHTTP to record the outgoing request path and method and caches the response. Then you can switch on fakeweb and it will use the cache from the recording.

Requirements¶ ↑

gem install fakeweb

Install¶ ↑

gem install netrecorder

Usage¶ ↑

Anywhere you use fakeweb, you can use net recorder.

Record all responses:

NetRecorder.config do |config|
  config.cache_file       = File.join(RAILS_ROOT, 'fakeweb')
  config.record_net_calls = true
end

Save recorded responses:

NetRecorder.cache!

Use recorded cache with fakeweb:

NetRecorder.config do |config|
  config.cache_file = File.join(RAILS_ROOT, 'features', 'support', 'fakeweb')
  config.fakeweb    = true
end

Cucumber Example¶ ↑

see cukes.info for more info on testing with Cucumber

# Find me in features/support/netrecorder.rb

NetRecorder.config do |config|
  config.cache_file = "#{File.dirname(__FILE__)}/../support/fakeweb"    
  if ENV['RECORD_WEB']
    config.record_net_calls = true
  else
    config.fakeweb = true
    FakeWeb.allow_net_connect = false
  end
end 

at_exit do
  if NetRecorder.recording?
    NetRecorder.cache!
  end
end

record mode (command line)

>> rake features RECORD_NET_CALLS=true

cache mode (command line)

>> rake features