diff --git a/jasmine.iws b/jasmine.iws index fa50e8a..c4af551 100644 --- a/jasmine.iws +++ b/jasmine.iws @@ -79,20 +79,20 @@ - - - - + + + + - + @@ -101,7 +101,7 @@ - + @@ -109,20 +109,20 @@ - - - + + + - + @@ -131,7 +131,7 @@ - + @@ -310,6 +310,25 @@ + + + + + - - - - - + + + + + + + + + + + + + + + + + @@ -517,45 +534,28 @@ - - - - - - - - + - + - + - - - - - - - - - - - + diff --git a/lib/jasmine.js b/lib/jasmine.js index fce4aea..6990392 100755 --- a/lib/jasmine.js +++ b/lib/jasmine.js @@ -205,6 +205,11 @@ Jasmine.Matchers.method('should_match', function (reg_exp) { 'Expected ' + this.actual + ' to match ' + reg_exp + '.'); }); +Jasmine.Matchers.method('should_be_defined', function () { + return this.report((this.actual !== undefined), + 'Expected ' + this.actual + ' to be defined.'); +}); + /* * Jasmine spec constructor */ diff --git a/test/bootstrap.js b/test/bootstrap.js index 0a9d045..c20ac47 100755 --- a/test/bootstrap.js +++ b/test/bootstrap.js @@ -58,13 +58,21 @@ var testMatchersComparisons = function () { reporter.test(!(expected.should_not_equal(true)), 'expects_that(true).should_not_equal(false) retruned true'); - expected = new Jasmine.Matchers('foobarbel'); + expected = new Jasmine.Matchers('foobarbel'); reporter.test((expected.should_match(/bar/)), 'expects_that(forbarbel).should_match(/bar/) returned false'); expected = new Jasmine.Matchers('foobazbel'); reporter.test(!(expected.should_match(/bar/)), 'expects_that(forbazbel).should_match(/bar/) returned true'); + + expected = new Jasmine.Matchers('foo'); + reporter.test(expected.should_be_defined(), + 'expects_that(foo).should_be_defined() returned true'); + + expected = new Jasmine.Matchers(undefined); + reporter.test(! expected.should_be_defined(), + 'expects_that(undefined).should_be_defined() returned false'); } var testMatchersReporting = function () { @@ -826,13 +834,13 @@ var testHandlesExceptions = function () { reporter.test((runner.suites[0].specs[0].expectationResults[0].passed === false), 'First test should have failed, got passed'); - reporter.test((runner.suites[0].specs[0].expectationResults[0].message === 'ReferenceError: fakeObject is not defined in file:///Users/pivotal/workspace/jasmine/test/bootstrap.js (line 799)'), + reporter.test((runner.suites[0].specs[0].expectationResults[0].message === 'ReferenceError: fakeObject is not defined in file:///Users/pivotal/workspace/jasmine/test/bootstrap.js (line 807)'), 'First test should have shown some exception string, got ' + runner.suites[0].specs[0].expectationResults[0].message); reporter.test((runner.suites[0].specs[1].expectationResults[0].passed === false), 'Second test should have a failing first result, got passed'); - reporter.test((runner.suites[0].specs[1].expectationResults[0].message === 'ReferenceError: fakeObject2 is not defined in file:///Users/pivotal/workspace/jasmine/test/bootstrap.js (line 805)'), + reporter.test((runner.suites[0].specs[1].expectationResults[0].message === 'ReferenceError: fakeObject2 is not defined in file:///Users/pivotal/workspace/jasmine/test/bootstrap.js (line 813)'), 'Second test should have shown an exception message for the first result, got ' + runner.suites[0].specs[1].expectationResults[0].message); reporter.test((runner.suites[0].specs[1].expectationResults[1].passed === true),