require 'spec/helper' describe 'em-http mock' do before(:each) do EventMachine::MockHttpRequest.reset_registry! EventMachine::MockHttpRequest.reset_counts! end it "should serve a fake http request from a file" do EventMachine::MockHttpRequest.register_file('http://www.google.ca:80/', :get, File.join(File.dirname(__FILE__), 'fixtures', 'google.ca')) EM.run { http = EventMachine::MockHttpRequest.new('http://www.google.ca/').get http.errback { fail } http.callback { http.response.should == File.read(File.join(File.dirname(__FILE__), 'fixtures', 'google.ca')).split("\n\n", 2).last EventMachine.stop } } EventMachine::MockHttpRequest.count('http://www.google.ca:80/', :get).should == 1 end it "should serve a fake http request from a string" do data = <<-HEREDOC HTTP/1.0 200 OK Date: Mon, 16 Nov 2009 20:39:15 GMT Expires: -1 Cache-Control: private, max-age=0 Content-Type: text/html; charset=ISO-8859-1 Set-Cookie: PREF=ID=9454187d21c4a6a6:TM=1258403955:LM=1258403955:S=2-mf1n5oV5yAeT9-; expires=Wed, 16-Nov-2011 20:39:15 GMT; path=/; domain=.google.ca Set-Cookie: NID=28=lvxxVdiBQkCetu_WFaUxLyB7qPlHXS5OdAGYTqge_laVlCKVN8VYYeVBh4bNZiK_Oan2gm8oP9GA-FrZfMPC3ZMHeNq37MG2JH8AIW9LYucU8brOeuggMEbLNNXuiWg4; expires=Tue, 18-May-2010 20:39:15 GMT; path=/; domain=.google.ca; HttpOnly Server: gws X-XSS-Protection: 0 X-Cache: MISS from . Via: 1.0 .:80 (squid) Connection: close Google
Web Images Videos Maps News Groups Gmail more »
iGoogle | Search settings | Sign in



 
  Advanced Search
  Language Tools
Search:

Google.ca offered in: fran?ais


Advertising Programs - Business Solutions - About Google - Go to Google.com

©2009 - Privacy