file manager pushes apps

This commit is contained in:
Chris Anderson 2008-09-16 11:14:25 -04:00
parent bb8371a718
commit 2356df978e
2 changed files with 105 additions and 0 deletions

View file

@ -24,6 +24,52 @@ describe CouchRest::FileManager do
end
end
describe CouchRest::FileManager, "generating an app" do
before(:all) do
@appdir = File.expand_path(File.dirname(__FILE__)) + '/fixtures/couchapp'
`rm -rf #{@appdir}`
`mkdir -p #{@appdir}`
CouchRest::FileManager.generate_app(@appdir)
end
it "should create an attachments directory" do
Dir["#{@appdir}/*"].select{|x|x =~ /attachments/}.length.should == 1
end
it "should create a views directory" do
Dir["#{@appdir}/*"].select{|x|x =~ /views/}.length.should == 1
end
it "should create index.html" do
html = File.open("#{@appdir}/attachments/index.html").read
html.should match(/DOCTYPE/)
end
it "should create an example view" do
map = File.open("#{@appdir}/views/example-map.js").read
map.should match(/function\(doc\)/)
reduce = File.open("#{@appdir}/views/example-reduce.js").read
reduce.should match(/rereduce/)
end
end
describe CouchRest::FileManager, "pushing an app" do
before(:all) do
@cr = CouchRest.new(COUCHHOST)
@db = @cr.database(TESTDB)
@db.delete! rescue nil
@db = @cr.create_db(TESTDB) rescue nil
@appdir = File.expand_path(File.dirname(__FILE__)) + '/fixtures/couchapp'
`rm -rf #{@appdir}`
`mkdir -p #{@appdir}`
CouchRest::FileManager.generate_app(@appdir)
@fm = CouchRest::FileManager.new(TESTDB, COUCHHOST)
r = @fm.push_app(@appdir, "couchapp")
end
it "should create a design document" do
lambda{@db.get("_design/couchapp")}.should_not raise_error
end
end
describe CouchRest::FileManager, "pushing views" do
before(:all) do
@cr = CouchRest.new(COUCHHOST)