Permalink
Browse files

Fixed render command and added render tests

Was due to the data attribute abstraction out into a instance property
instead. The instances were still being created with it being sent as
an attribute, so we handle this now in the constructor.
  • Loading branch information...
1 parent de5d015 commit db99e145f5c24469db4197824f5b3609ab726ebc @balupton balupton committed Jul 19, 2012
View
@@ -10,7 +10,8 @@ debug:
cd test; node --debug-brk ../bin/docpad run
test-clean:
- rm -Rf test/node_modules test/out
+ rm -Rf test/node_modules test/out test/npm-debug.log
+ cd test; npm install
test-prepare:
make test-clean
@@ -25,8 +26,8 @@ install:
clean:
rm -Rf lib node_modules/ npm-debug.log
- make test-clean
npm install
+ make test-clean
publish:
make clean
@@ -78,6 +78,7 @@ class ConsoleInterface
.description("render the file at <path> and output its results to stdout")
.action (command) ->
commander.debug ?= 5
+ commander.checkVersion = false
consoleInterface.performAction(command,consoleInterface.render)
# generate
@@ -289,7 +290,7 @@ class ConsoleInterface
renderDocument = ->
docpad.action 'render', opts, (err,result) ->
return docpad.fatal(err) if err
- process.stdout.write(result+'\n')
+ process.stdout.write(result)
next()
# Timeout if we don't have stdin
@@ -131,6 +131,10 @@ class FileModel extends Model
initialize: (attrs,opts) ->
# Prepare
{outDirPath,stat,data} = opts
+ if attrs.data?
+ data = attrs.data
+ delete attrs.data
+ delete @attributes.data
# Apply
@outDirPath = outDirPath if outDirPath
@@ -1,5 +1,6 @@
# RequirestestServer
balUtil = require('bal-util')
+fs = require('fs')
chai = require('chai')
expect = chai.expect
joe = require('joe')
@@ -9,33 +10,69 @@ _ = require('underscore')
# Configuration
# Vars
-port = 9780
docpadPath = __dirname+'/../..'
rootPath = docpadPath+'/test'
-srcPath = rootPath+'/src'
-outPath = rootPath+'/out'
-outExpectedPath = rootPath+'/out-expected'
-baseUrl = "http://localhost:#{port}"
-testWait = 1000*60*5 # five minutes
+renderPath = rootPath+'/render'
+expectPath = rootPath+'/render-expected'
cliPath = docpadPath+'/bin/docpad'
-# Configure DocPad
-docpadConfig =
- growl: false
- port: port
- rootPath: rootPath
- logLevel: if process.env.TRAVIS_NODE_VERSION? then 7 else 5
- skipUnsupportedPlugins: false
- catchExceptions: false
-
# -------------------------------------
# Tests
joe.suite 'docpad-render', (suite,test) ->
- test 'markdown-file', (done) ->
- command = [cliPath, 'render', 'src/documents/render-single-extensions-false.md']
- balUtil.spawn command, {cwd:rootPath}, (err,stdout,stderr,code,signal) ->
- console.log({stdout,err})
- done(err)
+ # Check render physical files
+ inputs = [
+ {
+ filename: 'markdown-with-extension.md'
+ stdout: '*awesome*'
+ }
+ {
+ filename: 'markdown-with-extensions.html.md'
+ stdout: '<p><em>awesome</em></p>'
+ }
+ ]
+ balUtil.each inputs, (input) ->
+ test input.filename, (done) ->
+ command = [cliPath, 'render', renderPath+'/'+input.filename]
+ balUtil.spawn command, {cwd:rootPath}, (err,stdout,stderr,code,signal) ->
+ return done(err) if err
+ expect(stdout).to.equal(input.stdout)
+ done()
+
+ # Check rendering stdin inputs
+ inputs = [
+ {
+ testname: 'markdown without extension'
+ filename: ''
+ stdin: '*awesome*'
+ stdout: '*awesome*'
+ }
+ {
+ testname: 'markdown with extension'
+ filename: 'markdown'
+ stdin: '*awesome*'
+ stdout: '<p><em>awesome</em></p>'
+ }
+ {
+ testname: 'markdown with extensions'
+ filename: '.html.md'
+ stdin: '*awesome*'
+ stdout: '<p><em>awesome</em></p>'
+ }
+ {
+ testname: 'markdown with filename'
+ filename: 'example.html.md'
+ stdin: '*awesome*'
+ stdout: '<p><em>awesome</em></p>'
+ }
+ ]
+ balUtil.each inputs, (input) ->
+ test input.testname, (done) ->
+ command = [cliPath, 'render']
+ command.push(input.filename) if input.filename
+ balUtil.spawn command, {stdin:input.stdin,cwd:rootPath}, (err,stdout,stderr,code,signal) ->
+ return done(err) if err
+ expect(stdout).to.equal(input.stdout)
+ done()
@@ -0,0 +1 @@
+*awesome*
@@ -0,0 +1 @@
+*awesome*

0 comments on commit db99e14

Please sign in to comment.