Store spec directory on required specs

This allows the project to be configured based on the spec being
run.
This commit is contained in:
Kevin Sawicki 2013-10-14 11:15:40 -07:00
parent f60ead03d2
commit 0b22d99fad
2 changed files with 19 additions and 7 deletions

View File

@ -37,18 +37,20 @@ jasmine.getEnv().defaultTimeoutInterval = 5000
specPackageName = null
specPackagePath = null
specProjectPath = null
if specDirectory = atom.getLoadSettings().specDirectory
specPackagePath = path.resolve(specDirectory, '..')
try
specPackageName = fs.readObjectSync(path.join(specPackagePath, 'package.json'))?.name
else
specDirectory = __dirname
specProjectPath = path.join(specDirectory, 'fixtures')
specProjectPath = path.join(specDirectory, 'fixtures')
beforeEach ->
$.fx.off = true
atom.project = new Project(specProjectPath)
if specProjectPath
atom.project = new Project(specProjectPath)
else
atom.project = new Project(path.join(@specDirectory, 'fixtures'))
window.project = atom.project
window.resetTimeouts()

View File

@ -7,14 +7,24 @@ measure 'spec suite require time', ->
for specFilePath in fs.listTreeSync(specDirectory) when /-spec\.coffee$/.test specFilePath
require specFilePath
# Set spec directory on spec for setting up the project in spec-helper
specs = jasmine.getEnv().currentRunner().specs()
if specs.length > 0
for index in [specs.length-1..0]
break if specs[index].specDirectory?
specs[index].specDirectory = specDirectory
setSpecType = (specType) ->
for spec in jasmine.getEnv().currentRunner().specs() when not spec.specType?
spec.specType = specType
specs = jasmine.getEnv().currentRunner().specs()
return if specs.length is 0
for index in [specs.length-1..0]
break if specs[index].specType?
specs[index].specType = specType
runAllSpecs = ->
# Only run core specs when resource path is the Atom repository
if Git.exists(window.resourcePath)
requireSpecs(path.join(window.resourcePath, 'spec'))
# requireSpecs(path.join(window.resourcePath, 'spec'))
setSpecType('core')
fixturesPackagesPath = path.join(__dirname, 'fixtures', 'packages')