new capabilities for couchapp script
This commit is contained in:
parent
387bd704ef
commit
b62b77eee5
4 changed files with 88 additions and 17 deletions
|
@ -37,10 +37,17 @@ describe CouchRest::FileManager, "generating an app" do
|
|||
it "should create a views directory" do
|
||||
Dir["#{@appdir}/*"].select{|x|x =~ /views/}.length.should == 1
|
||||
end
|
||||
it "should create a foo directory" do
|
||||
Dir["#{@appdir}/*"].select{|x|x =~ /foo/}.length.should == 1
|
||||
end
|
||||
it "should create index.html" do
|
||||
html = File.open("#{@appdir}/attachments/index.html").read
|
||||
html = File.open("#{@appdir}/_attachments/index.html").read
|
||||
html.should match(/DOCTYPE/)
|
||||
end
|
||||
it "should create bar.txt" do
|
||||
html = File.open("#{@appdir}/foo/bar.txt").read
|
||||
html.should match(/Couchapp will/)
|
||||
end
|
||||
it "should create an example view" do
|
||||
map = File.open("#{@appdir}/views/example-map.js").read
|
||||
map.should match(/function\(doc\)/)
|
||||
|
@ -75,6 +82,27 @@ describe CouchRest::FileManager, "pushing an app" do
|
|||
doc = @db.get("_design/couchapp")
|
||||
doc['_attachments']['index.html']["content_type"].should == 'text/html'
|
||||
end
|
||||
it "should push bar.txt" do
|
||||
doc = @db.get("_design/couchapp")
|
||||
doc["foo"].should_not be_nil
|
||||
doc["foo"]["bar"].should include("Couchapp will")
|
||||
end
|
||||
it "should push json as json" do
|
||||
File.open("#{@appdir}/test.json",'w') do |f|
|
||||
f.write("[1,2,3,4]")
|
||||
end
|
||||
r = @fm.push_app(@appdir, "couchapp")
|
||||
doc = @db.get("_design/couchapp")
|
||||
doc['test'].should == [1,2,3,4]
|
||||
end
|
||||
it "should apply keys from doc.json directly to the doc" do
|
||||
File.open("#{@appdir}/doc.json",'w') do |f|
|
||||
f.write('{"magical":"so magic"}')
|
||||
end
|
||||
r = @fm.push_app(@appdir, "couchapp")
|
||||
doc = @db.get("_design/couchapp")
|
||||
doc['magical'].should == "so magic"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue