aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFotoVerite <[email protected]>2013-06-12 01:31:21 -0400
committerFotoVerite <[email protected]>2013-06-12 01:31:21 -0400
commitd3d5ac2042851bd17fe29a7345ebb2f084c4b691 (patch)
tree0d441e086026afb798313134fe2d30f94abaf0e3
parent97ef5dd3e60a9fcb1c44b471ab0ea0e4eb529dc2 (diff)
parentcce5d927e7e847c780e828972c92113d4cb7199f (diff)
downloadfaker-d3d5ac2042851bd17fe29a7345ebb2f084c4b691.tar.xz
faker-d3d5ac2042851bd17fe29a7345ebb2f084c4b691.zip
[util] merged in chrisocast changes, updated build and version.
-rw-r--r--Faker.js7
-rw-r--r--examples/js/Faker.js7
-rw-r--r--lib/lorem.js5
-rw-r--r--package.json2
-rw-r--r--test/lorem.unit.js18
5 files changed, 29 insertions, 10 deletions
diff --git a/Faker.js b/Faker.js
index 36abae30..c3b21001 100644
--- a/Faker.js
+++ b/Faker.js
@@ -17,7 +17,7 @@ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-/*************** AUTOGENERATED @ 1371014758626 ***************
+/*************** AUTOGENERATED @ 1371014966634 ***************
WARNING: THIS FILE WAS AUTOGENERATED BY THE FAKER BUILD SCRIPT
MODIFYING THIS FILE IS FINE, BUT YOU REALLY SHOULD BE MODIFYING
THE LIBRARY DIRECTLY AND REGENERATING THIS FILE USING BUILD.js!!!!
@@ -239,11 +239,12 @@ Faker.Lorem.words = function (num) {
return Helpers.shuffle(definitions.lorem).slice(0, num);
};
-Faker.Lorem.sentence = function (wordCount) {
+Faker.Lorem.sentence = function (wordCount, range) {
if (typeof wordCount == 'undefined') { wordCount = 3; }
+ if (typeof range == 'undefined') { range = 7; }
// strange issue with the node_min_test failing for captialize, please fix and add this back
- //return this.words(wordCount + Helpers.randomNumber(7)).join(' ').capitalize();
+ //return this.words(wordCount + Helpers.randomNumber(range)).join(' ').capitalize();
return lorem.words(wordCount + Faker.random.number(7)).join(' ');
};
diff --git a/examples/js/Faker.js b/examples/js/Faker.js
index 36abae30..c3b21001 100644
--- a/examples/js/Faker.js
+++ b/examples/js/Faker.js
@@ -17,7 +17,7 @@ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-/*************** AUTOGENERATED @ 1371014758626 ***************
+/*************** AUTOGENERATED @ 1371014966634 ***************
WARNING: THIS FILE WAS AUTOGENERATED BY THE FAKER BUILD SCRIPT
MODIFYING THIS FILE IS FINE, BUT YOU REALLY SHOULD BE MODIFYING
THE LIBRARY DIRECTLY AND REGENERATING THIS FILE USING BUILD.js!!!!
@@ -239,11 +239,12 @@ Faker.Lorem.words = function (num) {
return Helpers.shuffle(definitions.lorem).slice(0, num);
};
-Faker.Lorem.sentence = function (wordCount) {
+Faker.Lorem.sentence = function (wordCount, range) {
if (typeof wordCount == 'undefined') { wordCount = 3; }
+ if (typeof range == 'undefined') { range = 7; }
// strange issue with the node_min_test failing for captialize, please fix and add this back
- //return this.words(wordCount + Helpers.randomNumber(7)).join(' ').capitalize();
+ //return this.words(wordCount + Helpers.randomNumber(range)).join(' ').capitalize();
return lorem.words(wordCount + Faker.random.number(7)).join(' ');
};
diff --git a/lib/lorem.js b/lib/lorem.js
index baa18ebc..209d2ced 100644
--- a/lib/lorem.js
+++ b/lib/lorem.js
@@ -8,11 +8,12 @@ var lorem = {
return Helpers.shuffle(definitions.lorem).slice(0, num);
},
- sentence: function (wordCount) {
+ sentence: function (wordCount, range) {
if (typeof wordCount == 'undefined') { wordCount = 3; }
+ if (typeof range == 'undefined') { range = 7; }
// strange issue with the node_min_test failing for captialize, please fix and add this back
- //return this.words(wordCount + Helpers.randomNumber(7)).join(' ').capitalize();
+ //return this.words(wordCount + Helpers.randomNumber(range)).join(' ').capitalize();
return lorem.words(wordCount + Faker.random.number(7)).join(' ');
},
diff --git a/package.json b/package.json
index 45244dd0..1cb1561e 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "Faker",
"description": "Generate massive amounts of fake contextual data",
- "version": "0.5.9",
+ "version": "0.5.10",
"author": "Marak Squires <[email protected]>",
"repository": {
"type": "git",
diff --git a/test/lorem.unit.js b/test/lorem.unit.js
index de806ddd..d85cce91 100644
--- a/test/lorem.unit.js
+++ b/test/lorem.unit.js
@@ -35,7 +35,7 @@ describe("lorem.js", function () {
});
describe("sentence()", function () {
- context("when no 'wordCount' param passed in", function () {
+ context("when no 'wordCount' or 'range' param passed in", function () {
it("returns a string of at least three words", function () {
sinon.spy(Faker.Lorem, 'words');
sinon.stub(Faker.random, 'number').returns(2);
@@ -66,6 +66,22 @@ describe("lorem.js", function () {
Faker.random.number.restore();
});
});
+
+ context("when 'wordCount' and 'range' params passed in", function () {
+ it("returns a string of at least the requested number of words", function () {
+ sinon.spy(Faker.Lorem, 'words');
+ sinon.stub(Faker.random, 'number').returns(4);
+ var sentence = Faker.Lorem.sentence(10, 4);
+
+ assert.ok(typeof sentence === 'string');
+ var parts = sentence.split(' ');
+ assert.equal(parts.length, 14); // requested 10 plus stubbed 4.
+ assert.ok(Faker.Lorem.words.calledWith(14));
+
+ Faker.Lorem.words.restore();
+ Faker.random.number.restore();
+ });
+ });
});
describe("sentences()", function () {