screw-unit 0.3.3 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. data/CHANGES +10 -0
  2. data/Rakefile +27 -25
  3. data/VERSION.yml +4 -0
  4. data/bin/screw_unit_server +14 -4
  5. data/core/EXAMPLE.html +1 -1
  6. data/core/example/spec/suite.html +1 -1
  7. data/core/lib/jquery-1.3.2.js +4376 -0
  8. data/core/lib/jquery.fn.js +2 -1
  9. data/core/lib/screw.behaviors.js +8 -7
  10. data/core/lib/screw.builder.js +34 -19
  11. data/core/lib/screw.css +1 -1
  12. data/core/lib/screw.events.js +5 -5
  13. data/core/lib/screw.matchers.js +59 -2
  14. data/core/spec/suite.html +2 -1
  15. data/core/spec/with_screw_context_spec.js +9 -0
  16. data/lib/screw_unit.rb +13 -16
  17. data/lib/screw_unit/representations.rb +2 -0
  18. data/lib/screw_unit/{resources/spec.rb → representations/spec.html.rb} +55 -39
  19. data/spec/functional/functional_spec.rb +1 -1
  20. data/spec/functional/functional_spec_helper.rb +21 -33
  21. data/spec/functional/functional_spec_server_starter.rb +68 -0
  22. data/spec/unit/js_test_core/specs/spec_file_spec.rb +52 -18
  23. data/spec/unit/unit_spec_helper.rb +24 -91
  24. data/vendor/js-test-core/CHANGES +8 -0
  25. data/vendor/js-test-core/Rakefile +1 -0
  26. data/vendor/js-test-core/lib/js_test_core.rb +22 -14
  27. data/vendor/js-test-core/lib/js_test_core/app.rb +12 -0
  28. data/vendor/js-test-core/lib/js_test_core/client.rb +21 -9
  29. data/vendor/js-test-core/lib/js_test_core/configuration.rb +35 -0
  30. data/vendor/js-test-core/lib/js_test_core/extensions.rb +1 -1
  31. data/vendor/js-test-core/lib/js_test_core/extensions/selenium/client/driver.rb +7 -0
  32. data/vendor/js-test-core/lib/js_test_core/models.rb +8 -0
  33. data/vendor/js-test-core/lib/js_test_core/models/selenium_session.rb +80 -0
  34. data/vendor/js-test-core/lib/js_test_core/representations.rb +11 -0
  35. data/vendor/js-test-core/lib/js_test_core/representations/dir.html.rb +24 -0
  36. data/vendor/js-test-core/lib/js_test_core/representations/not_found.html.rb +15 -0
  37. data/vendor/js-test-core/lib/js_test_core/representations/page.html.rb +41 -0
  38. data/vendor/js-test-core/lib/js_test_core/representations/spec.html.rb +24 -0
  39. data/vendor/js-test-core/lib/js_test_core/resources.rb +13 -7
  40. data/vendor/js-test-core/lib/js_test_core/resources/core_file.rb +19 -0
  41. data/vendor/js-test-core/lib/js_test_core/resources/file.rb +42 -20
  42. data/vendor/js-test-core/lib/js_test_core/resources/implementations_deprecation.rb +12 -0
  43. data/vendor/js-test-core/lib/js_test_core/resources/not_found.rb +35 -0
  44. data/vendor/js-test-core/lib/js_test_core/resources/resource.rb +16 -0
  45. data/vendor/js-test-core/lib/js_test_core/resources/selenium_session.rb +104 -0
  46. data/vendor/js-test-core/lib/js_test_core/resources/spec_file.rb +63 -0
  47. data/vendor/js-test-core/lib/js_test_core/resources/web_root.rb +5 -60
  48. data/vendor/js-test-core/{vendor/thin-rest/README → spec/example_core/subdir/SubDirFile.js} +0 -0
  49. data/vendor/js-test-core/spec/example_specs/custom_dir_and_suite/passing_spec.js +6 -0
  50. data/vendor/js-test-core/spec/example_specs/custom_suite.html +8 -0
  51. data/vendor/js-test-core/spec/example_specs/foo/failing_spec.js +1 -1
  52. data/vendor/js-test-core/spec/example_specs/foo/passing_spec.js +1 -1
  53. data/vendor/js-test-core/spec/spec_helpers/be_http.rb +32 -0
  54. data/vendor/js-test-core/spec/spec_helpers/example_group.rb +36 -0
  55. data/vendor/js-test-core/spec/spec_helpers/fake_selenium_driver.rb +27 -0
  56. data/vendor/js-test-core/spec/spec_helpers/show_test_exceptions.rb +22 -0
  57. data/vendor/js-test-core/spec/unit/js_test_core/client_spec.rb +35 -10
  58. data/vendor/js-test-core/spec/unit/js_test_core/configuration_spec.rb +44 -0
  59. data/vendor/js-test-core/spec/unit/js_test_core/models/selenium_session_spec.rb +85 -0
  60. data/vendor/js-test-core/spec/unit/js_test_core/resources/core_file_spec.rb +60 -0
  61. data/vendor/js-test-core/spec/unit/js_test_core/resources/file_spec.rb +54 -63
  62. data/vendor/js-test-core/spec/unit/js_test_core/resources/implementations_deprecation_spec.rb +18 -0
  63. data/vendor/js-test-core/spec/unit/js_test_core/resources/not_found_spec.rb +51 -0
  64. data/vendor/js-test-core/spec/unit/js_test_core/resources/selenium_session_spec.rb +362 -0
  65. data/vendor/js-test-core/spec/unit/js_test_core/resources/spec_file_spec.rb +120 -0
  66. data/vendor/js-test-core/spec/unit/js_test_core/resources/web_root_spec.rb +15 -19
  67. data/vendor/js-test-core/spec/unit/unit_spec_helper.rb +16 -149
  68. data/vendor/js-test-core/vendor/lucky-luciano/README.markdown +7 -0
  69. data/vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano.rb +4 -0
  70. data/vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano/resource.rb +135 -0
  71. data/vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano/rspec.rb +4 -0
  72. data/vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano/rspec/be_http.rb +32 -0
  73. data/vendor/js-test-core/vendor/lucky-luciano/spec/lucky_luciano/resource_spec.rb +231 -0
  74. data/vendor/js-test-core/vendor/lucky-luciano/spec/spec_helper.rb +48 -0
  75. data/vendor/js-test-core/vendor/{thin-rest → lucky-luciano}/spec/spec_suite.rb +1 -2
  76. metadata +134 -145
  77. data/core/lib/jquery-1.2.6.js +0 -3549
  78. data/lib/screw_unit/resources.rb +0 -2
  79. data/spec/unit/js_test_core/specs/spec_dir_spec.rb +0 -38
  80. data/vendor/js-test-core/lib/js_test_core/rack.rb +0 -2
  81. data/vendor/js-test-core/lib/js_test_core/rack/commonlogger.rb +0 -5
  82. data/vendor/js-test-core/lib/js_test_core/rails_server.rb +0 -22
  83. data/vendor/js-test-core/lib/js_test_core/resources/dir.rb +0 -67
  84. data/vendor/js-test-core/lib/js_test_core/resources/file_not_found.rb +0 -11
  85. data/vendor/js-test-core/lib/js_test_core/resources/runner.rb +0 -107
  86. data/vendor/js-test-core/lib/js_test_core/resources/session.rb +0 -44
  87. data/vendor/js-test-core/lib/js_test_core/resources/session_finish.rb +0 -17
  88. data/vendor/js-test-core/lib/js_test_core/resources/specs/spec_dir.rb +0 -46
  89. data/vendor/js-test-core/lib/js_test_core/resources/specs/spec_file.rb +0 -17
  90. data/vendor/js-test-core/lib/js_test_core/selenium.rb +0 -2
  91. data/vendor/js-test-core/lib/js_test_core/selenium/selenium_driver.rb +0 -5
  92. data/vendor/js-test-core/lib/js_test_core/server.rb +0 -50
  93. data/vendor/js-test-core/lib/js_test_core/thin.rb +0 -3
  94. data/vendor/js-test-core/lib/js_test_core/thin/backends/js_test_core_server.rb +0 -9
  95. data/vendor/js-test-core/lib/js_test_core/thin/js_test_core_connection.rb +0 -8
  96. data/vendor/js-test-core/spec/unit/js_test_core/rails_server_spec.rb +0 -45
  97. data/vendor/js-test-core/spec/unit/js_test_core/resources/dir_spec.rb +0 -52
  98. data/vendor/js-test-core/spec/unit/js_test_core/resources/file_not_found_spec.rb +0 -16
  99. data/vendor/js-test-core/spec/unit/js_test_core/resources/runners/runner_spec.rb +0 -303
  100. data/vendor/js-test-core/spec/unit/js_test_core/resources/session_finish_spec.rb +0 -79
  101. data/vendor/js-test-core/spec/unit/js_test_core/resources/session_spec.rb +0 -82
  102. data/vendor/js-test-core/spec/unit/js_test_core/resources/specs/spec_dir_spec.rb +0 -105
  103. data/vendor/js-test-core/spec/unit/js_test_core/resources/specs/spec_file_spec.rb +0 -42
  104. data/vendor/js-test-core/spec/unit/js_test_core/server_spec.rb +0 -117
  105. data/vendor/js-test-core/spec/unit/thin/js_test_core_connection_spec.rb +0 -6
  106. data/vendor/js-test-core/vendor/thin-rest/CHANGES +0 -2
  107. data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest.rb +0 -9
  108. data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/connection.rb +0 -116
  109. data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/extensions.rb +0 -3
  110. data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/extensions/object.rb +0 -21
  111. data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/resource.rb +0 -108
  112. data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/resource_invalid.rb +0 -4
  113. data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/routing_error.rb +0 -5
  114. data/vendor/js-test-core/vendor/thin-rest/spec/thin_rest/connection_spec.rb +0 -207
  115. data/vendor/js-test-core/vendor/thin-rest/spec/thin_rest/resource_spec.rb +0 -127
  116. data/vendor/js-test-core/vendor/thin-rest/spec/thin_rest_spec_helper.rb +0 -124
