
Security News
New Website “Is It Really FOSS?” Tracks Transparency in Open Source Distribution Models
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
== 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
== Scopes
Net recorder makes it easy to add a 'scope' to your recordings. Fakeweb doesn't have a way to name a response. If you make a request to the same url twice and get a different response both times, fakeweb just stores the responses in an array and returns them in order. This means that whatever you are testing will have to maintain the order or else you won't get the correct mocked data for your tests. So netrecorder allows you to set a scope that can be used when registering with fakeweb.
To record using scopes:
if NetRecorder.recording? NetRecorder.scope = 'first request' # request www.something.com # make a change that alters the return value from www.something.com NetRecorder.scope = "second request" # request www.something.com end
To register the scoped cache with fakeweb:
if !NetRecorder.recording? FakeWeb.clean_registry # This will clear out any previous registrations so that our scope will not be added to the array of reponses NetRecorder.register_scope(scenario.name) end
== Cucumber Example
see http://cukes.info for more info on testing with Cucumber
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
Before do |scenario| if NetRecorder.recording? NetRecorder.scope = scenario.name else FakeWeb.clean_registry NetRecorder.register_scope(scenario.name) end end
record mode (command line)
rake features RECORD_NET_CALLS=true
cache mode (command line)
rake features
== Similar projects
StaleFish[http://github.com/jsmestad/stale_fish]
FAQs
Unknown package
We found that netrecorder demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.