Skip to content

Commit

Permalink
dwf/rva: actionColllection now has an optional finishCallback
Browse files Browse the repository at this point in the history
  • Loading branch information
pivotalops committed Dec 4, 2008
1 parent f5486bd commit 735ebd6
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 56 deletions.
110 changes: 55 additions & 55 deletions jasmine.iws
Original file line number Diff line number Diff line change
Expand Up @@ -79,44 +79,44 @@
<leaf>
<file leaf-file-name="bootstrap.html" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/test/bootstrap.html">
<provider editor-type-id="HtmlPreview">
<state />
</provider>
<provider selected="true" editor-type-id="text-editor">
<state line="7" column="61" selection-start="350" selection-end="350" vertical-scroll-proportion="0.13782384">
<folding />
</state>
</provider>
<provider editor-type-id="HtmlPreview">
<state />
</provider>
</entry>
</file>
<file leaf-file-name="bootstrap.js" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/test/bootstrap.js">
<provider selected="true" editor-type-id="text-editor">
<state line="518" column="0" selection-start="14460" selection-end="14460" vertical-scroll-proportion="0.59381044">
<state line="565" column="0" selection-start="15772" selection-end="15858" vertical-scroll-proportion="0.7794971">
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="jasmine.js" pinned="false" current="false" current-in-tab="false">
<file leaf-file-name="jasmine.js" pinned="false" current="true" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/lib/jasmine.js">
<provider selected="true" editor-type-id="text-editor">
<state line="279" column="17" selection-start="5820" selection-end="5820" vertical-scroll-proportion="0.3968254">
<state line="70" column="0" selection-start="1481" selection-end="1553" vertical-scroll-proportion="0.2205029">
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="example.html" pinned="false" current="true" current-in-tab="true">
<file leaf-file-name="example.html" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/example/example.html">
<provider editor-type-id="HtmlPreview">
<state />
</provider>
<provider selected="true" editor-type-id="text-editor">
<state line="8" column="7" selection-start="355" selection-end="355" vertical-scroll-proportion="0.15751295">
<folding />
</state>
</provider>
<provider editor-type-id="HtmlPreview">
<state />
</provider>
</entry>
</file>
<file leaf-file-name="jasmine.css" pinned="false" current="false" current-in-tab="false">
Expand Down Expand Up @@ -296,6 +296,19 @@
<RUBY_DOC NAME="NUMBER" VALUE="0" />
</component>
<component name="RunManager">
<configuration default="true" type="Application" factoryName="Application" enabled="false" merge="false">
<option name="MAIN_CLASS_NAME" />
<option name="VM_PARAMETERS" />
<option name="PROGRAM_PARAMETERS" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="ENABLE_SWING_INSPECTOR" value="false" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<module name="" />
<envs />
</configuration>
<configuration default="true" type="JUnit" factoryName="JUnit" enabled="false" merge="false">
<module name="" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
Expand All @@ -315,38 +328,6 @@
</option>
<envs />
</configuration>
<configuration default="true" type="Application" factoryName="Application" enabled="false" merge="false">
<option name="MAIN_CLASS_NAME" />
<option name="VM_PARAMETERS" />
<option name="PROGRAM_PARAMETERS" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="ENABLE_SWING_INSPECTOR" value="false" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<module name="" />
<envs />
</configuration>
<configuration default="true" type="Remote" factoryName="Remote">
<option name="USE_SOCKET_TRANSPORT" value="true" />
<option name="SERVER_MODE" value="false" />
<option name="SHMEM_ADDRESS" value="javadebug" />
<option name="HOST" value="localhost" />
<option name="PORT" value="5005" />
</configuration>
<configuration default="true" type="Applet" factoryName="Applet">
<module name="" />
<option name="MAIN_CLASS_NAME" />
<option name="HTML_FILE_NAME" />
<option name="HTML_USED" value="false" />
<option name="WIDTH" value="400" />
<option name="HEIGHT" value="300" />
<option name="POLICY_FILE" value="$APPLICATION_HOME_DIR$/bin/appletviewer.policy" />
<option name="VM_PARAMETERS" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
</configuration>
<configuration default="true" type="RubyRunConfigurationType" factoryName="Ruby test">
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="TESTS_FOLDER_PATH" VALUE="" />
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="" />
Expand All @@ -361,6 +342,25 @@
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="ALTERN_SDK_NAME" VALUE="" />
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="INHERITANCE_CHECK_DISABLED" VALUE="false" />
</configuration>
<configuration default="true" type="Applet" factoryName="Applet">
<module name="" />
<option name="MAIN_CLASS_NAME" />
<option name="HTML_FILE_NAME" />
<option name="HTML_USED" value="false" />
<option name="WIDTH" value="400" />
<option name="HEIGHT" value="300" />
<option name="POLICY_FILE" value="$APPLICATION_HOME_DIR$/bin/appletviewer.policy" />
<option name="VM_PARAMETERS" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
</configuration>
<configuration default="true" type="Remote" factoryName="Remote">
<option name="USE_SOCKET_TRANSPORT" value="true" />
<option name="SERVER_MODE" value="false" />
<option name="SHMEM_ADDRESS" value="javadebug" />
<option name="HOST" value="localhost" />
<option name="PORT" value="5005" />
</configuration>
<list size="0" />
<configuration name="&lt;template&gt;" type="WebApp" default="true" selected="false">
<Host>localhost</Host>
Expand Down Expand Up @@ -412,7 +412,7 @@
</todo-panel>
</component>
<component name="ToolWindowManager">
<frame x="80" y="22" width="1661" height="1178" extended-state="0" />
<frame x="2" y="22" width="1661" height="1178" extended-state="0" />
<editor active="true" />
<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" />
Expand Down Expand Up @@ -499,14 +499,14 @@
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/test/bootstrap.html">
<provider editor-type-id="HtmlPreview">
<state />
</provider>
<provider selected="true" editor-type-id="text-editor">
<state line="7" column="61" selection-start="350" selection-end="350" vertical-scroll-proportion="0.13782384">
<folding />
</state>
</provider>
<provider editor-type-id="HtmlPreview">
<state />
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/jasmine.css">
<provider selected="true" editor-type-id="text-editor">
Expand All @@ -522,29 +522,29 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/test/bootstrap.js">
<entry file="file://$PROJECT_DIR$/example/example.html">
<provider editor-type-id="HtmlPreview">
<state />
</provider>
<provider selected="true" editor-type-id="text-editor">
<state line="518" column="0" selection-start="14460" selection-end="14460" vertical-scroll-proportion="0.59381044">
<state line="8" column="7" selection-start="355" selection-end="355" vertical-scroll-proportion="0.15751295">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/jasmine.js">
<entry file="file://$PROJECT_DIR$/test/bootstrap.js">
<provider selected="true" editor-type-id="text-editor">
<state line="279" column="17" selection-start="5820" selection-end="5820" vertical-scroll-proportion="0.3968254">
<state line="565" column="0" selection-start="15772" selection-end="15858" vertical-scroll-proportion="0.7794971">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/example/example.html">
<entry file="file://$PROJECT_DIR$/lib/jasmine.js">
<provider selected="true" editor-type-id="text-editor">
<state line="8" column="7" selection-start="355" selection-end="355" vertical-scroll-proportion="0.15751295">
<state line="70" column="0" selection-start="1481" selection-end="1553" vertical-scroll-proportion="0.2205029">
<folding />
</state>
</provider>
<provider editor-type-id="HtmlPreview">
<state />
</provider>
</entry>
</component>
</project>
Expand Down
9 changes: 8 additions & 1 deletion lib/jasmine.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ var actionCollection = function () {
finished: false,
results: nestedResults(),

finish: function () {
if (that.finishCallback) {
that.finishCallback();
}
that.finished = true;
},

report: function (result) {
that.results.push(result);
},
Expand All @@ -80,7 +87,7 @@ var actionCollection = function () {

next: function() {
if (that.index >= that.actions.length) {
that.finished = true;
that.finish();
return;
}

Expand Down
29 changes: 29 additions & 0 deletions test/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,34 @@ var testRunner = function() {
}, 1000);
}

var testRunnerFinishCallback = function () {
var runner = Runner();
var foo = 0;

runner.finish();

reporter.test((runner.finishCallback === undefined),
"Runner finish callback was defined");
reporter.test((runner.finished === true),
"Runner finished flag was not set.");


runner.finishCallback = function () {
foo++;
}

runner.finish();

reporter.test((runner.finished === true),
"Runner finished flag was not set.");
reporter.test((runner.finishCallback !== undefined),
"Runner finish callback was not defined");
reporter.test((foo === 1),
"Runner finish callback was not called");
}



var testNestedResults = function () {

// Leaf case
Expand Down Expand Up @@ -636,6 +664,7 @@ var runTests = function () {
testBeforeAndAfterCallbacks();
testSpecScope();
testRunner();
testRunnerFinishCallback();
testNestedResults();
testReporting();

Expand Down

0 comments on commit 735ebd6

Please sign in to comment.