@@ -10,7 +10,7 @@
10
10
  });
11
11
  return self;
12
12
  }
13
- }
13
+ };
14
14
  function define(self, name, fn) {
15
15
  self.data(namespacedName(name), fn);
16
16
  };
@@ -21,6 +21,7 @@
21
21
  if (fn) result = fn.apply(item, args)
22
22
  else throw(name + " is not defined");
23
23
  });
24
+
24
25
  return result;
25
26
  };
26
27
  function namespacedName(name) {
@@ -36,7 +36,7 @@
36
36
  });
37
37
 
38
38
  $('body > .describe').fn({
39
- selector: function() { return 'body > .describe' }
39
+ selector: function() { return 'body > .describe'; }
40
40
  });
41
41
 
42
42
  $('.it').fn({
@@ -63,7 +63,7 @@
63
63
  $(Screw)
64
64
  .queue(function() {
65
65
  self.fn('run');
66
- setTimeout(function() { $(Screw).dequeue() }, 0);
66
+ setTimeout(function() { $(Screw).dequeue(); }, 0);
67
67
  });
68
68
  },
69
69
 
@@ -73,12 +73,13 @@
73
73
  }
74
74
  });
75
75
 
76
- $('.before').fn({
77
- run: function() { $(this).data('screwunit.run')() }
76
+ $('body .before').fn({
77
+ run: function() { $(this).data('screwunit.run')(); }
78
78
  });
79
79
 
80
- $('.after').fn({
81
- run: function() { $(this).data('screwunit.run')() }
80
+ $('body .after').fn({
81
+ run: function() {
82
+ $(this).data('screwunit.run')(); }
82
83
  });
83
84
 
84
85
  $(Screw).trigger('before');
@@ -88,5 +89,5 @@
88
89
  .eq(0).trigger('scroll').end()
89
90
  .fn('enqueue');
90
91
  $(Screw).queue(function() { $(Screw).trigger('after') });
91
- })
92
+ });
92
93
  })(jQuery);
