diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4ced94fe4..f4c81fa90 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,17 @@
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
+
+## [4.13.4](https://github.com/gemini-testing/gemini/compare/v4.13.3...v4.13.4) (2016-11-07)
+
+
+### Bug Fixes
+
+* **config:** throw error if value contain not valid json string ([60cc4f0](https://github.com/gemini-testing/gemini/commit/60cc4f0))
+* **config:** use JSON.parse for plugins values from cli/env ([6039fd1](https://github.com/gemini-testing/gemini/commit/6039fd1))
+
+
+
## [4.13.3](https://github.com/gemini-testing/gemini/compare/v4.13.1...v4.13.3) (2016-11-03)
diff --git a/lib/config/util.js b/lib/config/util.js
index 18d6bb1cf..2ad5f17c8 100644
--- a/lib/config/util.js
+++ b/lib/config/util.js
@@ -48,6 +48,14 @@ function parseBoolean(value) {
}
}
+function parsePrimitive(str) {
+ try {
+ return JSON.parse(str);
+ } catch (error) {
+ throw new GeminiError('a value must be a primitive type');
+ }
+}
+
function positiveIntegerOption(defaultValue) {
return option({
parseEnv: Number,
@@ -70,7 +78,10 @@ function positiveIntegerOption(defaultValue) {
}
function anyObject() {
- return map(option({}));
+ return map(option({
+ parseEnv: parsePrimitive,
+ parseCli: parsePrimitive
+ }));
}
exports.is = is;
diff --git a/package.json b/package.json
index 7e9c191c0..ff3d9583a 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "gemini",
- "version": "4.13.3",
+ "version": "4.13.4",
"description": "UI Screenshot testing utility",
"engines": {
"node": ">= 4.0.0"
diff --git a/test/unit/config-options/config-options.test.js b/test/unit/config-options/config-options.test.js
index 8579fa357..f1e2386ab 100644
--- a/test/unit/config-options/config-options.test.js
+++ b/test/unit/config-options/config-options.test.js
@@ -8,7 +8,10 @@ var Config = require('lib/config'),
describe('config', function() {
var VALID_OPTIONS = {
system: {
- projectRoot: '/some/path'
+ projectRoot: '/some/path',
+ plugins: {
+ plugin: {}
+ }
},
rootUrl: 'http://example.com/root',
gridUrl: 'http://example.com/root',
@@ -225,6 +228,38 @@ describe('config', function() {
});
}
+ function testObjectOption(name) {
+ it('should parse any of primitive type from environment', () => {
+ ['string', 1.0, 1, false, null, [], {a: 1}].forEach((expected) => {
+ const value = JSON.stringify(expected);
+ assertParsesEnv({property: name, value, expected});
+ });
+ });
+
+ it('should throw if value from environment is not valid', () => {
+ ['{a:1}', '{', ']', '\'string\'', '\n'].forEach((value) => {
+ assert.throw(() => {
+ assertParsesEnv({property: name, value});
+ }, GeminiError);
+ });
+ });
+
+ it('should parse any of primitive type from cli', () => {
+ ['string', 1.0, 1, false, null, [], {a: 1}].forEach((expected) => {
+ const value = JSON.stringify(expected);
+ assertParsesCli({property: name, value, expected});
+ });
+ });
+
+ it('should throw if value from cli is not valid', () => {
+ ['{a:1}', '{', ']', '\'string\'', '\n'].forEach((value) => {
+ assert.throw(() => {
+ assertParsesCli({property: name, value});
+ }, GeminiError);
+ });
+ });
+ }
+
beforeEach(function() {
this.sinon = sinon.sandbox.create();
});
@@ -439,6 +474,10 @@ describe('config', function() {
});
});
});
+
+ describe('plugins', () => {
+ testObjectOption('system.plugins.plugin');
+ });
});
describe('browser options', function() {