- # Set things up for OpenID testing
- def openid_setup
- Net::HTTP.get_response(URI.parse("http://localhost:1123/"))
- rescue
- # It isn't, so start a new instance.
- rots = IO.popen("#{Rails.root}/vendor/gems/rots-0.2.1/bin/rots --silent")
-
- # Wait for up to 30 seconds for the server to start and respond before continuing
- 1.upto(30).each do
- begin
- sleep 1
- Net::HTTP.get_response(URI.parse("http://localhost:1123/"))
- # If the rescue block doesn't fire, ROTS is up and running and we can continue
- break
- rescue
- # If the connection failed, do nothing and repeat the loop
- next
- end
+ ##
+ # execute a block with a given set of HTTP responses stubbed
+ def with_http_stubs(stubs_file)
+ stubs = YAML.load_file(File.expand_path("../http/#{stubs_file}.yml", __FILE__))
+ stubs.each do |url, response|
+ stub_request(:get, Regexp.new(Regexp.quote(url))).to_return(:status => response["code"], :body => response["body"])