Skip to content

Commit

Permalink
Helper class can now accept array of files/dirs to test with
Browse files Browse the repository at this point in the history
  • Loading branch information
Moshe Belostotsky committed Jul 7, 2016
1 parent 587cd17 commit 6c12f1a
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,23 @@ class Helper
@Response = MockResponse

constructor: (scriptsPath) ->
@scriptsPath = Path.resolve(Path.dirname(module.parent.filename), scriptsPath)
if not Array.isArray(scriptsPath)
scriptsPath = [scriptsPath]
@scriptsPath = scriptsPath

createRoom: (options={}) ->
robot = new MockRobot(options.httpd)

if 'response' of options
robot.Response = options.response

if Fs.statSync(@scriptsPath).isDirectory()
for file in Fs.readdirSync(@scriptsPath).sort()
robot.loadFile @scriptsPath, file
else
robot.loadFile Path.dirname(@scriptsPath), Path.basename(@scriptsPath)
for script in @scriptsPath
script = Path.resolve(Path.dirname(module.parent.filename), script)
if Fs.statSync(script).isDirectory()
for file in Fs.readdirSync(script).sort()
robot.loadFile script, file
else
robot.loadFile Path.dirname(script), Path.basename(script)

robot.brain.emit 'loaded'

Expand Down

0 comments on commit 6c12f1a

Please sign in to comment.