dwf/rva - moved should_be_defined() into Jasmine from Tweed

This commit is contained in:
pivotal 2009-01-07 17:12:17 -08:00
parent d9345b3874
commit 183b06bb9d
3 changed files with 70 additions and 57 deletions

View File

@ -79,20 +79,20 @@
<leaf> <leaf>
<file leaf-file-name="bootstrap.html" pinned="false" current="false" current-in-tab="false"> <file leaf-file-name="bootstrap.html" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/test/bootstrap.html"> <entry file="file://$PROJECT_DIR$/test/bootstrap.html">
<provider editor-type-id="HtmlPreview">
<state />
</provider>
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state line="12" column="4" selection-start="533" selection-end="533" vertical-scroll-proportion="0.41379312"> <state line="12" column="4" selection-start="533" selection-end="533" vertical-scroll-proportion="0.25249168">
<folding /> <folding />
</state> </state>
</provider> </provider>
<provider editor-type-id="HtmlPreview">
<state />
</provider>
</entry> </entry>
</file> </file>
<file leaf-file-name="bootstrap.js" pinned="false" current="true" current-in-tab="true"> <file leaf-file-name="bootstrap.js" pinned="false" current="true" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/test/bootstrap.js"> <entry file="file://$PROJECT_DIR$/test/bootstrap.js">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state line="828" column="3" selection-start="25391" selection-end="26216" vertical-scroll-proportion="0.3322314"> <state line="842" column="193" selection-start="26377" selection-end="26377" vertical-scroll-proportion="0.94043887">
<folding /> <folding />
</state> </state>
</provider> </provider>
@ -101,7 +101,7 @@
<file leaf-file-name="jasmine.js" pinned="false" current="false" current-in-tab="false"> <file leaf-file-name="jasmine.js" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/lib/jasmine.js"> <entry file="file://$PROJECT_DIR$/lib/jasmine.js">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state line="205" column="3" selection-start="4581" selection-end="4581" vertical-scroll-proportion="1.4096774"> <state line="389" column="1" selection-start="8626" selection-end="8626" vertical-scroll-proportion="0.88271606">
<folding /> <folding />
</state> </state>
</provider> </provider>
@ -109,20 +109,20 @@
</file> </file>
<file leaf-file-name="example.html" pinned="false" current="false" current-in-tab="false"> <file leaf-file-name="example.html" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/example/example.html"> <entry file="file://$PROJECT_DIR$/example/example.html">
<provider editor-type-id="HtmlPreview">
<state />
</provider>
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state line="0" column="0" selection-start="0" selection-end="721" vertical-scroll-proportion="0.0"> <state line="0" column="0" selection-start="0" selection-end="721" vertical-scroll-proportion="0.0">
<folding /> <folding />
</state> </state>
</provider> </provider>
<provider editor-type-id="HtmlPreview">
<state />
</provider>
</entry> </entry>
</file> </file>
<file leaf-file-name="jasmine.css" pinned="false" current="false" current-in-tab="false"> <file leaf-file-name="jasmine.css" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/lib/jasmine.css"> <entry file="file://$PROJECT_DIR$/lib/jasmine.css">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state line="17" column="36" selection-start="351" selection-end="351" vertical-scroll-proportion="0.5209677"> <state line="17" column="36" selection-start="351" selection-end="351" vertical-scroll-proportion="0.33230454">
<folding /> <folding />
</state> </state>
</provider> </provider>
@ -131,7 +131,7 @@
<file leaf-file-name="example.js" pinned="false" current="false" current-in-tab="false"> <file leaf-file-name="example.js" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/example/example.js"> <entry file="file://$PROJECT_DIR$/example/example.js">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state line="6" column="0" selection-start="183" selection-end="183" vertical-scroll-proportion="0.18387097"> <state line="6" column="0" selection-start="183" selection-end="183" vertical-scroll-proportion="0.11728395">
<folding /> <folding />
</state> </state>
</provider> </provider>
@ -310,6 +310,25 @@
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="ALTERN_SDK_NAME" VALUE="" /> <RTEST_RUN_CONFIG_SETTINGS_ID NAME="ALTERN_SDK_NAME" VALUE="" />
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="INHERITANCE_CHECK_DISABLED" VALUE="false" /> <RTEST_RUN_CONFIG_SETTINGS_ID NAME="INHERITANCE_CHECK_DISABLED" VALUE="false" />
</configuration> </configuration>
<configuration default="true" type="JUnit" factoryName="JUnit" enabled="false" merge="false">
<module name="" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="PACKAGE_NAME" />
<option name="MAIN_CLASS_NAME" />
<option name="METHOD_NAME" />
<option name="TEST_OBJECT" value="class" />
<option name="VM_PARAMETERS" />
<option name="PARAMETERS" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="ADDITIONAL_CLASS_PATH" />
<option name="TEST_SEARCH_SCOPE">
<value defaultName="wholeProject" />
</option>
<envs />
</configuration>
<configuration default="true" type="Application" factoryName="Application" enabled="false" merge="false"> <configuration default="true" type="Application" factoryName="Application" enabled="false" merge="false">
<option name="MAIN_CLASS_NAME" /> <option name="MAIN_CLASS_NAME" />
<option name="VM_PARAMETERS" /> <option name="VM_PARAMETERS" />
@ -335,25 +354,6 @@
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" /> <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" /> <option name="ALTERNATIVE_JRE_PATH" />
</configuration> </configuration>
<configuration default="true" type="JUnit" factoryName="JUnit" enabled="false" merge="false">
<module name="" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="PACKAGE_NAME" />
<option name="MAIN_CLASS_NAME" />
<option name="METHOD_NAME" />
<option name="TEST_OBJECT" value="class" />
<option name="VM_PARAMETERS" />
<option name="PARAMETERS" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="ADDITIONAL_CLASS_PATH" />
<option name="TEST_SEARCH_SCOPE">
<value defaultName="wholeProject" />
</option>
<envs />
</configuration>
<configuration default="true" type="Remote" factoryName="Remote"> <configuration default="true" type="Remote" factoryName="Remote">
<option name="USE_SOCKET_TRANSPORT" value="true" /> <option name="USE_SOCKET_TRANSPORT" value="true" />
<option name="SERVER_MODE" value="false" /> <option name="SERVER_MODE" value="false" />
@ -412,15 +412,15 @@
</todo-panel> </todo-panel>
</component> </component>
<component name="ToolWindowManager"> <component name="ToolWindowManager">
<frame x="7" y="22" width="1872" height="1102" extended-state="0" /> <frame x="43" y="39" width="1862" height="1116" extended-state="0" />
<editor active="true" /> <editor active="true" />
<layout> <layout>
<window_info id="UI Designer" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="3" /> <window_info id="UI Designer" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="3" />
<window_info id="IDEtalk" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="3" /> <window_info id="IDEtalk" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="3" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="7" /> <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="7" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.21091811" order="0" /> <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.2107005" order="0" />
<window_info id="RDoc" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="8" /> <window_info id="RDoc" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="8" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.32837301" order="1" /> <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32837301" order="1" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" order="1" /> <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" order="1" />
<window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="14" /> <window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" order="14" />
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" order="6" /> <window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" order="6" />
@ -505,6 +505,23 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/lib/json_reporter.js">
<provider selected="true" editor-type-id="text-editor">
<state line="20" column="0" selection-start="648" selection-end="648" vertical-scroll-proportion="0.15240084">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/test/bootstrap.html">
<provider selected="true" editor-type-id="text-editor">
<state line="12" column="4" selection-start="533" selection-end="533" vertical-scroll-proportion="0.25249168">
<folding />
</state>
</provider>
<provider editor-type-id="HtmlPreview">
<state />
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/example/example.html"> <entry file="file://$PROJECT_DIR$/example/example.html">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state line="0" column="0" selection-start="0" selection-end="721" vertical-scroll-proportion="0.0"> <state line="0" column="0" selection-start="0" selection-end="721" vertical-scroll-proportion="0.0">
@ -517,45 +534,28 @@
</entry> </entry>
<entry file="file://$PROJECT_DIR$/lib/jasmine.css"> <entry file="file://$PROJECT_DIR$/lib/jasmine.css">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state line="17" column="36" selection-start="351" selection-end="351" vertical-scroll-proportion="0.5209677"> <state line="17" column="36" selection-start="351" selection-end="351" vertical-scroll-proportion="0.33230454">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/json_reporter.js">
<provider selected="true" editor-type-id="text-editor">
<state line="20" column="0" selection-start="648" selection-end="648" vertical-scroll-proportion="0.15240084">
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/example/example.js"> <entry file="file://$PROJECT_DIR$/example/example.js">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state line="6" column="0" selection-start="183" selection-end="183" vertical-scroll-proportion="0.18387097"> <state line="6" column="0" selection-start="183" selection-end="183" vertical-scroll-proportion="0.11728395">
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/lib/jasmine.js"> <entry file="file://$PROJECT_DIR$/lib/jasmine.js">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state line="205" column="3" selection-start="4581" selection-end="4581" vertical-scroll-proportion="1.4096774"> <state line="389" column="1" selection-start="8626" selection-end="8626" vertical-scroll-proportion="0.88271606">
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/test/bootstrap.html">
<provider selected="true" editor-type-id="text-editor">
<state line="12" column="4" selection-start="533" selection-end="533" vertical-scroll-proportion="0.41379312">
<folding />
</state>
</provider>
<provider editor-type-id="HtmlPreview">
<state />
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/test/bootstrap.js"> <entry file="file://$PROJECT_DIR$/test/bootstrap.js">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state line="828" column="3" selection-start="25391" selection-end="26216" vertical-scroll-proportion="0.3322314"> <state line="842" column="193" selection-start="26377" selection-end="26377" vertical-scroll-proportion="0.94043887">
<folding /> <folding />
</state> </state>
</provider> </provider>

View File

@ -205,6 +205,11 @@ Jasmine.Matchers.method('should_match', function (reg_exp) {
'Expected ' + this.actual + ' to match ' + 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 * Jasmine spec constructor
*/ */

12
test/bootstrap.js vendored
View File

@ -65,6 +65,14 @@ var testMatchersComparisons = function () {
expected = new Jasmine.Matchers('foobazbel'); expected = new Jasmine.Matchers('foobazbel');
reporter.test(!(expected.should_match(/bar/)), reporter.test(!(expected.should_match(/bar/)),
'expects_that(forbazbel).should_match(/bar/) returned true'); '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 () { var testMatchersReporting = function () {
@ -826,13 +834,13 @@ var testHandlesExceptions = function () {
reporter.test((runner.suites[0].specs[0].expectationResults[0].passed === false), reporter.test((runner.suites[0].specs[0].expectationResults[0].passed === false),
'First test should have failed, got passed'); '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); '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), reporter.test((runner.suites[0].specs[1].expectationResults[0].passed === false),
'Second test should have a failing first result, got passed'); '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); '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), reporter.test((runner.suites[0].specs[1].expectationResults[1].passed === true),