Created
May 15, 2014 08:05
-
-
Save bru/4e2cff8ae18b8e213183 to your computer and use it in GitHub Desktop.
Artifice example with more than one endpoint
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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