Skip to content

Instantly share code, notes, and snippets.

@wallace
Forked from chrisk/cucumber_fakeweb_hook.rb
Created September 4, 2010 14:43
Show Gist options
  • Save wallace/565231 to your computer and use it in GitHub Desktop.
Save wallace/565231 to your computer and use it in GitHub Desktop.
# config/initializers/cucumber_fakeweb_hook.rb
# If this looks like a test server process, make its FakeWeb available to other
# processes via DRb. That way Cucumber (which runs in a separate process) can
# dynamically register stubs for this server to use.
if Rails.env =~ /^culerity/
require 'drb'
require 'fakeweb'
DRb.start_service("druby://localhost:30010", FakeWeb)
puts "=> FakeWeb is available at #{DRb.uri}"
end
# features/support/env.rb
require 'drb'
DRb.start_service
$remote_fakeweb = DRbObject.new(nil, "druby://localhost:30010")
# Clean FakeWeb's registry before each scenario
Before do
$remote_fakeweb.clean_registry
end
# features/step_definitions/fakeweb_steps.rb
Given "the example site responds with a 200 OK" do
$remote_fakeweb.register_uri(:get, "http://example.com", :status => [200, "OK"])
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment