couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lena Herrmann <l...@zeromail.org>
Subject Small changes to jquery.couch.js ajax method for better testing?
Date Mon, 29 Mar 2010 23:40:19 GMT
Hi,

I think it is very bad style when you change code only in order to make 
it more testable. But I can't think of a way to test some methods 
without these small changes to jquery.couch.js:

http://gist.github.com/348527

Look at lines 33-35 and 37. Examples why the changes are needed are here:

http://github.com/lenalena/couchdb/blob/testsuite/share/www/spec/jquery_couch_js_class_methods_spec.js#L38-47

http://github.com/lenalena/couchdb/blob/testsuite/share/www/spec/jquery_couch_js_instance_methods_1_spec.js#L69-71

The problem is that the details of the ajax request are encapsulated, 
which is a good thing. Whenever possible I try to test the results of 
the method and not its internals. But some methods only trigger 
something on couchdb, and it's hard or impossible to check the results 
(compact or cleanup view, for example).

1) Does someone have a better idea how to test the stuff, or

2) are these changes acceptable, or

3) are they not and the code should better stay untested?

What do you think?

Lena


Mime
View raw message