Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

breaking changes to the API: 'value()' must be used to access the sho…

…uld methods
  • Loading branch information...
commit 5a15ea73c614db23ddca6bcebc5d57704e78d72b 1 parent b88c200
Emilio Cavazos authored
8 README.md
View
@@ -29,20 +29,20 @@ command line.
});
it("should be named 'Sephiroth'", function () {
- sephiroth.getName().shouldEqual('Sephiroth');
+ value(sephiroth.getName()).shouldEqual('Sephiroth');
});
it("should allow name changing", function () {
sephiroth.setName('Pedro');
- sephiroth.getName().shouldEqual('Pedro');
+ value(sephiroth.getName()).shouldEqual('Pedro');
});
it("should be have an hp of 999", function () {
- sephiroth.getHp().shouldEqual(999);
+ value(sephiroth.getHp()).shouldEqual(999);
});
it("should be have an mp of 999", function () {
- sephiroth.getMp().shouldEqual(999);
+ value(sephiroth.getMp()).shouldEqual(999);
});
});
6 TODO.md
View
@@ -0,0 +1,6 @@
+* Show the name of the spec file before showing the errors
+* Consolidate specs
+* Update README to show new API
+* Should api
+ ** have
+ ** instanceOf
2  lib/runner.js
View
@@ -40,7 +40,7 @@ Runner.prototype = {
var value = require("./should").value;
this.opts = opts.parse(process.ARGV);
- should.init();
+ // should.init();
// =======================================
// speks test structure
46 lib/should.js
View
@@ -1,6 +1,5 @@
var strutil = require("./strutil");
var equalizor = require("./equalizor");
-var sys = require("sys");
var should = exports;
@@ -126,48 +125,3 @@ var value = should.value = function (actual) {
return new Sut(actual);
};
-exports.init = function () {
- Object.prototype.shouldEqual = function (expected) {
- value(this).shouldEqual(expected);
- };
-
- Object.prototype.shouldNotEqual = function (expected) {
- value(this).shouldNotEqual(expected);
- };
-
- Object.prototype.shouldBeSame = function (expected) {
- value(this).shouldBeSame(expected);
- };
-
- Object.prototype.shouldNotBeSame = function (expected) {
- value(this).shouldNotBeSame(expected);
- };
-
- Boolean.prototype.shouldBeTrue = function () {
- value(this).shouldBeTrue();
- };
-
- Boolean.prototype.shouldBeFalse = function () {
- value(this).shouldBeFalse();
- };
-
- String.prototype.shouldMatch = function (expected) {
- value(this).shouldMatch(expected);
- };
-
- String.prototype.shouldNotMatch = function (expected) {
- value(this).shouldNotMatch(expected);
- };
-
- Number.prototype.shouldBeGreaterThan = function (expected) {
- value(this).shouldBeGreaterThan(expected);
- };
-
- Number.prototype.shouldBeLessThan = function (expected) {
- value(this).shouldBeLessThan(expected);
- };
-
- // should have
- // should be of type
-
-};
8 spec/examples/cloud_spec.js
View
@@ -10,19 +10,19 @@ describe("Cloud", function () {
});
it("should be named 'Cloud'", function () {
- cloud.getName().shouldEqual('Cloud');
+ value(cloud.getName()).shouldEqual('Cloud');
});
it("should allow name changing", function () {
cloud.setName('Rain-Cloud');
- cloud.getName().shouldEqual('Rain-Cloud');
+ value(cloud.getName()).shouldEqual('Rain-Cloud');
});
it("should be have an hp of 99", function () {
- cloud.getHp().shouldEqual(99);
+ value(cloud.getHp()).shouldEqual(99);
});
it("should be have an mp of 77", function () {
- cloud.getMp().shouldEqual(77);
+ value(cloud.getMp()).shouldEqual(77);
});
});
8 spec/examples/sephiroth_spec.js
View
@@ -7,20 +7,20 @@ describe("Sephiroth", function () {
});
it("should be named 'Sephiroth'", function () {
- sephiroth.getName().shouldEqual('Sephiroth');
+ value(sephiroth.getName()).shouldEqual('Sephiroth');
});
it("should allow name changing", function () {
sephiroth.setName('Pedro');
- sephiroth.getName().shouldEqual('Pedro');
+ value(sephiroth.getName()).shouldEqual('Pedro');
});
it("should be have an hp of 999", function () {
- sephiroth.getHp().shouldEqual(999);
+ value(sephiroth.getHp()).shouldEqual(999);
});
it("should be have an mp of 999", function () {
- sephiroth.getMp().shouldEqual(999);
+ value(sephiroth.getMp()).shouldEqual(999);
});
});
10 spec/functional/array_spec.js
View
@@ -6,26 +6,26 @@ describe('Array', function () {
});
it('should equal another array of the same value', function () {
- _ar1.shouldEqual(_ar2);
+ value(_ar1).shouldEqual(_ar2);
});
it('should not equal another array of different value', function () {
_ar1[0] = 2;
- _ar1.shouldNotEqual(_ar2);
+ value(_ar1).shouldNotEqual(_ar2);
});
it('should be identical', function () {
- _ar1.shouldBeSame(_ar1);
+ value(_ar1).shouldBeSame(_ar1);
});
it('should not be identical', function () {
- _ar1.shouldNotBeSame(_ar2);
+ value(_ar1).shouldNotBeSame(_ar2);
});
it('should equal another array of the same value when array contains custom objects', function () {
var cloud = new require('../spec/examples/cloud').Cloud();
_ar1.push(cloud);
_ar2.push(cloud);
- _ar1.shouldEqual(_ar2);
+ value(_ar1).shouldEqual(_ar2);
});
});
12 spec/functional/object_spec.js
View
@@ -1,4 +1,4 @@
-describe('Speks', function () {
+describe('Object', function () {
beforeEach(function () {
// do something
@@ -14,7 +14,7 @@ describe('Speks', function () {
this.bar = function () { return 'bar'; }
};
- new obj1().shouldEqual(new obj1());
+ value(new obj1()).shouldEqual(new obj1());
});
it('should assert inequality of objects', function () {
@@ -26,7 +26,7 @@ describe('Speks', function () {
this.bar = function () { return 'bar'; }
};
- obj1.shouldEqual(obj2);
+ value(obj1).shouldEqual(obj2);
});
it('should assert objects are the same', function () {
@@ -37,15 +37,15 @@ describe('Speks', function () {
var a = new obj1();
- a.shouldBeSame(a);
- obj1.shouldBeSame(obj1);
+ value(a).shouldBeSame(a);
+ value(obj1).shouldBeSame(obj1);
});
it('should assert objects are not the same', function () {
var a = new Object();
var b = new Object();
- a.shouldNotBeSame(b);
+ value(a).shouldNotBeSame(b);
});
});
10 spec/lib/option_parser_spec.js
View
@@ -3,19 +3,21 @@ describe("Option Parser", function () {
var opts = require("./option_parser");
it("should leave the verbose property null when the verbose flag is not provided", function () {
- (opts.parse([]).verbose == null).shouldBeTrue();
+ value(opts.parse([]).verbose == null).shouldBeTrue();
});
it("should parse verbose flag", function () {
- opts.parse(["foo", "bar", "--verbose"]).verbose.shouldEqual("--verbose");
+ var actual = opts.parse(["foo", "bar", "--verbose"]).verbose;
+ value(actual).shouldEqual("--verbose");
});
it("should leave the filename property null when no filename is provided", function () {
- (opts.parse([]).filename == null).shouldBeTrue();
+ value(opts.parse([]).filename == null).shouldBeTrue();
});
it("should parse filename when filename ends with '_spec.js'", function () {
- opts.parse(["bar", "fake_spec.js", "foo"]).filename.shouldEqual("fake_spec.js");
+ var actual = opts.parse(["bar", "fake_spec.js", "foo"]).filename;
+ value(actual).shouldEqual("fake_spec.js");
});
});
13 spec/lib/results_spec.js
View
@@ -6,23 +6,26 @@ describe("Results", function () {
});
it("should return only the summary when the spec run contains no failures", function () {
- results.format(2, []).shouldEqual("\033[32m2 specs, 2 passed, 0 failed\033[37m");
+ var actual = results.format(2, []);
+ value(actual).shouldEqual("\033[32m2 specs, 2 passed, 0 failed\033[37m");
});
it("should you spec (singular form) when only one spec is run", function () {
- results.format(1, []).shouldEqual("\033[32m1 spec, 1 passed, 0 failed\033[37m");
+ var actual = results.format(1, []);
+ value(actual).shouldEqual("\033[32m1 spec, 1 passed, 0 failed\033[37m");
});
it("should output failure messages and summary", function () {
var failures = ["fail msg 1", "fail msg 2"];
var expected = "1) fail msg 12) fail msg 2\n\033[31m2 specs, 0 passed, 2 failed\033[37m";
- results.format(2, failures).shouldEqual(expected);
+ var actual = results.format(2, failures);
+ value(actual).shouldEqual(expected);
});
it("should output failed and passed feedback", function () {
var expected = "1) fail\n\033[31m2 specs, 1 passed, 1 failed\033[37m";
-
- results.format(2, ["fail"]).shouldEqual(expected);
+ var actual = results.format(2, ["fail"]);
+ value(actual).shouldEqual(expected);
});
});
10 spec/lib/should_spec.js
View
@@ -4,13 +4,13 @@ describe("Should", function () {
it("should not throw when shouldEqual passes", function () {
value(function () {
- ({}).shouldEqual({});
+ value({}).shouldEqual({});
}).shouldNotThrow();
});
it("should throw when shouldEqual fails", function () {
value(function () {
- ({}).shouldEqual({ bar: "bar" });
+ value({}).shouldEqual({ bar: "bar" });
})
.shouldThrow()
.exception('Expected:\n{ bar: "bar" }\n\nActual:\n{}');
@@ -18,14 +18,14 @@ describe("Should", function () {
it("should not throw when shouldNotEqual passes", function () {
value(function () {
- ({}).shouldNotEqual({ bar: "bar" });
+ value({}).shouldNotEqual({ bar: "bar" });
})
.shouldNotThrow();
});
it("should throw when shouldNotEqual fails", function () {
value(function () {
- ({}).shouldNotEqual({});
+ value({}).shouldNotEqual({});
})
.shouldThrow()
.exception("Expected:\n{}\n\nActual:\n{}");
@@ -49,7 +49,7 @@ describe("Should", function () {
it("should not throw when shouldNotBeSame passes", function () {
value(function () {
- ({}).shouldNotBeSame({});
+ value({}).shouldNotBeSame({});
})
.shouldNotThrow();
});
14 spec/lib/strutil_spec.js
View
@@ -3,33 +3,33 @@ describe("tostr", function () {
var strutil = require('./strutil');
it('should place double quotes around strings', function () {
- strutil.tostr('foo').shouldEqual('"foo"');
+ value(strutil.tostr('foo')).shouldEqual('"foo"');
});
it('should convert undefined values into a string', function () {
var undefined;
- strutil.tostr(undefined).shouldEqual('undefined');
+ value(strutil.tostr(undefined)).shouldEqual('undefined');
});
it('should convert true into a string', function () {
- strutil.tostr(true).shouldEqual('true');
+ value(strutil.tostr(true)).shouldEqual('true');
});
it('should convert false into a string', function () {
- strutil.tostr(false).shouldEqual('false');
+ value(strutil.tostr(false)).shouldEqual('false');
});
it('should convert numbers into a string', function () {
- strutil.tostr(22).shouldEqual('22');
+ value(strutil.tostr(22)).shouldEqual('22');
});
it('should convert null into a string', function () {
- strutil.tostr(null).shouldEqual('null');
+ value(strutil.tostr(null)).shouldEqual('null');
});
it('should convert functions into a string', function () {
var func = function (a, b) { return 'foo'; };
- strutil.tostr(func).shouldEqual('function (a, b) { return \'foo\'; }');
+ value(strutil.tostr(func)).shouldEqual('function (a, b) { return \'foo\'; }');
});
});
2  speks.js
View
@@ -2,7 +2,7 @@ var sys = require("sys");
var Speks = {
- version: "0.3.1",
+ version: "0.3.3",
run: function () {
var runr = require("./lib/runner");
Please sign in to comment.
Something went wrong with that request. Please try again.