Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 43455 invoked from network); 10 Nov 2009 10:44:56 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 10 Nov 2009 10:44:56 -0000 Received: (qmail 71508 invoked by uid 500); 10 Nov 2009 10:44:55 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 71435 invoked by uid 500); 10 Nov 2009 10:44:54 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 71425 invoked by uid 99); 10 Nov 2009 10:44:54 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 10 Nov 2009 10:44:54 +0000 X-ASF-Spam-Status: No, hits=-2.6 required=5.0 tests=BAYES_00 X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of karel.minarik@gmail.com designates 209.85.218.218 as permitted sender) Received: from [209.85.218.218] (HELO mail-bw0-f218.google.com) (209.85.218.218) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 10 Nov 2009 10:44:51 +0000 Received: by bwz10 with SMTP id 10so4583795bwz.35 for ; Tue, 10 Nov 2009 02:44:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:from:to :in-reply-to:content-type:content-transfer-encoding:mime-version :subject:date:references:x-mailer; bh=gnTSugsGto/aPvI72W0n7hTI34/11RtsJLNYs3YRUMo=; b=m0esvR9dFC4W7zsHPe2dnpkuED7LzJpz52ZHOq8e5jWT7RkgghYP857ld25NPqPBo+ BkyLuLz8Zz0TOyMvFYkGAAKbwfSDlKLjiR0SKH9OMq2VLja9hirtHiJjuUI0i6PCVIcq Sazhs6WvjT8sXVFqf4P2ctqyYMzw/gNywGu+k= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:from:to:in-reply-to:content-type :content-transfer-encoding:mime-version:subject:date:references :x-mailer; b=mOo4P6zm7NReg400NrfwH22MBl2pA1bzT854FaQa5sYWobiYZyE3fy0SNP8FE4ia6k 5yYaHqvAOruDMw0EOAmGd3nT2ykWGFpAaASPNJR1foH8kZLJKSIc7SObuc0rf1PmS+iW PVzd5/kjTNLIQSy08muVnAcPuDFkGMTDmH6pE= Received: by 10.204.156.3 with SMTP id u3mr3592908bkw.179.1257849870456; Tue, 10 Nov 2009 02:44:30 -0800 (PST) Received: from ?192.168.1.102? (customer-79-127-150-226.net.angelnet.cz [79.127.150.226]) by mx.google.com with ESMTPS id z15sm894554fkz.44.2009.11.10.02.44.28 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 10 Nov 2009 02:44:28 -0800 (PST) Message-Id: <5B348DFD-D44B-48F2-8438-2F5FD63F9317@gmail.com> From: =?UTF-8?Q?Karel_Mina=C5=99=C3=ADk?= To: user@couchdb.apache.org In-Reply-To: <20091107215841.GC9046@uk.tiscali.com> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v936) Subject: Re: Tests/TDD for CouchDB views Date: Tue, 10 Nov 2009 11:44:27 +0100 References: <177E2090-776A-4C2D-9BFB-89BF4F074DFB@gmail.com> <20091107215841.GC9046@uk.tiscali.com> X-Mailer: Apple Mail (2.936) Hello, On 7.Nov, 2009, at 22:58 , Brian Candler wrote: >> * How do would you write/implement tests for your views? > I don't see in principle why it can't be any different to normal > tests. That > is, you ... of course, it is not different *in principle* at all. I am specifically curious about concrete strategies/techniques/best practices or ways *how* to do it. Eg., Jan has a fixture directly in the design document: how does one work with it then? Is this a good way to TDD views? >> * What is the recommended practice for writing the views? In Futon? >> In >> an editor and uploading them to db via couchapp or similar? Via >> CouchRest or similar layer? > I do the latter (using my own CouchTiny rather than CouchRest). Your > views > are source-controlled together with the rest of your application, your > application can populate the design docs when required, and you can > integrate your view tests with your application tests just as you > wish. Yes, that's one way of thinking about this. But, in fact, when I am thinking about "mental shifts" Couch brings to my RDBMS-based experience, I don't think it's the one ot the best way. In a standard Rails app, for example, database is *usually* (please note emphasis) just dumb storage for data. You model the domain, manage validations, etc in your application code. With Couch, as I see it, it would make much more sense to "de-couple" the database from the application. First, "my" app is not neccessarily the only one working with the database, given MVCC/replication/ standalone couchapps/etc. (And that I tend to see as good and awesome thing.) Second, Couch provides relatively rich functionality without any "middleware" -- think polling the _changes API or the _update hooks. My knowledge here is severely limited, but this seems to me like a big (and, again, awesome) difference to the usual ways. So I am not convinced that tying the view tests/development/generation to the app is neccessarily the best way. That's why I was asking about concrete strategies, because I couldn't find almost *any* documentation on this. >> * Is there a way to automatically run such test suites? (Via >> browser, or >> something like Rhino?) > Same. Sure: again, I am sorry, but was asking about some specific, real- world info. After some investigation, using couchjs for running the JS code would be much better fit. But, is there any info/tutorial? > ou can set up 'test', 'development' and 'production' environments for > CouchDB just as ActiveRecord does, and this is how I handle it. See > http://github.com/candlerb/couchtiny/blob/master/doc/RAILS.rdoc Thanks for the link! So, you basically declare the view JS code in your model (`define_view "Foo_by_bar"`) and let CouchTiny upload it to the database? While I see the point here, I would rather not tie views to the application code in this way (as said above). But, again, I might be seriously mistaken about this. I would highly appreciate any info, or just opinion/perspective on this... Best, Karel