Skip to content

Commit

Permalink
test CLI behavior with nixt, starting with harp init
Browse files Browse the repository at this point in the history
  • Loading branch information
zeke committed Feb 16, 2014
1 parent 3d316c6 commit b868973
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@
"mocha": "1.8.1",
"should": "1.2.2",
"request": "2.30.0",
"cheerio": "~0.13.1"
"cheerio": "~0.13.1",
"nixt": "~0.3.0"
},
"scripts": {
"test": "mocha --reporter spec"
Expand Down
52 changes: 52 additions & 0 deletions test/harp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
var nixt = require('nixt')

describe("harp init", function() {

beforeEach(function(done){
nixt()
.run("rm -rf /tmp/harp && mkdir /tmp/harp")
.exist("/tmp/harp")
.end(done)
})

it("downloads the default boilerplate if it's not set", function(done) {
nixt()
.run('harp init /tmp/harp')
.stdout(/Downloading.*harp-boilerplates\/default/)
.stdout(/Initialized project at \/tmp\/harp/)
.exist('/tmp/harp/404.jade')
.exist('/tmp/harp/_layout.jade')
.exist('/tmp/harp/index.jade')
.exist('/tmp/harp/main.less')
.end(done)
})

it("defaults to the harp-boilerplates github org when given a shorthand pattern", function(done) {
nixt()
.run('harp init /tmp/harp -b hb-start')
.stdout(/Downloading.*harp-boilerplates\/hb-start/)
.exist('/tmp/harp/public')
.end(done)
})

it("honors -b option when given a user/repo pattern", function(done) {
nixt()
.run('harp init /tmp/harp -b zeke/harp-sample')
.stdout(/Downloading.*zeke\/harp-sample/)
.exist('/tmp/harp/README.md')
.exist('/tmp/harp/index.jade')
.end(done)
})

it("doesn't overwrite an existing directory", function(done) {
nixt()
.run('harp init /tmp/harp')
.end(function() {
nixt()
.run('harp init /tmp/harp')
.stdout(/Sorry,.*must be empty/)
.end(done)
})
})

})

0 comments on commit b868973

Please sign in to comment.