@@ -1,14 +1,28 @@
1
1
  var Screw = (function($) {
2
2
  var screw = {
3
3
  Unit: function(fn) {
4
- var contents = fn.toString().match(/^[^\{]*{((.*\n*)*)}/m)[1];
5
- var fn = new Function("matchers", "specifications",
4
+ var wrappedFn;
5
+ if(fn.length == 0) {
6
+ var contents = fn.toString().match(/^[^\{]*{((.*\n*)*)}/m)[1];
7
+ wrappedFn = new Function("matchers", "specifications",
6
8
  "with (specifications) { with (matchers) { " + contents + " } }"
7
- );
9
+ );
10
+ } else {
11
+ wrappedFn = function(matchers, specifications) {
12
+ var screwContext = {};
13
+ for(var method in matchers) {
14
+ screwContext[method] = matchers[method];
15
+ }
16
+ for(var method in specifications) {
17
+ screwContext[method] = specifications[method];
18
+ }
19
+ fn(screwContext);
20
+ }
21
+ }
8
22
 
9
23
  $(Screw).queue(function() {
10
24
  Screw.Specifications.context.push($('body > .describe'));
11
- fn.call(this, Screw.Matchers, Screw.Specifications);
25
+ wrappedFn.call(this, Screw.Matchers, Screw.Specifications);
12
26
  Screw.Specifications.context.pop();
13
27
  $(this).dequeue();
14
28
  });
@@ -18,12 +32,12 @@ var Screw = (function($) {
18
32
  context: [],
19
33
 
20
34
  describe: function(name, fn) {
21
- var describe = $('<li class="describe"></li>')
22
- .append($('<h1></h1>').text(name))
23
- .append('<ol class="befores"></ol>')
24
- .append('<ul class="its"></ul>')
25
- .append('<ul class="describes"></ul>')
26
- .append('<ol class="afters"></ol>');
35
+ var describe = $('<li class="describe">')
36
+ .append($('<h1 />').text(name))
37
+ .append('<ol class="befores">')
38
+ .append('<ul class="its">')
39
+ .append('<ul class="describes">')
40
+ .append('<ol class="afters">');
27
41
 
28
42
  this.context.push(describe);
29
43
  fn.call();
@@ -35,8 +49,8 @@ var Screw = (function($) {
35
49
  },
36
50
 
37
51
  it: function(name, fn) {
38
- var it = $('<li class="it"></li>')
39
- .append($('<h2></h2>').text(name))
52
+ var it = $('<li class="it">')
53
+ .append($('<h2 />').text(name))
40
54
  .data('screwunit.run', fn);
41
55
 
42
56
  this.context[this.context.length-1]
@@ -65,16 +79,17 @@ var Screw = (function($) {
65
79
  };
66
80
 
67
81
  $(screw).queue(function() { $(screw).trigger('loading') });
68
- $(function() {
69
- $('<div class="describe"></div>')
70
- .append('<h3 class="status"></h3>')
71
- .append('<ol class="befores"></ol>')
72
- .append('<ul class="describes"></ul>')
73
- .append('<ol class="afters"></ol>')
82
+ $(window).load(function(){
83
+ $('<div class="describe">')
84
+ .append('<h3 class="status" />')
85
+ .append('<ol class="befores">')
86
+ .append('<ul class="describes">')
87
+ .append('<ol class="afters">')
74
88
  .appendTo('body');
75
-
89
+
76
90
  $(screw).dequeue();
77
91
  $(screw).trigger('loaded');
78
92
  });
93
+
79
94
  return screw;
80
95
  })(jQuery);
@@ -42,7 +42,7 @@ html {
42
42
  .describes .describe {
43
43
  margin-left: 0.6em;
44
44
  padding-left: 0.6em;
45
- border: 1px dashed #999;
45
+ border: 1px dashed #6E6E6E;
46
46
  }
47
47
 
48
48
  .describes .describe .its {}
@@ -26,20 +26,20 @@
26
26
  .bind('failed', function(e, reason) {
27
27
  $(this)
28
28
  .addClass('failed')
29
- .append($('<p class="error"></p>').text(reason.toString()));
29
+ .append($('<p class="error">').text(reason.toString()));
30
30
 
31
31
  var file = reason.fileName || reason.sourceURL;
32
32
  var line = reason.lineNumber || reason.line;
33
33
  if (file || line) {
34
34
  $(this).append($('<p class="error"></p>').text('line ' + line + ', ' + file));
35
35
  }
36
- })
36
+ });
37
37
  })
38
38
  .bind('before', function() {
39
39
  Screw.suite_start_time = new Date();
40
40
  $('.status').text('Running...');
41
41
  })
42
42
  .bind('after', function() {
43
- $('.status').fn('display')
44
- })
45
- })(jQuery);
43
+ $('body .status').fn('display');
44
+ });
45
+ })(jQuery);
@@ -1,6 +1,21 @@
1
1
  Screw.Matchers = (function($) {
2
2
  return matchers = {
3
3
  expect: function(actual) {
4
+ var funcname = function(f) {
5
+ var s = f.toString().match(/function (\w*)/)[1];
6
+ if ((s == null) || (s.length == 0)) return "anonymous";
7
+ return s;
8
+ };
9
+
10
+ var stacktrace = function() {
11
+ var s = "";
12
+ for(var a = arguments.caller; a != null; a = a.caller) {
13
+ s += funcname(a.callee) + "\n";
14
+ if (a.caller == a) break;
15
+ }
16
+ return s;
17
+ };
18
+
4
19
  return {
5
20
  to: function(matcher, expected, not) {
6
21
  var matched = matcher.match(expected, actual);
@@ -38,7 +53,7 @@ Screw.Matchers = (function($) {
38
53
  return 'expected ' + $.print(actual) + (not ? ' to not equal ' : ' to equal ') + $.print(expected);
39
54
  }
40
55
  },
41
-
56
+
42
57
  be_gt: {
43
58
  match: function(expected, actual) {
44
59
  return actual > expected;
@@ -104,6 +119,18 @@ Screw.Matchers = (function($) {
104
119
  }
105
120
  },
106
121
 
122
+ be_blank: {
123
+ match: function(expected, actual) {
124
+ if (actual == undefined) return true;
125
+ if (typeof(actual) == "string") actual = actual.replace(/^\s*(.*?)\s*$/, "$1");
126
+ return Screw.Matchers.be_empty.match(expected, actual);
127
+ },
128
+
129
+ failure_message: function(expected, actual, not) {
130
+ return 'expected ' + $.print(actual) + (not ? ' to not be blank' : ' to be blank');
131
+ }
132
+ },
133
+
107
134
  have_length: {
108
135
  match: function(expected, actual) {
109
136
  if (actual.length == undefined) throw(actual.toString() + " does not respond to length");
@@ -156,6 +183,36 @@ Screw.Matchers = (function($) {
156
183
  }
157
184
  },
158
185
 
186
+ match_html: {
187
+ munge: function(mungee) {
188
+ if (mungee instanceof jQuery) {
189
+ mungee = mungee.html();
190
+ } else if (typeof(mungee) == "string") {
191
+ var span = document.createElement("span");
192
+ span.innerHTML = mungee;
193
+ mungee = span.innerHTML;
194
+ }
195
+
196
+ var regEx = /\sjQuery\d+=['"]\d+['"]/g;
197
+ mungee = mungee.replace(regEx, "");
198
+
199
+ return mungee;
200
+ },
201
+
202
+ match: function(expected, actual) {
203
+ var trimmedExpected = this.munge(expected);
204
+ var trimmedActual = this.munge(actual);
205
+ return trimmedActual.indexOf(trimmedExpected) > -1;
206
+ },
207
+
208
+ failure_message: function(expected, actual, not) {
209
+ var trimmedExpected = this.munge(expected);
210
+ var trimmedActual = this.munge(actual);
211
+ return 'expected ' + $.print(trimmedActual, { max_string: 300 }) +
212
+ (not ? ' to not contain ' : ' to contain ') + $.print(trimmedExpected, { max_string: 300 });
213
+ }
214
+ },
215
+
159
216
  match_selector: {
160
217
  match: function(expected, actual) {
161
218
  if (!(actual instanceof jQuery)) {
@@ -184,4 +241,4 @@ Screw.Matchers = (function($) {
184
241
  }
185
242
  }
186
243
  }
187
- })(jQuery);
244
+ })(jQuery);
@@ -1,6 +1,6 @@
1
1
  <html>
2
2
  <head>
3
- <script src="../lib/jquery-1.2.6.js"></script>
3
+ <script src="../lib/jquery-1.3.2.js"></script>
4
4
  <script src="../lib/jquery.fn.js"></script>
5
5
  <script src="../lib/jquery.print.js"></script>
6
6
  <script src="../lib/screw.builder.js"></script>
@@ -11,6 +11,7 @@
11
11
  <script src="behaviors_spec.js"></script>
12
12
  <script src="matchers_spec.js"></script>
13
13
  <script src="print_spec.js"></script>
14
+ <script src="with_screw_context_spec.js"></script>
14
15
 
15
16
  <link rel="stylesheet" href="../lib/screw.css">
16
17
  </head>
@@ -0,0 +1,9 @@
1
+ Screw.Unit(function(screw) { with(screw) {
2
+ describe("Screw.Unit", function() {
3
+ describe("when the passed-in function has an arity of 1", function() {
4
+ it("passes the Screw.Unit context into the function", function() {
5
+ expect(true).to(equal, true);
6
+ });
7
+ });
8
+ });
9
+ }});
@@ -3,24 +3,21 @@ require "rubygems"
3
3
  dir = File.dirname(__FILE__)
4
4
  $:.unshift(File.expand_path("#{dir}/../vendor/js-test-core/lib"))
5
5
  require "js_test_core"
6
- JsTestCore::Resources::WebRoot.dispatch_specs
7
6
 
8
- require "#{dir}/screw_unit/resources"
7
+ require "#{dir}/screw_unit/representations"
9
8
 
10
- module ScrewUnit
11
- DEFAULT_HOST = JsTestCore::DEFAULT_HOST
12
- DEFAULT_PORT = JsTestCore::DEFAULT_PORT
13
-
14
- Server = JsTestCore::Server
15
- RailsServer = JsTestCore::RailsServer
16
- Client = JsTestCore::Client
17
- end
18
9
  JsTestCore.core_path = File.expand_path("#{dir}/../core/lib")
10
+ JsTestCore::Resources::SpecFile.spec_representation_class = ScrewUnit::Representations::Spec
11
+ module ScrewUnit
12
+ include JsTestCore
19
13
 
20
- class JsTestCore::Resources::Specs::SpecFile
21
- include ScrewUnit::Resources::Spec
22
- end
23
-
24
- class JsTestCore::Resources::Specs::SpecDir
25
- include ScrewUnit::Resources::Spec
14
+ class << self
15
+ def method_missing(method_name, *args, &block)
16
+ if JsTestCore::Configuration.instance.respond_to?(method_name)
17
+ JsTestCore::Configuration.instance.send(method_name, *args, &block)
18
+ else
19
+ super
20
+ end
21
+ end
22
+ end
26
23
  end
@@ -0,0 +1,2 @@
1
+ dir = File.dirname(__FILE__)
2
+ require "#{dir}/representations/spec.html"
@@ -1,22 +1,13 @@
1
1
  module ScrewUnit
2
- module Resources
3
- module Spec
4
- def get
5
- # TODO: BT/JN - Remove the Screw.Assets when we implement rendering of script and link tags from yml files.
6
- html = <<-HTML
7
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
8
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
9
- <head>
10
- <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
11
- <title>ScrewUnit results</title>
12
- <script src="/core/jquery-1.2.6.js"></script>
13
- <script src="/core/jquery.fn.js"></script>
14
- <script src="/core/jquery.print.js"></script>
15
- <script src="/core/screw.builder.js"></script>
16
- <script src="/core/screw.matchers.js"></script>
17
- <script src="/core/screw.events.js"></script>
18
- <script src="/core/screw.behaviors.js"></script>
19
- <script type="text/javascript">
2
+ module Representations
3
+ class Spec < JsTestCore::Representations::Spec
4
+ def title_text
5
+ "Screw Unit suite"
6
+ end
7
+
8
+ def head_content
9
+ core_js_files
10
+ script(raw(<<-JS), :type => "text/javascript")
20
11
  (function($) {
21
12
  Screw.Assets = {};
22
13
  Screw.Assets.use_cache_buster = false; // TODO: NS/CTI - make this configurable from the UI.
@@ -68,34 +59,59 @@ module ScrewUnit
68
59
  (function($) {
69
60
  var ajax = $.ajax;
70
61
  $(Screw).bind('after', function() {
71
- var error_text = $(".error").map(function(i, element) {
72
- return element.innerHTML;
62
+ var error_text = $(".error").map(function(i, error_element) {
63
+ var element = $(error_element);
64
+
65
+ var parent_descriptions = element.parents("li.describe");
66
+ var parent_description_text = [];
67
+
68
+ for(var i=parent_descriptions.length-1; i >= 0; i--) {
69
+ parent_description_text.push($(parent_descriptions[i]).find("h1").text());
70
+ }
71
+
72
+ var it_text = element.parents("li.it").find("h2").text();
73
+
74
+ return parent_description_text.join(" ") + " " + it_text + ": " + element.text();
73
75
  }).get().join("\\n");
74
-
76
+
75
77
  ajax({
76
78
  type: "POST",
77
- url: '/session/finish',
79
+ url: '#{ScrewUnit::Resources::SeleniumSession.path("/finish")}',
78
80
  data: {"text": error_text}
79
81
  });
80
82
  });
81
83
  })(jQuery);
82
- </script>
83
- <link rel="stylesheet" href="/core/screw.css" />
84
- HTML
85
- spec_files.each do |file|
86
- html << %{<script type="text/javascript" src="#{file.relative_path}"></script>\n}
87
- end
88
-
89
- html << <<-HTML
90
- </head>
91
- <body>
92
- <div id="screw_unit_content"></div>
93
- </body>
94
- </html>
95
- HTML
96
- connection.send_head
97
- connection.send_body(html.gsub(/^ /, ""))
84
+ JS
85
+ project_js_files
86
+ link :rel => "stylesheet", :href => "/core/screw.css"
87
+ project_css_files
88
+
89
+ spec_script_elements
90
+ end
91
+
92
+ def core_js_files
93
+ script :src => jquery_js_file
94
+ script :src => "/core/jquery.fn.js"
95
+ script :src => "/core/jquery.print.js"
96
+ script :src => "/core/screw.builder.js"
97
+ script :src => "/core/screw.matchers.js"
98
+ script :src => "/core/screw.events.js"
99
+ script :src => "/core/screw.behaviors.js"
100
+ end
101
+
102
+ def project_js_files
103
+ end
104
+
105
+ def project_css_files
106
+ end
107
+
108
+ def jquery_js_file
109
+ "/core/jquery-1.3.2.js"
110
+ end
111
+
112
+ def body_content
113
+ div :id => "screw_unit_content"
98
114
  end
99
115
  end
100
116
  end
101
- end
117
+ end