diff --git a/bin/embark b/bin/embark index 476897cd..f1bf7744 100755 --- a/bin/embark +++ b/bin/embark @@ -108,15 +108,16 @@ program.command('run [env]').description('run dapp').action(function(env_) { } }); -program.command('spec').description('run specs').action(function() { +program.command('spec').description('run tests').action(function() { var embarkConfig = readYaml.sync("./embark.yml"); if (embarkConfig.type === "grunt") { - run('jasmine'); + run('mocha'); } else { console.log("command not available in meteor or manual mode yet"); console.log("note: you can use embark tests with any framework"); + console.log("try running mocha test/"); } }); @@ -158,7 +159,7 @@ program.command('demo').description('create a working dapp with a SimpleStorage wrench.copyDirSyncRecursive(boilerPath, targetDir); wrench.copyDirSyncRecursive(demoPath + "/app", targetDir + "/app", {forceDelete: true}); wrench.copyDirSyncRecursive(demoPath + "/config", targetDir + "/config", {forceDelete: true}); - wrench.copyDirSyncRecursive(demoPath + "/spec", targetDir + "/spec", {forceDelete: true}); + wrench.copyDirSyncRecursive(demoPath + "/test", targetDir + "/test", {forceDelete: true}); cd(targetDir); run('npm install'); diff --git a/boilerplate/spec/support/jasmine.json b/boilerplate/spec/support/jasmine.json deleted file mode 100644 index a5f29329..00000000 --- a/boilerplate/spec/support/jasmine.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "spec_dir": "spec", - "spec_files": [ - "**/*[sS]pec.js" - ], - "helpers": [ - "helpers/**/*.js" - ] -} diff --git a/demo/spec/contracts/simple_storage_spec.js b/demo/spec/contracts/simple_storage_spec.js deleted file mode 100644 index 71d654e4..00000000 --- a/demo/spec/contracts/simple_storage_spec.js +++ /dev/null @@ -1,26 +0,0 @@ -var EmbarkSpec = require('embark-framework').test; - -describe("SimpleStorage", function() { - beforeAll(function(done) { - EmbarkSpec(done); - //SimpleStorage = EmbarkSpec.request("SimpleStorage", [150]); - }); - - it("should set constructor value", function(done) { - SimpleStorage.storedData(function(err, result) { - expect(result.toNumber()).toEqual(100); - done(); - }); - }); - - it("set storage value", function(done) { - SimpleStorage.set(150, function() { - SimpleStorage.get(function(err, result) { - console.log(arguments); - expect(result.toNumber()).toEqual(150); - done(); - }); - }); - }); - -}) diff --git a/demo/spec/support/jasmine.json b/demo/spec/support/jasmine.json deleted file mode 100644 index a5f29329..00000000 --- a/demo/spec/support/jasmine.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "spec_dir": "spec", - "spec_files": [ - "**/*[sS]pec.js" - ], - "helpers": [ - "helpers/**/*.js" - ] -} diff --git a/demo/test/simple_storage_spec.js b/demo/test/simple_storage_spec.js new file mode 100644 index 00000000..916c4c5e --- /dev/null +++ b/demo/test/simple_storage_spec.js @@ -0,0 +1,26 @@ +var assert = require('assert'); +var Embark = require('embark-framework'); +var EmbarkSpec = Embark.initTests(); + +describe("SimpleStorage", function(done) { + before(function(done) { + EmbarkSpec.deployAll(done); + }); + + it("should set constructor value", function(done) { + SimpleStorage.storedData(function(err, result) { + assert.equal(result.toNumber(), 100); + done(); + }); + }); + + it("set storage value", function(done) { + SimpleStorage.set(150, function() { + SimpleStorage.get(function(err, result) { + assert.equal(result.toNumber(), 150); + done(); + }); + }); + }); + +}) diff --git a/lib/deploy.js b/lib/deploy.js index dfebb4aa..0c6087e2 100644 --- a/lib/deploy.js +++ b/lib/deploy.js @@ -31,12 +31,8 @@ Deploy = function(env, contractFiles, blockchainConfig, contractsConfig, chainMa }; Deploy.prototype.deploy_contract = function(contractObject, contractParams, cb) { - console.log("called deploy_contract"); var callback = function(e, contract) { - console.log("got receipt"); - console.log(arguments); if(!e && contract.address !== undefined) { - console.log("Contract mined! Address: " + contract.address); cb(contract.address); } else { @@ -123,8 +119,6 @@ Deploy.prototype.deploy_a_contract = function(env, className, cb) { var _this = this; this.deploy_contract(contractObject, contractParams, function(contractAddress) { - console.log("response!"); - if (web3.eth.getCode(contractAddress) === "0x") { console.log("========="); console.log("contract was deployed at " + contractAddress + " but doesn't seem to be working"); diff --git a/lib/index.js b/lib/index.js index 844334ab..e27f4c1c 100644 --- a/lib/index.js +++ b/lib/index.js @@ -66,8 +66,11 @@ Embark = { release: Release, - test: function(cb) { - var tests = new Test(cb); + initTests: function() { + var files = ["app/contracts/simple_storage.sol"]; + var tests = new Test(files, 'development'); + + return tests; } } diff --git a/lib/test.js b/lib/test.js index bd9a04a1..ce474a50 100644 --- a/lib/test.js +++ b/lib/test.js @@ -1,29 +1,24 @@ var ethersim = require('ethersim'); var web3 = require('web3'); -Test = function(cb) { - var Manager = ethersim.Manager; - var Provider = ethersim.Provider; +Test = function(contractFiles, _env) { + this.env = _env || 'development'; + this.web3 = web3; + this.web3.setProvider(ethersim.web3Provider()); + this.contractFiles = contractFiles; - var manager = new Manager(); - web3.setProvider(new Provider(manager)); - - Embark.init(web3); + Embark.init(this.web3); Embark.blockchainConfig.loadConfigFile('config/blockchain.yml'); Embark.contractsConfig.loadConfigFile('config/contracts.yml'); - var files = ["app/contracts/simple_storage.sol"]; + Embark.contractsConfig.init(this.contractFiles, this.env); +} - Embark.contractsConfig.init(files, 'development'); - - Embark.deployContracts('development', files, "/tmp/abi.js", "chains.json", false, false, function(abi) { - console.log("return abi"); - console.log(abi); +Test.prototype.deployAll = function(cb) { + Embark.deployContracts('development', this.contractFiles, "/tmp/abi.js", "chains.json", false, false, function(abi) { eval(abi); cb(); }); } -//Test.prototype.deploy_contract = function(className, params) - module.exports = Test;