jasnode 0.2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) hide show
  1. data/.gitignore +1 -0
  2. data/.gitmodules +3 -0
  3. data/MIT.LICENSE +20 -0
  4. data/README.md +28 -0
  5. data/Rakefile +34 -0
  6. data/VERSION.yml +5 -0
  7. data/bin/jasnode +52 -0
  8. data/features/jasnode.feature +24 -0
  9. data/features/step_definitions/jasnode-steps.rb +39 -0
  10. data/jasmine/MIT.LICENSE +20 -0
  11. data/jasmine/README.markdown +502 -0
  12. data/jasmine/Rakefile +158 -0
  13. data/jasmine/cruise_config.rb +21 -0
  14. data/jasmine/doc/files.html +460 -0
  15. data/jasmine/doc/index.html +322 -0
  16. data/jasmine/doc/symbols/_global_.html +918 -0
  17. data/jasmine/doc/symbols/jasmine.Block.html +417 -0
  18. data/jasmine/doc/symbols/jasmine.Clock.html +678 -0
  19. data/jasmine/doc/symbols/jasmine.Env.html +1169 -0
  20. data/jasmine/doc/symbols/jasmine.JsApiReporter.html +822 -0
  21. data/jasmine/doc/symbols/jasmine.Matchers.html +1474 -0
  22. data/jasmine/doc/symbols/jasmine.MultiReporter.html +394 -0
  23. data/jasmine/doc/symbols/jasmine.NestedResults.html +710 -0
  24. data/jasmine/doc/symbols/jasmine.Reporter.html +574 -0
  25. data/jasmine/doc/symbols/jasmine.Runner.html +710 -0
  26. data/jasmine/doc/symbols/jasmine.Spec.html +1253 -0
  27. data/jasmine/doc/symbols/jasmine.Spy.html +855 -0
  28. data/jasmine/doc/symbols/jasmine.Suite.html +705 -0
  29. data/jasmine/doc/symbols/jasmine.html +1345 -0
  30. data/jasmine/doc/symbols/jasmine.util.html +535 -0
  31. data/jasmine/doc/symbols/src/lib_TrivialReporter.js.html +124 -0
  32. data/jasmine/doc/symbols/src/src_Block.js.html +29 -0
  33. data/jasmine/doc/symbols/src/src_Env.js.html +248 -0
  34. data/jasmine/doc/symbols/src/src_JsApiReporter.js.html +111 -0
  35. data/jasmine/doc/symbols/src/src_Matchers.js.html +344 -0
  36. data/jasmine/doc/symbols/src/src_MultiReporter.js.html +36 -0
  37. data/jasmine/doc/symbols/src/src_NestedResults.js.html +88 -0
  38. data/jasmine/doc/symbols/src/src_PrettyPrinter.js.html +130 -0
  39. data/jasmine/doc/symbols/src/src_Queue.js.html +102 -0
  40. data/jasmine/doc/symbols/src/src_Reporter.js.html +35 -0
  41. data/jasmine/doc/symbols/src/src_Reporters.js.html +51 -0
  42. data/jasmine/doc/symbols/src/src_Runner.js.html +75 -0
  43. data/jasmine/doc/symbols/src/src_Spec.js.html +214 -0
  44. data/jasmine/doc/symbols/src/src_Suite.js.html +77 -0
  45. data/jasmine/doc/symbols/src/src_WaitsBlock.js.html +21 -0
  46. data/jasmine/doc/symbols/src/src_WaitsForBlock.js.html +45 -0
  47. data/jasmine/doc/symbols/src/src_base.js.html +585 -0
  48. data/jasmine/doc/symbols/src/src_mock-timeout.js.html +185 -0
  49. data/jasmine/doc/symbols/src/src_util.js.html +75 -0
  50. data/jasmine/examples/html/example_runner.html +27 -0
  51. data/jasmine/examples/html/spec/example_suite.js +11 -0
  52. data/jasmine/examples/ruby/Rakefile +33 -0
  53. data/jasmine/examples/ruby/spec/example/example_spec.js +11 -0
  54. data/jasmine/examples/ruby/spec/jasmine_helper.rb +41 -0
  55. data/jasmine/examples/ruby/spec/jasmine_spec.rb +31 -0
  56. data/jasmine/examples/ruby/spec/saucelabs.yml +24 -0
  57. data/jasmine/geminstaller.yml +25 -0
  58. data/jasmine/images/fail-16.png +0 -0
  59. data/jasmine/images/fail.png +0 -0
  60. data/jasmine/images/go-16.png +0 -0
  61. data/jasmine/images/go.png +0 -0
  62. data/jasmine/images/pending-16.png +0 -0
  63. data/jasmine/images/pending.png +0 -0
  64. data/jasmine/images/question-bk.png +0 -0
  65. data/jasmine/images/questionbk-16.png +0 -0
  66. data/jasmine/images/spinner.gif +0 -0
  67. data/jasmine/lib/TrivialReporter.js +117 -0
  68. data/jasmine/lib/consolex.js +28 -0
  69. data/jasmine/lib/jasmine-0.10.2.js +2318 -0
  70. data/jasmine/lib/jasmine.css +86 -0
  71. data/jasmine/lib/json2.js +478 -0
  72. data/jasmine/spec/jasmine_helper.rb +44 -0
  73. data/jasmine/spec/jasmine_spec.rb +31 -0
  74. data/jasmine/spec/runner.html +79 -0
  75. data/jasmine/spec/saucelabs.yml +24 -0
  76. data/jasmine/spec/suites/CustomMatchersSpec.js +112 -0
  77. data/jasmine/spec/suites/EnvSpec.js +141 -0
  78. data/jasmine/spec/suites/ExceptionsSpec.js +107 -0
  79. data/jasmine/spec/suites/JsApiReporterSpec.js +82 -0
  80. data/jasmine/spec/suites/MatchersSpec.js +709 -0
  81. data/jasmine/spec/suites/MockClockSpec.js +34 -0
  82. data/jasmine/spec/suites/MultiReporterSpec.js +30 -0
  83. data/jasmine/spec/suites/NestedResultsSpec.js +54 -0
  84. data/jasmine/spec/suites/PrettyPrintSpec.js +93 -0
  85. data/jasmine/spec/suites/QueueSpec.js +23 -0
  86. data/jasmine/spec/suites/ReporterSpec.js +60 -0
  87. data/jasmine/spec/suites/RunnerSpec.js +252 -0
  88. data/jasmine/spec/suites/SpecRunningSpec.js +1086 -0
  89. data/jasmine/spec/suites/SpecSpec.js +110 -0
  90. data/jasmine/spec/suites/SpySpec.js +201 -0
  91. data/jasmine/spec/suites/SuiteSpec.js +101 -0
  92. data/jasmine/spec/suites/TrivialReporterSpec.js +140 -0
  93. data/jasmine/spec/suites/UtilSpec.js +40 -0
  94. data/jasmine/src/Block.js +22 -0
  95. data/jasmine/src/Env.js +240 -0
  96. data/jasmine/src/JsApiReporter.js +103 -0
  97. data/jasmine/src/Matchers.js +336 -0
  98. data/jasmine/src/MultiReporter.js +28 -0
  99. data/jasmine/src/NestedResults.js +80 -0
  100. data/jasmine/src/PrettyPrinter.js +122 -0
  101. data/jasmine/src/Queue.js +94 -0
  102. data/jasmine/src/Reporter.js +27 -0
  103. data/jasmine/src/Reporters.js +43 -0
  104. data/jasmine/src/Runner.js +68 -0
  105. data/jasmine/src/Spec.js +206 -0
  106. data/jasmine/src/Suite.js +70 -0
  107. data/jasmine/src/WaitsBlock.js +13 -0
  108. data/jasmine/src/WaitsForBlock.js +38 -0
  109. data/jasmine/src/base.js +578 -0
  110. data/jasmine/src/mock-timeout.js +177 -0
  111. data/jasmine/src/util.js +67 -0
  112. data/jasmine/src/version.json +5 -0
  113. data/jasnode.gemspec +171 -0
  114. data/lib/jasnode/core.rb +180 -0
  115. data/lib/jasnode.js +135 -0
  116. data/lib/jasnode.rb +4 -0
  117. data/pkg/jasnode-0.1.0.0.gem +0 -0
  118. data/spec/jasnode/jasnode_spec.rb +40 -0
  119. data/spec/rspec_suite.rb +8 -0
  120. data/spec/spec_helper.rb +6 -0
  121. data/templates/Rakefile +9 -0
  122. data/templates/bin/hello_world +5 -0
  123. data/templates/lib/server.js +25 -0
  124. data/templates/spec/README.md +3 -0
  125. data/templates/spec/runner.js +16 -0
  126. data/templates/spec/server/server_spec.js +45 -0
  127. data/templates/spec/server/spec_server.js +45 -0
  128. data/templates/spec/spec.js +45 -0
  129. metadata +184 -0
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Holds results for a set of Jasmine spec. Allows for the results array to hold another jasmine.NestedResults
3
+ *
4
+ * @constructor
5
+ */
6
+ jasmine.NestedResults = function() {
7
+ /**
8
+ * The total count of results
9
+ */
10
+ this.totalCount = 0;
11
+ /**
12
+ * Number of passed results
13
+ */
14
+ this.passedCount = 0;
15
+ /**
16
+ * Number of failed results
17
+ */
18
+ this.failedCount = 0;
19
+ /**
20
+ * Was this suite/spec skipped?
21
+ */
22
+ this.skipped = false;
23
+ /**
24
+ * @ignore
25
+ */
26
+ this.items_ = [];
27
+ };
28
+
29
+ /**
30
+ * Roll up the result counts.
31
+ *
32
+ * @param result
33
+ */
34
+ jasmine.NestedResults.prototype.rollupCounts = function(result) {
35
+ this.totalCount += result.totalCount;
36
+ this.passedCount += result.passedCount;
37
+ this.failedCount += result.failedCount;
38
+ };
39
+
40
+ /**
41
+ * Tracks a result's message.
42
+ * @param message
43
+ */
44
+ jasmine.NestedResults.prototype.log = function(message) {
45
+ this.items_.push(new jasmine.MessageResult(message));
46
+ };
47
+
48
+ /**
49
+ * Getter for the results: message & results.
50
+ */
51
+ jasmine.NestedResults.prototype.getItems = function() {
52
+ return this.items_;
53
+ };
54
+
55
+ /**
56
+ * Adds a result, tracking counts (total, passed, & failed)
57
+ * @param {jasmine.ExpectationResult|jasmine.NestedResults} result
58
+ */
59
+ jasmine.NestedResults.prototype.addResult = function(result) {
60
+ if (result.type != 'MessageResult') {
61
+ if (result.items_) {
62
+ this.rollupCounts(result);
63
+ } else {
64
+ this.totalCount++;
65
+ if (result.passed()) {
66
+ this.passedCount++;
67
+ } else {
68
+ this.failedCount++;
69
+ }
70
+ }
71
+ }
72
+ this.items_.push(result);
73
+ };
74
+
75
+ /**
76
+ * @returns {Boolean} True if <b>everything</b> below passed
77
+ */
78
+ jasmine.NestedResults.prototype.passed = function() {
79
+ return this.passedCount === this.totalCount;
80
+ };
@@ -0,0 +1,122 @@
1
+ /**
2
+ * Base class for pretty printing for expectation results.
3
+ */
4
+ jasmine.PrettyPrinter = function() {
5
+ this.ppNestLevel_ = 0;
6
+ };
7
+
8
+ /**
9
+ * Formats a value in a nice, human-readable string.
10
+ *
11
+ * @param value
12
+ */
13
+ jasmine.PrettyPrinter.prototype.format = function(value) {
14
+ if (this.ppNestLevel_ > 40) {
15
+ throw new Error('jasmine.PrettyPrinter: format() nested too deeply!');
16
+ }
17
+
18
+ this.ppNestLevel_++;
19
+ try {
20
+ if (value === jasmine.undefined) {
21
+ this.emitScalar('undefined');
22
+ } else if (value === null) {
23
+ this.emitScalar('null');
24
+ } else if (value.navigator && value.frames && value.setTimeout) {
25
+ this.emitScalar('<window>');
26
+ } else if (value instanceof jasmine.Matchers.Any) {
27
+ this.emitScalar(value.toString());
28
+ } else if (typeof value === 'string') {
29
+ this.emitString(value);
30
+ } else if (jasmine.isSpy(value)) {
31
+ this.emitScalar("spy on " + value.identity);
32
+ } else if (value instanceof RegExp) {
33
+ this.emitScalar(value.toString());
34
+ } else if (typeof value === 'function') {
35
+ this.emitScalar('Function');
36
+ } else if (typeof value.nodeType === 'number') {
37
+ this.emitScalar('HTMLNode');
38
+ } else if (value instanceof Date) {
39
+ this.emitScalar('Date(' + value + ')');
40
+ } else if (value.__Jasmine_been_here_before__) {
41
+ this.emitScalar('<circular reference: ' + (jasmine.isArray_(value) ? 'Array' : 'Object') + '>');
42
+ } else if (jasmine.isArray_(value) || typeof value == 'object') {
43
+ value.__Jasmine_been_here_before__ = true;
44
+ if (jasmine.isArray_(value)) {
45
+ this.emitArray(value);
46
+ } else {
47
+ this.emitObject(value);
48
+ }
49
+ delete value.__Jasmine_been_here_before__;
50
+ } else {
51
+ this.emitScalar(value.toString());
52
+ }
53
+ } finally {
54
+ this.ppNestLevel_--;
55
+ }
56
+ };
57
+
58
+ jasmine.PrettyPrinter.prototype.iterateObject = function(obj, fn) {
59
+ for (var property in obj) {
60
+ if (property == '__Jasmine_been_here_before__') continue;
61
+ fn(property, obj.__lookupGetter__ ? (obj.__lookupGetter__(property) != null) : false);
62
+ }
63
+ };
64
+
65
+ jasmine.PrettyPrinter.prototype.emitArray = jasmine.unimplementedMethod_;
66
+ jasmine.PrettyPrinter.prototype.emitObject = jasmine.unimplementedMethod_;
67
+ jasmine.PrettyPrinter.prototype.emitScalar = jasmine.unimplementedMethod_;
68
+ jasmine.PrettyPrinter.prototype.emitString = jasmine.unimplementedMethod_;
69
+
70
+ jasmine.StringPrettyPrinter = function() {
71
+ jasmine.PrettyPrinter.call(this);
72
+
73
+ this.string = '';
74
+ };
75
+ jasmine.util.inherit(jasmine.StringPrettyPrinter, jasmine.PrettyPrinter);
76
+
77
+ jasmine.StringPrettyPrinter.prototype.emitScalar = function(value) {
78
+ this.append(value);
79
+ };
80
+
81
+ jasmine.StringPrettyPrinter.prototype.emitString = function(value) {
82
+ this.append("'" + value + "'");
83
+ };
84
+
85
+ jasmine.StringPrettyPrinter.prototype.emitArray = function(array) {
86
+ this.append('[ ');
87
+ for (var i = 0; i < array.length; i++) {
88
+ if (i > 0) {
89
+ this.append(', ');
90
+ }
91
+ this.format(array[i]);
92
+ }
93
+ this.append(' ]');
94
+ };
95
+
96
+ jasmine.StringPrettyPrinter.prototype.emitObject = function(obj) {
97
+ var self = this;
98
+ this.append('{ ');
99
+ var first = true;
100
+
101
+ this.iterateObject(obj, function(property, isGetter) {
102
+ if (first) {
103
+ first = false;
104
+ } else {
105
+ self.append(', ');
106
+ }
107
+
108
+ self.append(property);
109
+ self.append(' : ');
110
+ if (isGetter) {
111
+ self.append('<getter>');
112
+ } else {
113
+ self.format(obj[property]);
114
+ }
115
+ });
116
+
117
+ this.append(' }');
118
+ };
119
+
120
+ jasmine.StringPrettyPrinter.prototype.append = function(value) {
121
+ this.string += value;
122
+ };
@@ -0,0 +1,94 @@
1
+ jasmine.Queue = function(env) {
2
+ this.env = env;
3
+ this.blocks = [];
4
+ this.running = false;
5
+ this.index = 0;
6
+ this.offset = 0;
7
+ };
8
+
9
+ jasmine.Queue.prototype.addBefore = function(block) {
10
+ this.blocks.unshift(block);
11
+ };
12
+
13
+ jasmine.Queue.prototype.add = function(block) {
14
+ this.blocks.push(block);
15
+ };
16
+
17
+ jasmine.Queue.prototype.insertNext = function(block) {
18
+ this.blocks.splice((this.index + this.offset + 1), 0, block);
19
+ this.offset++;
20
+ };
21
+
22
+ jasmine.Queue.prototype.start = function(onComplete) {
23
+ this.running = true;
24
+ this.onComplete = onComplete;
25
+ this.next_();
26
+ };
27
+
28
+ jasmine.Queue.prototype.isRunning = function() {
29
+ return this.running;
30
+ };
31
+
32
+ jasmine.Queue.LOOP_DONT_RECURSE = true;
33
+
34
+ jasmine.Queue.prototype.next_ = function() {
35
+ var self = this;
36
+ var goAgain = true;
37
+
38
+ while (goAgain) {
39
+ goAgain = false;
40
+
41
+ if (self.index < self.blocks.length) {
42
+ var calledSynchronously = true;
43
+ var completedSynchronously = false;
44
+
45
+ var onComplete = function () {
46
+ if (jasmine.Queue.LOOP_DONT_RECURSE && calledSynchronously) {
47
+ completedSynchronously = true;
48
+ return;
49
+ }
50
+
51
+ self.offset = 0;
52
+ self.index++;
53
+
54
+ var now = new Date().getTime();
55
+ if (self.env.updateInterval && now - self.env.lastUpdate > self.env.updateInterval) {
56
+ self.env.lastUpdate = now;
57
+ self.env.setTimeout(function() {
58
+ self.next_();
59
+ }, 0);
60
+ } else {
61
+ if (jasmine.Queue.LOOP_DONT_RECURSE && completedSynchronously) {
62
+ goAgain = true;
63
+ } else {
64
+ self.next_();
65
+ }
66
+ }
67
+ };
68
+ self.blocks[self.index].execute(onComplete);
69
+
70
+ calledSynchronously = false;
71
+ if (completedSynchronously) {
72
+ onComplete();
73
+ }
74
+
75
+ } else {
76
+ self.running = false;
77
+ if (self.onComplete) {
78
+ self.onComplete();
79
+ }
80
+ }
81
+ }
82
+ };
83
+
84
+ jasmine.Queue.prototype.results = function() {
85
+ var results = new jasmine.NestedResults();
86
+ for (var i = 0; i < this.blocks.length; i++) {
87
+ if (this.blocks[i].results) {
88
+ results.addResult(this.blocks[i].results());
89
+ }
90
+ }
91
+ return results;
92
+ };
93
+
94
+
@@ -0,0 +1,27 @@
1
+ /** No-op base class for Jasmine reporters.
2
+ *
3
+ * @constructor
4
+ */
5
+ jasmine.Reporter = function() {
6
+ };
7
+
8
+ //noinspection JSUnusedLocalSymbols
9
+ jasmine.Reporter.prototype.reportRunnerStarting = function(runner) {
10
+ };
11
+
12
+ //noinspection JSUnusedLocalSymbols
13
+ jasmine.Reporter.prototype.reportRunnerResults = function(runner) {
14
+ };
15
+
16
+ //noinspection JSUnusedLocalSymbols
17
+ jasmine.Reporter.prototype.reportSuiteResults = function(suite) {
18
+ };
19
+
20
+ //noinspection JSUnusedLocalSymbols
21
+ jasmine.Reporter.prototype.reportSpecResults = function(spec) {
22
+ };
23
+
24
+ //noinspection JSUnusedLocalSymbols
25
+ jasmine.Reporter.prototype.log = function(str) {
26
+ };
27
+
@@ -0,0 +1,43 @@
1
+ /** JasmineReporters.reporter
2
+ * Base object that will get called whenever a Spec, Suite, or Runner is done. It is up to
3
+ * descendants of this object to do something with the results (see json_reporter.js)
4
+ *
5
+ * @deprecated
6
+ */
7
+ jasmine.Reporters = {};
8
+
9
+ /**
10
+ * @deprecated
11
+ * @param callbacks
12
+ */
13
+ jasmine.Reporters.reporter = function(callbacks) {
14
+ /**
15
+ * @deprecated
16
+ * @param callbacks
17
+ */
18
+ var that = {
19
+ callbacks: callbacks || {},
20
+
21
+ doCallback: function(callback, results) {
22
+ if (callback) {
23
+ callback(results);
24
+ }
25
+ },
26
+
27
+ reportRunnerResults: function(runner) {
28
+ that.doCallback(that.callbacks.runnerCallback, runner);
29
+ },
30
+ reportSuiteResults: function(suite) {
31
+ that.doCallback(that.callbacks.suiteCallback, suite);
32
+ },
33
+ reportSpecResults: function(spec) {
34
+ that.doCallback(that.callbacks.specCallback, spec);
35
+ },
36
+ log: function (str) {
37
+ if (console && console.log) console.log(str);
38
+ }
39
+ };
40
+
41
+ return that;
42
+ };
43
+
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Runner
3
+ *
4
+ * @constructor
5
+ * @param {jasmine.Env} env
6
+ */
7
+ jasmine.Runner = function(env) {
8
+ var self = this;
9
+ self.env = env;
10
+ self.queue = new jasmine.Queue(env);
11
+ self.before_ = [];
12
+ self.after_ = [];
13
+ self.suites_ = [];
14
+ };
15
+
16
+ jasmine.Runner.prototype.execute = function() {
17
+ var self = this;
18
+ if (self.env.reporter.reportRunnerStarting) {
19
+ self.env.reporter.reportRunnerStarting(this);
20
+ }
21
+ self.queue.start(function () {
22
+ self.finishCallback();
23
+ });
24
+ };
25
+
26
+ jasmine.Runner.prototype.beforeEach = function(beforeEachFunction) {
27
+ beforeEachFunction.typeName = 'beforeEach';
28
+ this.before_.push(beforeEachFunction);
29
+ };
30
+
31
+ jasmine.Runner.prototype.afterEach = function(afterEachFunction) {
32
+ afterEachFunction.typeName = 'afterEach';
33
+ this.after_.push(afterEachFunction);
34
+ };
35
+
36
+
37
+ jasmine.Runner.prototype.finishCallback = function() {
38
+ this.env.reporter.reportRunnerResults(this);
39
+ };
40
+
41
+ jasmine.Runner.prototype.addSuite = function(suite) {
42
+ this.suites_.push(suite);
43
+ };
44
+
45
+ jasmine.Runner.prototype.add = function(block) {
46
+ if (block instanceof jasmine.Suite) {
47
+ this.addSuite(block);
48
+ }
49
+ this.queue.add(block);
50
+ };
51
+
52
+ jasmine.Runner.prototype.specs = function () {
53
+ var suites = this.suites();
54
+ var specs = [];
55
+ for (var i = 0; i < suites.length; i++) {
56
+ specs = specs.concat(suites[i].specs());
57
+ }
58
+ return specs;
59
+ };
60
+
61
+
62
+ jasmine.Runner.prototype.suites = function() {
63
+ return this.suites_;
64
+ };
65
+
66
+ jasmine.Runner.prototype.results = function() {
67
+ return this.queue.results();
68
+ };
@@ -0,0 +1,206 @@
1
+ /**
2
+ * Internal representation of a Jasmine specification, or test.
3
+ *
4
+ * @constructor
5
+ * @param {jasmine.Env} env
6
+ * @param {jasmine.Suite} suite
7
+ * @param {String} description
8
+ */
9
+ jasmine.Spec = function(env, suite, description) {
10
+ if (!env) {
11
+ throw new Error('jasmine.Env() required');
12
+ }
13
+ if (!suite) {
14
+ throw new Error('jasmine.Suite() required');
15
+ }
16
+ var spec = this;
17
+ spec.id = env.nextSpecId ? env.nextSpecId() : null;
18
+ spec.env = env;
19
+ spec.suite = suite;
20
+ spec.description = description;
21
+ spec.queue = new jasmine.Queue(env);
22
+
23
+ spec.afterCallbacks = [];
24
+ spec.spies_ = [];
25
+
26
+ spec.results_ = new jasmine.NestedResults();
27
+ spec.results_.description = description;
28
+ spec.matchersClass = null;
29
+ };
30
+
31
+ jasmine.Spec.prototype.getFullName = function() {
32
+ return this.suite.getFullName() + ' ' + this.description + '.';
33
+ };
34
+
35
+
36
+ jasmine.Spec.prototype.results = function() {
37
+ return this.results_;
38
+ };
39
+
40
+ jasmine.Spec.prototype.log = function(message) {
41
+ return this.results_.log(message);
42
+ };
43
+
44
+ /** @deprecated */
45
+ jasmine.Spec.prototype.getResults = function() {
46
+ return this.results_;
47
+ };
48
+
49
+ jasmine.Spec.prototype.runs = function (func) {
50
+ var block = new jasmine.Block(this.env, func, this);
51
+ this.addToQueue(block);
52
+ return this;
53
+ };
54
+
55
+ jasmine.Spec.prototype.addToQueue = function (block) {
56
+ if (this.queue.isRunning()) {
57
+ this.queue.insertNext(block);
58
+ } else {
59
+ this.queue.add(block);
60
+ }
61
+ };
62
+
63
+ jasmine.Spec.prototype.addMatcherResult = function(result) {
64
+ this.results_.addResult(result);
65
+ };
66
+
67
+ jasmine.Spec.prototype.expect = function(actual) {
68
+ var positive = new (this.getMatchersClass_())(this.env, actual, this);
69
+ positive.not = new (this.getMatchersClass_())(this.env, actual, this, true);
70
+ return positive;
71
+ };
72
+
73
+ jasmine.Spec.prototype.waits = function(timeout) {
74
+ var waitsFunc = new jasmine.WaitsBlock(this.env, timeout, this);
75
+ this.addToQueue(waitsFunc);
76
+ return this;
77
+ };
78
+
79
+ jasmine.Spec.prototype.waitsFor = function(timeout, latchFunction, timeoutMessage) {
80
+ var waitsForFunc = new jasmine.WaitsForBlock(this.env, timeout, latchFunction, timeoutMessage, this);
81
+ this.addToQueue(waitsForFunc);
82
+ return this;
83
+ };
84
+
85
+ jasmine.Spec.prototype.fail = function (e) {
86
+ var expectationResult = new jasmine.ExpectationResult({
87
+ passed: false,
88
+ message: e ? jasmine.util.formatException(e) : 'Exception'
89
+ });
90
+ this.results_.addResult(expectationResult);
91
+ };
92
+
93
+ jasmine.Spec.prototype.getMatchersClass_ = function() {
94
+ return this.matchersClass || this.env.matchersClass;
95
+ };
96
+
97
+ jasmine.Spec.prototype.addMatchers = function(matchersPrototype) {
98
+ var parent = this.getMatchersClass_();
99
+ var newMatchersClass = function() {
100
+ parent.apply(this, arguments);
101
+ };
102
+ jasmine.util.inherit(newMatchersClass, parent);
103
+ jasmine.Matchers.wrapInto_(matchersPrototype, newMatchersClass);
104
+ this.matchersClass = newMatchersClass;
105
+ };
106
+
107
+ jasmine.Spec.prototype.finishCallback = function() {
108
+ this.env.reporter.reportSpecResults(this);
109
+ };
110
+
111
+ jasmine.Spec.prototype.finish = function(onComplete) {
112
+ this.removeAllSpies();
113
+ this.finishCallback();
114
+ if (onComplete) {
115
+ onComplete();
116
+ }
117
+ };
118
+
119
+ jasmine.Spec.prototype.after = function(doAfter) {
120
+ if (this.queue.isRunning()) {
121
+ this.queue.add(new jasmine.Block(this.env, doAfter, this));
122
+ } else {
123
+ this.afterCallbacks.unshift(doAfter);
124
+ }
125
+ };
126
+
127
+ jasmine.Spec.prototype.execute = function(onComplete) {
128
+ var spec = this;
129
+ if (!spec.env.specFilter(spec)) {
130
+ spec.results_.skipped = true;
131
+ spec.finish(onComplete);
132
+ return;
133
+ }
134
+ this.env.reporter.log('>> Jasmine Running ' + this.suite.description + ' ' + this.description + '...');
135
+
136
+ spec.env.currentSpec = spec;
137
+
138
+ spec.addBeforesAndAftersToQueue();
139
+
140
+ spec.queue.start(function () {
141
+ spec.finish(onComplete);
142
+ });
143
+ };
144
+
145
+ jasmine.Spec.prototype.addBeforesAndAftersToQueue = function() {
146
+ var runner = this.env.currentRunner();
147
+ var i;
148
+
149
+ for (var suite = this.suite; suite; suite = suite.parentSuite) {
150
+ for (i = 0; i < suite.before_.length; i++) {
151
+ this.queue.addBefore(new jasmine.Block(this.env, suite.before_[i], this));
152
+ }
153
+ }
154
+ for (i = 0; i < runner.before_.length; i++) {
155
+ this.queue.addBefore(new jasmine.Block(this.env, runner.before_[i], this));
156
+ }
157
+ for (i = 0; i < this.afterCallbacks.length; i++) {
158
+ this.queue.add(new jasmine.Block(this.env, this.afterCallbacks[i], this));
159
+ }
160
+ for (suite = this.suite; suite; suite = suite.parentSuite) {
161
+ for (i = 0; i < suite.after_.length; i++) {
162
+ this.queue.add(new jasmine.Block(this.env, suite.after_[i], this));
163
+ }
164
+ }
165
+ for (i = 0; i < runner.after_.length; i++) {
166
+ this.queue.add(new jasmine.Block(this.env, runner.after_[i], this));
167
+ }
168
+ };
169
+
170
+ jasmine.Spec.prototype.explodes = function() {
171
+ throw 'explodes function should not have been called';
172
+ };
173
+
174
+ jasmine.Spec.prototype.spyOn = function(obj, methodName, ignoreMethodDoesntExist) {
175
+ if (obj == jasmine.undefined) {
176
+ throw "spyOn could not find an object to spy upon for " + methodName + "()";
177
+ }
178
+
179
+ if (!ignoreMethodDoesntExist && obj[methodName] === jasmine.undefined) {
180
+ throw methodName + '() method does not exist';
181
+ }
182
+
183
+ if (!ignoreMethodDoesntExist && obj[methodName] && obj[methodName].isSpy) {
184
+ throw new Error(methodName + ' has already been spied upon');
185
+ }
186
+
187
+ var spyObj = jasmine.createSpy(methodName);
188
+
189
+ this.spies_.push(spyObj);
190
+ spyObj.baseObj = obj;
191
+ spyObj.methodName = methodName;
192
+ spyObj.originalValue = obj[methodName];
193
+
194
+ obj[methodName] = spyObj;
195
+
196
+ return spyObj;
197
+ };
198
+
199
+ jasmine.Spec.prototype.removeAllSpies = function() {
200
+ for (var i = 0; i < this.spies_.length; i++) {
201
+ var spy = this.spies_[i];
202
+ spy.baseObj[spy.methodName] = spy.originalValue;
203
+ }
204
+ this.spies_ = [];
205
+ };
206
+
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Internal representation of a Jasmine suite.
3
+ *
4
+ * @constructor
5
+ * @param {jasmine.Env} env
6
+ * @param {String} description
7
+ * @param {Function} specDefinitions
8
+ * @param {jasmine.Suite} parentSuite
9
+ */
10
+ jasmine.Suite = function(env, description, specDefinitions, parentSuite) {
11
+ var self = this;
12
+ self.id = env.nextSuiteId ? env.nextSuiteId() : null;
13
+ self.description = description;
14
+ self.queue = new jasmine.Queue(env);
15
+ self.parentSuite = parentSuite;
16
+ self.env = env;
17
+ self.before_ = [];
18
+ self.after_ = [];
19
+ self.specs_ = [];
20
+ };
21
+
22
+ jasmine.Suite.prototype.getFullName = function() {
23
+ var fullName = this.description;
24
+ for (var parentSuite = this.parentSuite; parentSuite; parentSuite = parentSuite.parentSuite) {
25
+ fullName = parentSuite.description + ' ' + fullName;
26
+ }
27
+ return fullName;
28
+ };
29
+
30
+ jasmine.Suite.prototype.finish = function(onComplete) {
31
+ this.env.reporter.reportSuiteResults(this);
32
+ this.finished = true;
33
+ if (typeof(onComplete) == 'function') {
34
+ onComplete();
35
+ }
36
+ };
37
+
38
+ jasmine.Suite.prototype.beforeEach = function(beforeEachFunction) {
39
+ beforeEachFunction.typeName = 'beforeEach';
40
+ this.before_.push(beforeEachFunction);
41
+ };
42
+
43
+ jasmine.Suite.prototype.afterEach = function(afterEachFunction) {
44
+ afterEachFunction.typeName = 'afterEach';
45
+ this.after_.push(afterEachFunction);
46
+ };
47
+
48
+ jasmine.Suite.prototype.results = function() {
49
+ return this.queue.results();
50
+ };
51
+
52
+ jasmine.Suite.prototype.add = function(block) {
53
+ if (block instanceof jasmine.Suite) {
54
+ this.env.currentRunner().addSuite(block);
55
+ } else {
56
+ this.specs_.push(block);
57
+ }
58
+ this.queue.add(block);
59
+ };
60
+
61
+ jasmine.Suite.prototype.specs = function() {
62
+ return this.specs_;
63
+ };
64
+
65
+ jasmine.Suite.prototype.execute = function(onComplete) {
66
+ var self = this;
67
+ this.queue.start(function () {
68
+ self.finish(onComplete);
69
+ });
70
+ };