       fin()
 
     # When core is initialized
-    initCore axiomConfig, runService
+    initCore {
+      axiom: axiomConfig
+      node_modules:
+        'axiom-server':
+          services:
+            run: runService
+    }
 
     # And the service is called
     core.request 'server.run', {}, (err, result) ->

should = require 'should'
async = require 'async'
_ = require 'lodash'
logger = require 'torch'
{focus} = require 'qi'
{join} = require 'path'

bus = require '../lib/bus'
core = require '../lib/core'

mockRetriever = require './helpers/mockRetriever'

initCore = (axiomConfig, runService) ->
  retriever = mockRetriever()
  retriever.packages.axiom = axiomConfig
  retriever.packages.node_modules['axiom-server'] =
    services:
      run: runService

  core.init {timeout: 20}, retriever

describe 'core.request', ->

  afterEach ->
    core.reset()

      # It should return without its assertions failing
      should.not.exist err
      done()

  it 'should expose app config to a base script', (done) ->

    # Given an Axiom config with an 'app' section defined
    axiomConfig =
      app:
        serverPort: 4000
        apiPort: 4001

    # And a run service that inherits from a base
    baseService = (args, next) ->
      should.exist @app
      @app.should.eql axiomConfig.app
      next()

    # When core is initialized
    initCore {
      axiom: axiomConfig
      node_modules:
        'axiom-server':
          config:
            run:
              base: 'runtime'
        'axiom-base':
          {
            services:
              runtime: baseService
          }
    }

    # And the service is called
    core.request 'server.run', {}, (err, result) ->

      # It should return without its assertions failing
      should.not.exist err
      done()
