unit testing offline with mechanize

A

Adam Akhtar

Although mechanize is designed to navigate around web pages online, is
there a way to load up webpages saved to the harddrive for the purposes
of quick unit testing. Constantly accessing online sources slows down
the tests. I tried to simply type the file name instead of the url in
agent.get("..") but it complains. I tried get_file and that didnt work
either.

any help greatly appreciated.
 
P

Phlip

Adam said:
Although mechanize is designed to navigate around web pages online, is
there a way to load up webpages saved to the harddrive for the purposes
of quick unit testing. Constantly accessing online sources slows down
the tests. I tried to simply type the file name instead of the url in
agent.get("..") but it complains. I tried get_file and that didnt work
either.

That sounds like the assumption you must serve a page through a web server just
to unit test it.

Why not do what Rails tests do - call the same method a server would call to
generate a page, then read it as a string and test it?
 
L

Lex Williams

a tip would be to save the page with mechanize , read it then locally
within a script , get your regexes ( or whatever you're doing to parse
the data ) right , and then try them on the online version .
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,152
Latest member
LorettaGur
Top