guard-jasmine 1.8.1 → 1.8.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -68,7 +68,13 @@ Alternatively you can install [Homebrew][] on Mac OS X and install it with:
68
68
  $ brew install phantomjs
69
69
  ```
70
70
 
71
- If you are using Ubuntu 10.10, you can install it with apt:
71
+ If you are using Ubuntu 12.04 or above, phantomjs is in the official repositories and can be installed with apt:
72
+
73
+ ```bash
74
+ $ sudo apt-get install phantomjs
75
+ ```
76
+
77
+ For older versions of Ubuntu, you will need to add a repository first:
72
78
 
73
79
  ```bash
74
80
  $ sudo add-apt-repository ppa:jerome-etienne/neoip
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env ruby
2
- script = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'guard', 'jasmine', 'phantomjs', 'guard-jasmine.coffee'))
2
+ script = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'guard', 'jasmine', 'phantomjs', 'guard-jasmine.js'))
3
3
  puts `phantomjs #{ script } #{ ARGV[0] } #{ ARGV[1] }`
@@ -0,0 +1,124 @@
1
+ (function() {
2
+ var currentSpecId, errors, logs, options, page, specsReady, waitFor;
3
+
4
+ phantom.injectJs('lib/result.js');
5
+
6
+ options = {
7
+ url: phantom.args[0] || 'http://127.0.0.1:3000/jasmine',
8
+ timeout: parseInt(phantom.args[1] || 5000),
9
+ specdoc: phantom.args[2] || 'failure',
10
+ focus: /true/i.test(phantom.args[3]),
11
+ console: phantom.args[4] || 'failure',
12
+ errors: phantom.args[5] || 'failure'
13
+ };
14
+
15
+ page = require('webpage').create();
16
+
17
+ currentSpecId = -1;
18
+
19
+ logs = {};
20
+
21
+ errors = {};
22
+
23
+ page.onError = function(msg, trace) {
24
+ if (currentSpecId && currentSpecId !== -1) {
25
+ errors[currentSpecId] || (errors[currentSpecId] = []);
26
+ return errors[currentSpecId].push({
27
+ msg: msg,
28
+ trace: trace
29
+ });
30
+ }
31
+ };
32
+
33
+ page.onConsoleMessage = function(msg, line, source) {
34
+ var result;
35
+ if (/^RUNNER_END$/.test(msg)) {
36
+ result = page.evaluate(function() {
37
+ return window.reporter.runnerResult;
38
+ });
39
+ console.log(JSON.stringify(new Result(result, logs, errors, options).process()));
40
+ return page.evaluate(function() {
41
+ return window.resultReceived = true;
42
+ });
43
+ } else if (/^SPEC_START: (\d+)$/.test(msg)) {
44
+ currentSpecId = Number(RegExp.$1);
45
+ return logs[currentSpecId] = [];
46
+ } else {
47
+ if (currentSpecId !== -1) {
48
+ return logs[currentSpecId].push(msg);
49
+ }
50
+ }
51
+ };
52
+
53
+ page.onInitialized = function() {
54
+ page.injectJs('lib/console.js');
55
+ page.injectJs('lib/reporter.js');
56
+ return page.evaluate(function() {
57
+ return window.onload = function() {
58
+ window.resultReceived = false;
59
+ window.reporter = new ConsoleReporter();
60
+ return jasmine.getEnv().addReporter(window.reporter);
61
+ };
62
+ });
63
+ };
64
+
65
+ page.open(options.url, function(status) {
66
+ var done;
67
+ page.onLoadFinished = function() {};
68
+ if (status !== 'success') {
69
+ console.log(JSON.stringify({
70
+ error: "Unable to access Jasmine specs at " + options.url
71
+ }));
72
+ return phantom.exit();
73
+ } else {
74
+ done = function() {
75
+ return phantom.exit();
76
+ };
77
+ return waitFor(specsReady, done, options.timeout);
78
+ }
79
+ });
80
+
81
+ specsReady = function() {
82
+ return page.evaluate(function() {
83
+ return window.resultReceived;
84
+ });
85
+ };
86
+
87
+ waitFor = function(test, ready, timeout) {
88
+ var condition, interval, start, wait;
89
+ if (timeout == null) {
90
+ timeout = 5000;
91
+ }
92
+ start = new Date().getTime();
93
+ condition = false;
94
+ wait = function() {
95
+ var error, text;
96
+ if ((new Date().getTime() - start < timeout) && !condition) {
97
+ return condition = test();
98
+ } else {
99
+ if (!condition) {
100
+ text = page.evaluate(function() {
101
+ var _ref;
102
+ return (_ref = document.getElementsByTagName('body')[0]) != null ? _ref.innerText : void 0;
103
+ });
104
+ if (text) {
105
+ error = "Timeout waiting for the Jasmine test results!\n\n" + text;
106
+ console.log(JSON.stringify({
107
+ error: error
108
+ }));
109
+ } else {
110
+ console.log(JSON.stringify({
111
+ error: 'Timeout waiting for the Jasmine test results!'
112
+ }));
113
+ }
114
+ return phantom.exit(1);
115
+ } else {
116
+ ready();
117
+ return clearInterval(interval);
118
+ }
119
+ }
120
+ };
121
+ return interval = setInterval(wait, 250);
122
+ };
123
+
124
+ }).call(this);
@@ -30,7 +30,7 @@
30
30
  if (!spec.results().skipped) {
31
31
  specResult = {
32
32
  id: spec.id,
33
- description: spec.description,
33
+ description: '' + spec.description,
34
34
  passed: spec.results().failedCount === 0
35
35
  };
36
36
  if (spec.results().failedCount !== 0) {
@@ -56,7 +56,7 @@
56
56
  suiteResult = {
57
57
  id: suite.id,
58
58
  parent: (_ref = suite.parentSuite) != null ? _ref.id : void 0,
59
- description: suite.description,
59
+ description: '' + suite.description,
60
60
  passed: suite.results().failedCount === 0,
61
61
  specs: this.currentSpecs[suite.id] || [],
62
62
  suites: []
@@ -118,7 +118,7 @@ module Guard
118
118
  # @return [String] the path to the PhantomJS script
119
119
  #
120
120
  def phantomjs_script
121
- File.expand_path(File.join(File.dirname(__FILE__), 'phantomjs', 'guard-jasmine.coffee'))
121
+ File.expand_path(File.join(File.dirname(__FILE__), 'phantomjs', 'guard-jasmine.js'))
122
122
  end
123
123
 
124
124
  # The suite name must be extracted from the spec that
@@ -1,6 +1,6 @@
1
1
  module Guard
2
2
  module JasmineVersion
3
3
  # Guard::Jasmine version that is used for the Gem specification
4
- VERSION = '1.8.1'
4
+ VERSION = '1.8.2'
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-jasmine
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.1
4
+ version: 1.8.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-30 00:00:00.000000000 Z
12
+ date: 2012-09-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: guard
@@ -106,6 +106,7 @@ files:
106
106
  - lib/guard/jasmine/formatter.rb
107
107
  - lib/guard/jasmine/inspector.rb
108
108
  - lib/guard/jasmine/phantomjs/guard-jasmine.coffee
109
+ - lib/guard/jasmine/phantomjs/guard-jasmine.js
109
110
  - lib/guard/jasmine/phantomjs/lib/console.js
110
111
  - lib/guard/jasmine/phantomjs/lib/reporter.js
111
112
  - lib/guard/jasmine/phantomjs/lib/result.js
@@ -138,7 +139,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
138
139
  version: '0'
139
140
  segments:
140
141
  - 0
141
- hash: 1592890697872928837
142
+ hash: -2197142457549692615
142
143
  required_rubygems_version: !ruby/object:Gem::Requirement
143
144
  none: false
144
145
  requirements: