Rafael Souza Desenvolvimento Web

Posted
19 September 2009 @ 8pm

No Comments Yet

FakePage

FakePage is a simple class that use rack and thin to create an environment where you can make tests simulating real web requests.

Example

page = FakePage.new('home', :body => 'this is my home page')
# Net::HTTP
puts Net::HTTP.get(page.url)
# Curb
puts Curl::Easy.perform(page.url).body_str

Also, you can specify the HTTP method

FakePage.new('another_page', :method => :get, :body => 'another body page')

Or

FakePage.get('do_get', :body => 'another body page')
FakePage.post('do_post', :body => 'another body page')
FakePage.put('do_put', :body => 'another body page')
FakePage.delete('do_delete', :body => 'another body page')

Others options are: code and content_type


Back to Home