jasmine-phantom 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.markdown CHANGED
@@ -1,8 +1,8 @@
1
1
  Jasmine Phantom
2
2
  ===============
3
3
 
4
- Jasmine Phantom provides a rake task that runs your jasmine specs via phanstomjs. It is adapted from the jasmine runner example that comes with
5
- phantom js. It requires jasmine `>= 1.2.0rc2`, which is only currency available via github.
4
+ Jasmine Phantom provides a rake task that runs your jasmine specs via phantomjs. It is adapted from the jasmine runner example that comes with
5
+ phantom js. It requires jasmine `>= 1.2.0rc2`, which is only currently available via GitHub.
6
6
 
7
7
  Installation
8
8
  ------------
@@ -18,7 +18,7 @@ Add jasmine 1.2.0rc2 and jasmine-phantom to your gemfile:
18
18
 
19
19
  and run `bundle install`.
20
20
 
21
- Then run `bundle exec rake jasmine` and check `http://localhost:8888/` to make sure you jasmine specs are passing.
21
+ Then run `bundle exec rake jasmine` and check `http://localhost:8888/` to make sure your jasmine specs are passing.
22
22
 
23
23
  Download and install the appropriate [PhantomJS](http://code.google.com/p/phantomjs/downloads/list) for your platform.
24
24
  Make sure to add the directory with the `phantomjs` executable to your `PATH`.
@@ -28,94 +28,103 @@ if (system.args.length !== 2) {
28
28
  phantom.exit();
29
29
  }
30
30
 
31
+ function jasmineReportsFinished(page){
32
+ return page.evaluate(function(){
33
+ return jsApiReporter.finished;
34
+ });
35
+ }
36
+
37
+ function collectJasmineResults() {
38
+ console.log('');
39
+ var suites = jsApiReporter.suites();
40
+ var results = jsApiReporter.results();
41
+
42
+ for(var specId in results) {
43
+ var result = results[specId];
44
+ if (result.result != "passed") {
45
+
46
+ var name = findSpecName(specId, suites);
47
+
48
+ console.log(name);
49
+
50
+ for (var msgId in result.messages) {
51
+ console.log(' ' + result.messages[msgId]);
52
+ }
53
+
54
+ console.log('');
55
+ }
56
+ }
57
+
58
+ return summarizeResults(suites, results);
59
+
60
+ function findSpecName(specId, suites) {
61
+ for (var i in suites) {
62
+ if (suites[i].id == specId) {
63
+ return suites[i].name;
64
+ }
65
+
66
+ var name = findSpecName(specId, suites[i].children);
67
+
68
+ if (name) { return suites[i].name + ' ' + name };
69
+ }
70
+ }
71
+
72
+ function summarizeResults(suites, results) {
73
+ var total = { total: 0, passed: 0, failed: 0 }
74
+
75
+ for (var i in suites) {
76
+ var suite = suites[i];
77
+
78
+ if (suite.type == 'spec') {
79
+ total.total++;
80
+
81
+ if (results[suite.id].result == 'passed') {
82
+ total.passed++;
83
+ } else {
84
+ total.failed++;
85
+ }
86
+ }
87
+
88
+ var subTotal = summarizeResults(suite.children, results);
89
+ total.total += subTotal.total;
90
+ total.passed += subTotal.passed;
91
+ total.failed += subTotal.failed;
92
+ }
93
+
94
+ return total;
95
+ }
96
+ }
97
+
98
+ function sumUpAndExit(summary) {
99
+ console.log(summary.total + ' specs | ' + summary.failed + ' failing');
100
+
101
+ if (summary.passed == summary.total) {
102
+ phantom.exit();
103
+ } else {
104
+ phantom.exit(1);
105
+ }
106
+ }
107
+
31
108
  var page = require('webpage').create();
32
109
 
33
110
  // Route "console.log()" calls from within the Page context to the main Phantom context (i.e. current "this")
34
111
  page.onConsoleMessage = function(msg) {
35
- console.log(msg);
112
+ console.log(msg);
36
113
  };
37
114
 
38
115
  page.open(system.args[1], function(status){
39
- if (status !== "success") {
40
- console.log("Unable to access network");
41
- phantom.exit();
42
- } else {
43
- waitFor("Jasmine specs to report finished", function(){
44
- return page.evaluate(function(){
45
- return jsApiReporter.finished;
46
- });
47
- }, function(){
48
- var summary = page.evaluate(function(){
49
- console.log('');
50
- var suites = jsApiReporter.suites();
51
- var results = jsApiReporter.results();
52
-
53
- for(var specId in results) {
54
- var result = results[specId];
55
- if (result.result != "passed") {
56
-
57
- var name = findSpecName(specId, suites);
58
-
59
- console.log(name);
60
-
61
- for (var msgId in result.messages) {
62
- console.log(' ' + result.messages[msgId]);
63
- }
64
-
65
- console.log('');
66
- }
67
- }
68
-
69
- return summarizeResults(suites, results);
70
-
71
- function findSpecName(specId, suites) {
72
- for (var i in suites) {
73
- if (suites[i].id == specId) {
74
- return suites[i].name;
75
- }
76
-
77
- var name = findSpecName(specId, suites[i].children);
78
-
79
- if (name) { return suites[i].name + ' ' + name };
80
- }
81
- }
82
-
83
- function summarizeResults(suites, results) {
84
- var total = { total: 0, passed: 0, failed: 0 }
85
-
86
- for (var i in suites) {
87
- var suite = suites[i];
88
-
89
- if (suite.type == 'spec') {
90
- total.total++;
91
-
92
- if (results[suite.id].result == 'passed') {
93
- total.passed++;
94
- } else {
95
- total.failed++;
96
- }
97
- }
98
-
99
- var subTotal = summarizeResults(suite.children, results);
100
- total.total += subTotal.total;
101
- total.passed += subTotal.passed;
102
- total.failed += subTotal.failed;
103
- }
104
-
105
- return total;
106
- }
107
-
108
- return passed;
109
- });
110
-
111
- console.log(summary.total + ' specs | ' + summary.failed + ' failing');
112
-
113
- if (summary.passed == summary.total) {
114
- phantom.exit();
115
- } else {
116
- phantom.exit(1);
117
- }
118
- });
119
- }
120
-
116
+ if (status !== "success") {
117
+ console.log("Unable to access network");
118
+ phantom.exit();
119
+ } else {
120
+ waitFor(
121
+ "Jasmine specs to report finished",
122
+ function() { return jasmineReportsFinished(page); },
123
+ function(){
124
+ var summary = page.evaluate(collectJasmineResults);
125
+ sumUpAndExit(summary);
126
+ },
127
+ 30000
128
+ );
129
+ }
121
130
  });
@@ -1,5 +1,5 @@
1
1
  module Jasmine
2
2
  module Phantom
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jasmine-phantom
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-18 00:00:00.000000000 Z
12
+ date: 2012-05-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &2153382420 !ruby/object:Gem::Requirement
16
+ requirement: &2153708660 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '3.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2153382420
24
+ version_requirements: *2153708660
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: jasmine
27
- requirement: &2153381920 !ruby/object:Gem::Requirement
27
+ requirement: &2153708160 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: 1.2.0rc2
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2153381920
35
+ version_requirements: *2153708160
36
36
  description: ! "jasmine-phantom provides a rake task, jasmine:phantom:ci,\n that
37
37
  runs your jasmine specs via the phantomjs browser just as if you had\n run
38
38
  rake jasmine and run them manually via your browser.\n\n You
@@ -65,12 +65,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
65
65
  - - ! '>='
66
66
  - !ruby/object:Gem::Version
67
67
  version: '0'
68
+ segments:
69
+ - 0
70
+ hash: 1636865008111916093
68
71
  required_rubygems_version: !ruby/object:Gem::Requirement
69
72
  none: false
70
73
  requirements:
71
74
  - - ! '>='
72
75
  - !ruby/object:Gem::Version
73
76
  version: '0'
77
+ segments:
78
+ - 0
79
+ hash: 1636865008111916093
74
80
  requirements: []
75
81
  rubyforge_project: jasmine-phantom
76
82
  rubygems_version: 1.8.6