From e3da7d5c8f1d8caf8d44cbfb63733b1549493f28 Mon Sep 17 00:00:00 2001 From: Chris Anderson Date: Tue, 16 Sep 2008 11:15:36 -0400 Subject: [PATCH] specs for couchapp --- spec/couchapp_spec.rb | 57 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 spec/couchapp_spec.rb diff --git a/spec/couchapp_spec.rb b/spec/couchapp_spec.rb new file mode 100644 index 0000000..c8ae0b0 --- /dev/null +++ b/spec/couchapp_spec.rb @@ -0,0 +1,57 @@ +require File.dirname(__FILE__) + '/spec_helper' + +describe "couchapp" do + before(:all) do + @fixdir = File.expand_path(File.dirname(__FILE__)) + '/fixtures/couchapp-test' + @couchapp = File.expand_path(File.dirname(__FILE__)) + '/../bin/couchapp' + `rm -rf #{@fixdir}` + `mkdir -p #{@fixdir}` + @run = "cd #{@fixdir} && #{@couchapp}" + + end + + describe "--help" do + it "should output the opts" do + `#{@run} --help`.should match(/Usage/) + end + end + + describe "generate my-app" do + it "should create an app directory" do + `#{@run} generate my-app`.should match(/generating/i) + Dir["#{@fixdir}/*"].select{|x|x =~ /my-app/}.length.should == 1 + end + it "should create a views directory" do + `#{@run} generate my-app`.should match(/generating/i) + Dir["#{@fixdir}/my-app/*"].select{|x|x =~ /views/}.length.should == 1 + end + end + + describe "push my-app #{TESTDB}" do + before(:all) do + @cr = CouchRest.new(COUCHHOST) + @db = @cr.database(TESTDB) + @db.delete! rescue nil + @db = @cr.create_db(TESTDB) rescue nil + `#{@run} generate my-app` + end + it "should create the design document with the app name" do + `#{@run} push my-app #{TESTDB}` + lambda{@db.get("_design/my-app")}.should_not raise_error + end + end + + describe "push my-app my-design #{TESTDB}" do + before(:all) do + @cr = CouchRest.new(COUCHHOST) + @db = @cr.database(TESTDB) + @db.delete! rescue nil + @db = @cr.create_db(TESTDB) rescue nil + `#{@run} generate my-app` + end + it "should create the design document" do + + end + end +end +