-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor addon config generation to Project.prototype.config.
- Loading branch information
Showing
5 changed files
with
188 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
'use strict'; | ||
|
||
var fs = require('fs'); | ||
var path = require('path'); | ||
var ConfigLoader = require('../../../lib/broccoli/broccoli-config-loader'); | ||
var assert = require('assert'); | ||
var root = process.cwd(); | ||
var tmp = require('tmp-sync'); | ||
var tmproot = path.join(root, 'tmp'); | ||
var rimraf = require('rimraf'); | ||
|
||
describe('broccoli/broccoli-config-loader', function() { | ||
var configLoader, tmpDestDir, tmpSrcDir, project, options; | ||
|
||
beforeEach(function() { | ||
tmpDestDir = tmp.in(tmproot); | ||
tmpSrcDir = tmp.in(tmproot); | ||
|
||
project = { | ||
root: tmpSrcDir, | ||
addons: [], | ||
configPath: function() { | ||
return 'config/environment'; | ||
}, | ||
|
||
config: function(env) { | ||
return { | ||
env: env, | ||
foo: 'bar', | ||
baz: 'qux' | ||
}; | ||
} | ||
}; | ||
|
||
options = { | ||
env: 'development', | ||
tests: true, | ||
project: project | ||
}; | ||
|
||
configLoader = new ConfigLoader('.', options); | ||
}); | ||
|
||
afterEach(function() { | ||
rimraf.sync(tmpDestDir); | ||
}); | ||
|
||
describe('updateCache', function() { | ||
it('writes the current environments file', function() { | ||
configLoader.updateCache(tmpSrcDir, tmpDestDir); | ||
|
||
assert(fs.existsSync(path.join(tmpDestDir, 'environment.js'))); | ||
assert(fs.existsSync(path.join(tmpDestDir, 'environments', 'development.js'))); | ||
assert(fs.existsSync(path.join(tmpDestDir, 'environments', 'development.json'))); | ||
|
||
assert(fs.existsSync(path.join(tmpDestDir, 'environments', 'test.js'))); | ||
assert(fs.existsSync(path.join(tmpDestDir, 'environments', 'test.json'))); | ||
}); | ||
|
||
it('does not generate test environment files if testing is disabled', function() { | ||
options.tests = false; | ||
configLoader.updateCache(tmpSrcDir, tmpDestDir); | ||
|
||
assert(fs.existsSync(path.join(tmpDestDir, 'environment.js'))); | ||
assert(fs.existsSync(path.join(tmpDestDir, 'environments', 'development.js'))); | ||
assert(fs.existsSync(path.join(tmpDestDir, 'environments', 'development.json'))); | ||
|
||
assert(!fs.existsSync(path.join(tmpDestDir, 'environments', 'test.js'))); | ||
assert(!fs.existsSync(path.join(tmpDestDir, 'environments', 'test.json'))); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters