Skip to content

Instantly share code, notes, and snippets.

@bru
Created May 15, 2014 08:05
Show Gist options
  • Save bru/4e2cff8ae18b8e213183 to your computer and use it in GitHub Desktop.
Save bru/4e2cff8ae18b8e213183 to your computer and use it in GitHub Desktop.
Artifice example with more than one endpoint
require 'rubygems'
require 'artifice'
describe "MyArtifice" do
FakeTwoApp = proc do |env|
text = case env["PATH_INFO"]
when "/hello"
"world"
when "/foo"
"bar"
else
"WAT?!"
end
[200, {}, [text]]
end
before do
Artifice.activate_with(FakeTwoApp)
end
context "when requesting path 'hello'" do
let(:response) { Net::HTTP.get_response(URI.parse("http://artifice.com/hello")) }
it "should return 'world'" do
response.body.should == "world"
end
end
context "when requesting path 'foo'" do
let(:response) { Net::HTTP.get_response(URI.parse("http://artifice.com/foo")) }
it "should return 'bar'" do
response.body.should == "bar"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment