|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
On Tue, May 27, 2008 at 7:59 AM, Tobias Weber <towb@gmx.net> wrote:
> Hi, > my programm uses the HTTPClient gem to call a backend that was > originally made for AJAX-without-the-X. Mainly it does POST without > expecting any result. > > How do you test this? Hello Tobias, I've been through the same routine for an http client (http://rufus.rubyforge.org/rufus-verbs). I've written a test server based on Webrick just for the unit tests : http://github.com/jmettraux/rufus-ve.../test/items.rb (see the class ItemServer as a starting point). It's then used in the startup/teadown of my unit tests : http://github.com/jmettraux/rufus-ve...st/testbase.rb Maybe that'll inspire you. Webrick comes with Ruby, it's quite handy. You don't have to worry about threads [for now], the server will run in its own. I'm sure someone else will come with an even better piece of advice. Freundliche Gruesse, -- John Mettraux - http://jmettraux.wordpress.com |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
> I've been through the same routine for an http client
> (http://rufus.rubyforge.org/rufus-verbs). I've written a test server > based on Webrick just for the unit tests : > > http://github.com/jmettraux/rufus-ve.../test/items.rb > > (see the class ItemServer as a starting point). > > It's then used in the startup/teadown of my unit tests : > > http://github.com/jmettraux/rufus-ve...st/testbase.rb > > Maybe that'll inspire you. I have done it that way, and I have also used Mocha to simply make the HTTP client magically return whatever result you want. I have to recommend Mocha over mocking a server over a wire - no matter how short that wire may be! You are not inventing a web application stack yourself, so you just need a mock that lets you focus on cleaning and refactoring your own code. |
|
![]() |
| Outils de la discussion | |
|
|