Fingertips-headless-squirrel 0.2.0

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.
Files changed (124) hide show
  1. data/README.rdoc +53 -0
  2. data/Rakefile +49 -0
  3. data/VERSION.yml +4 -0
  4. data/bin/jstest +10 -0
  5. data/lib/headless_squirrel/runner.rb +70 -0
  6. data/lib/headless_squirrel/test.rb +17 -0
  7. data/lib/headless_squirrel/test_case.rb +121 -0
  8. data/lib/headless_squirrel.rb +2 -0
  9. data/test/fixtures/a_unit_test.html +27 -0
  10. data/test/fixtures/a_unit_test.js +22 -0
  11. data/test/regression/prototype/unit/ajax_test.html +29 -0
  12. data/test/regression/prototype/unit/array_test.html +28 -0
  13. data/test/regression/prototype/unit/assets/prototype.js +4900 -0
  14. data/test/regression/prototype/unit/assets/unittest.css +50 -0
  15. data/test/regression/prototype/unit/assets/unittest.js +615 -0
  16. data/test/regression/prototype/unit/assets/unittest_transport.js +1 -0
  17. data/test/regression/prototype/unit/base_test.html +27 -0
  18. data/test/regression/prototype/unit/class_test.html +27 -0
  19. data/test/regression/prototype/unit/date_test.html +27 -0
  20. data/test/regression/prototype/unit/dom_test.html +304 -0
  21. data/test/regression/prototype/unit/element_mixins_test.html +30 -0
  22. data/test/regression/prototype/unit/enumerable_test.html +35 -0
  23. data/test/regression/prototype/unit/event_test.html +31 -0
  24. data/test/regression/prototype/unit/fixtures/ajax.html +2 -0
  25. data/test/regression/prototype/unit/fixtures/ajax.js +42 -0
  26. data/test/regression/prototype/unit/fixtures/array.html +1 -0
  27. data/test/regression/prototype/unit/fixtures/class.js +83 -0
  28. data/test/regression/prototype/unit/fixtures/content.html +1 -0
  29. data/test/regression/prototype/unit/fixtures/data.json +1 -0
  30. data/test/regression/prototype/unit/fixtures/dom.css +84 -0
  31. data/test/regression/prototype/unit/fixtures/dom.html +278 -0
  32. data/test/regression/prototype/unit/fixtures/dom.js +17 -0
  33. data/test/regression/prototype/unit/fixtures/element_mixins.html +4 -0
  34. data/test/regression/prototype/unit/fixtures/element_mixins.js +2 -0
  35. data/test/regression/prototype/unit/fixtures/empty.html +0 -0
  36. data/test/regression/prototype/unit/fixtures/empty.js +1 -0
  37. data/test/regression/prototype/unit/fixtures/enumerable.html +8 -0
  38. data/test/regression/prototype/unit/fixtures/enumerable.js +23 -0
  39. data/test/regression/prototype/unit/fixtures/event.html +4 -0
  40. data/test/regression/prototype/unit/fixtures/form.html +108 -0
  41. data/test/regression/prototype/unit/fixtures/function.js +13 -0
  42. data/test/regression/prototype/unit/fixtures/hash.js +25 -0
  43. data/test/regression/prototype/unit/fixtures/hello.js +1 -0
  44. data/test/regression/prototype/unit/fixtures/logo.gif +0 -0
  45. data/test/regression/prototype/unit/fixtures/object.html +6 -0
  46. data/test/regression/prototype/unit/fixtures/object.js +7 -0
  47. data/test/regression/prototype/unit/fixtures/position.html +9 -0
  48. data/test/regression/prototype/unit/fixtures/selector.html +71 -0
  49. data/test/regression/prototype/unit/fixtures/string.js +8 -0
  50. data/test/regression/prototype/unit/fixtures/unittest.html +18 -0
  51. data/test/regression/prototype/unit/form_test.html +135 -0
  52. data/test/regression/prototype/unit/function_test.html +27 -0
  53. data/test/regression/prototype/unit/hash_test.html +27 -0
  54. data/test/regression/prototype/unit/number_test.html +27 -0
  55. data/test/regression/prototype/unit/object_test.html +32 -0
  56. data/test/regression/prototype/unit/periodical_executer_test.html +27 -0
  57. data/test/regression/prototype/unit/position_test.html +36 -0
  58. data/test/regression/prototype/unit/prototype_test.html +27 -0
  59. data/test/regression/prototype/unit/range_test.html +27 -0
  60. data/test/regression/prototype/unit/regexp_test.html +27 -0
  61. data/test/regression/prototype/unit/selector_test.html +98 -0
  62. data/test/regression/prototype/unit/string_test.html +27 -0
  63. data/test/regression/prototype/unit/tests/ajax_test.js +379 -0
  64. data/test/regression/prototype/unit/tests/array_test.js +186 -0
  65. data/test/regression/prototype/unit/tests/base_test.js +43 -0
  66. data/test/regression/prototype/unit/tests/class_test.js +136 -0
  67. data/test/regression/prototype/unit/tests/date_test.js +5 -0
  68. data/test/regression/prototype/unit/tests/dom_test.js +1493 -0
  69. data/test/regression/prototype/unit/tests/element_mixins_test.js +32 -0
  70. data/test/regression/prototype/unit/tests/enumerable_test.js +271 -0
  71. data/test/regression/prototype/unit/tests/event_test.js +235 -0
  72. data/test/regression/prototype/unit/tests/form_test.js +382 -0
  73. data/test/regression/prototype/unit/tests/function_test.js +133 -0
  74. data/test/regression/prototype/unit/tests/hash_test.js +178 -0
  75. data/test/regression/prototype/unit/tests/number_test.js +44 -0
  76. data/test/regression/prototype/unit/tests/object_test.js +180 -0
  77. data/test/regression/prototype/unit/tests/periodical_executer_test.js +15 -0
  78. data/test/regression/prototype/unit/tests/position_test.js +44 -0
  79. data/test/regression/prototype/unit/tests/prototype_test.js +43 -0
  80. data/test/regression/prototype/unit/tests/range_test.js +58 -0
  81. data/test/regression/prototype/unit/tests/regexp_test.js +42 -0
  82. data/test/regression/prototype/unit/tests/selector_test.js +408 -0
  83. data/test/regression/prototype/unit/tests/string_test.js +548 -0
  84. data/test/regression/prototype/unit/tests/unittest_test.js +148 -0
  85. data/test/regression/prototype/unit/unittest_test.html +45 -0
  86. data/test/regression/prototype/upstream +1 -0
  87. data/test/regression/scriptaculous/src/builder.js +134 -0
  88. data/test/regression/scriptaculous/src/controls.js +963 -0
  89. data/test/regression/scriptaculous/src/dragdrop.js +973 -0
  90. data/test/regression/scriptaculous/src/effects.js +1122 -0
  91. data/test/regression/scriptaculous/src/javascripttest.rb +203 -0
  92. data/test/regression/scriptaculous/src/scriptaculous.js +66 -0
  93. data/test/regression/scriptaculous/src/slider.js +273 -0
  94. data/test/regression/scriptaculous/src/sound.js +57 -0
  95. data/test/regression/scriptaculous/src/unittest.js +566 -0
  96. data/test/regression/scriptaculous/unit/_ajax_inplaceeditor_ipce_alt_text.html +1 -0
  97. data/test/regression/scriptaculous/unit/_ajax_inplaceeditor_ipce_collection.js +1 -0
  98. data/test/regression/scriptaculous/unit/_ajax_inplaceeditor_result.html +1 -0
  99. data/test/regression/scriptaculous/unit/_ajax_inplaceeditor_result2.html +1 -0
  100. data/test/regression/scriptaculous/unit/_ajax_inplaceeditor_tagged.html +1 -0
  101. data/test/regression/scriptaculous/unit/_ajax_inplaceeditor_text.html +1 -0
  102. data/test/regression/scriptaculous/unit/_ajax_updater_result.html +20 -0
  103. data/test/regression/scriptaculous/unit/_autocomplete_result.html +11 -0
  104. data/test/regression/scriptaculous/unit/_autocomplete_result_nobr.html +1 -0
  105. data/test/regression/scriptaculous/unit/ajax_autocompleter_test.html +243 -0
  106. data/test/regression/scriptaculous/unit/ajax_inplaceeditor_test.html +895 -0
  107. data/test/regression/scriptaculous/unit/builder_test.html +262 -0
  108. data/test/regression/scriptaculous/unit/dragdrop_test.html +131 -0
  109. data/test/regression/scriptaculous/unit/effects_test.html +547 -0
  110. data/test/regression/scriptaculous/unit/element_test.html +116 -0
  111. data/test/regression/scriptaculous/unit/icon.png +0 -0
  112. data/test/regression/scriptaculous/unit/index.html +70 -0
  113. data/test/regression/scriptaculous/unit/loading_test.html +41 -0
  114. data/test/regression/scriptaculous/unit/position_clone_test.html +312 -0
  115. data/test/regression/scriptaculous/unit/slider_test.html +437 -0
  116. data/test/regression/scriptaculous/unit/sortable_test.html +205 -0
  117. data/test/regression/scriptaculous/unit/string_test.html +71 -0
  118. data/test/regression/scriptaculous/unit/unittest_test.html +154 -0
  119. data/test/regression/scriptaculous/upstream +1 -0
  120. data/test/test_helper.rb +20 -0
  121. data/test/unit/runner_test.rb +165 -0
  122. data/test/unit/test_case_test.rb +168 -0
  123. data/test/unit/test_test.rb +24 -0
  124. metadata +179 -0
@@ -0,0 +1,148 @@
1
+ var testObj = {
2
+ isNice: function() {
3
+ return true;
4
+ },
5
+ isBroken: function() {
6
+ return false;
7
+ }
8
+ }
9
+
10
+ new Test.Unit.Runner({
11
+
12
+ testIsRunningFromRake: function() {
13
+ if (window.location.toString().startsWith('http')) {
14
+ this.assert(this.isRunningFromRake);
15
+ this.info('These tests are running from rake.')
16
+ } else {
17
+ this.assert(!this.isRunningFromRake);
18
+ this.info('These tests are *not* running from rake.')
19
+ }
20
+ },
21
+
22
+ testBuildMessage: function() {
23
+ this.assertEqual("'foo' 'bar'", this.buildMessage('', '? ?', 'foo', 'bar'))
24
+ },
25
+
26
+ testAssertEqual: function() {
27
+ this.assertEqual(0, 0);
28
+ this.assertEqual(0, 0, "test");
29
+
30
+ this.assertEqual(0,'0');
31
+ this.assertEqual(65.0, 65);
32
+
33
+ this.assertEqual("a", "a");
34
+ this.assertEqual("a", "a", "test");
35
+
36
+ this.assertNotEqual(0, 1);
37
+ this.assertNotEqual("a","b");
38
+ this.assertNotEqual({},{});
39
+ this.assertNotEqual([],[]);
40
+ this.assertNotEqual([],{});
41
+ },
42
+
43
+ testAssertEnumEqual: function() {
44
+ this.assertEnumEqual([], []);
45
+ this.assertEnumEqual(['a', 'b'], ['a', 'b']);
46
+ this.assertEnumEqual(['1', '2'], [1, 2]);
47
+ this.assertEnumNotEqual(['1', '2'], [1, 2, 3]);
48
+ },
49
+
50
+ testAssertHashEqual: function() {
51
+ this.assertHashEqual({}, {});
52
+ this.assertHashEqual({a:'b'}, {a:'b'});
53
+ this.assertHashEqual({a:'b', c:'d'}, {c:'d', a:'b'});
54
+ this.assertHashNotEqual({a:'b', c:'d'}, {c:'d', a:'boo!'});
55
+ },
56
+
57
+ testAssertRespondsTo: function() {
58
+ this.assertRespondsTo('isNice', testObj);
59
+ this.assertRespondsTo('isBroken', testObj);
60
+ },
61
+
62
+ testAssertIdentical: function() {
63
+ this.assertIdentical(0, 0);
64
+ this.assertIdentical(0, 0, "test");
65
+ this.assertIdentical(1, 1);
66
+ this.assertIdentical('a', 'a');
67
+ this.assertIdentical('a', 'a', "test");
68
+ this.assertIdentical('', '');
69
+ this.assertIdentical(undefined, undefined);
70
+ this.assertIdentical(null, null);
71
+ this.assertIdentical(true, true);
72
+ this.assertIdentical(false, false);
73
+
74
+ var obj = {a:'b'};
75
+ this.assertIdentical(obj, obj);
76
+
77
+ this.assertNotIdentical({1:2,3:4},{1:2,3:4});
78
+
79
+ this.assertIdentical(1, 1.0); // both are typeof == 'number'
80
+
81
+ this.assertNotIdentical(1, '1');
82
+ this.assertNotIdentical(1, '1.0');
83
+ },
84
+
85
+ testAssertNullAndAssertUndefined: function() {
86
+ this.assertNull(null);
87
+ this.assertNotNull(undefined);
88
+ this.assertNotNull(0);
89
+ this.assertNotNull('');
90
+ this.assertNotUndefined(null);
91
+ this.assertUndefined(undefined);
92
+ this.assertNotUndefined(0);
93
+ this.assertNotUndefined('');
94
+ this.assertNullOrUndefined(null);
95
+ this.assertNullOrUndefined(undefined);
96
+ this.assertNotNullOrUndefined(0);
97
+ this.assertNotNullOrUndefined('');
98
+ },
99
+
100
+ testAssertMatch: function() {
101
+ this.assertMatch(/knowmad.jpg$/, 'http://script.aculo.us/images/knowmad.jpg');
102
+ this.assertMatch(/Fuc/, 'Thomas Fuchs');
103
+ this.assertMatch(/^\$(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?$/, '$19.95');
104
+ this.assertMatch(/(\d{3}\) ?)|(\d{3}[- \.])?\d{3}[- \.]\d{4}(\s(x\d+)?){0,1}$/, '704-343-9330');
105
+ this.assertMatch(/^(?:(?:(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00)))(\/|-|\.)(?:0?2\1(?:29)))|(?:(?:(?:1[6-9]|[2-9]\d)?\d{2})(\/|-|\.)(?:(?:(?:0?[13578]|1[02])\2(?:31))|(?:(?:0?[1,3-9]|1[0-2])\2(29|30))|(?:(?:0?[1-9])|(?:1[0-2]))\2(?:0?[1-9]|1\d|2[0-8]))))$/, '2001-06-16');
106
+ this.assertMatch(/^((0?[123456789])|(1[012]))\s*:\s*([012345]\d)(\s*:\s*([012345]\d))?\s*[ap]m\s*-\s*((0?[123456789])|(1[012]))\s*:\s*([012345]\d)(\s*:\s*([012345]\d))?\s*[ap]m$/i, '2:00PM-2:15PM');
107
+ this.assertNoMatch(/zubar/, 'foo bar');
108
+ },
109
+
110
+ testAssertInstanceOf: function() {
111
+ this.assertInstanceOf(String, new String);
112
+ this.assertInstanceOf(RegExp, /foo/);
113
+ this.assertNotInstanceOf(String, {});
114
+ },
115
+
116
+ testAssertVisible: function() {
117
+ this.assertVisible('testcss1');
118
+ this.assertNotVisible('testcss1_span');
119
+ //this.assertNotVisible('testcss2', "Due to a Safari bug, this test fails in Safari.");
120
+
121
+ Element.hide('testcss1');
122
+ this.assertNotVisible('testcss1');
123
+ this.assertNotVisible('testcss1_span');
124
+ Element.show('testcss1');
125
+ this.assertVisible('testcss1');
126
+ this.assertNotVisible('testcss1_span');
127
+
128
+ Element.show('testcss1_span');
129
+ this.assertVisible('testcss1_span');
130
+ Element.hide('testcss1');
131
+ this.assertNotVisible('testcss1_span'); // hidden by parent
132
+ },
133
+
134
+ testAssertElementsMatch: function() {
135
+ this.assertElementsMatch($$('#tlist'), '#tlist');
136
+ this.assertElementMatches($('tlist'), '#tlist');
137
+ }
138
+ });
139
+
140
+ new Test.Unit.Runner({
141
+ testDummy: function() {
142
+ this.assert(true);
143
+ },
144
+
145
+ testMultipleTestRunner: function() {
146
+ this.assertEqual('passed', $('testlog_2').down('td', 1).innerHTML);
147
+ }
148
+ }, {testLog: 'testlog_2'});
@@ -0,0 +1,45 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <title>Unit test file | Unittest | default template | 2009-04-11 15:28</title>
6
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
7
+ <script type="text/javascript" charset="utf-8">
8
+ var eventResults = {};
9
+ var originalElement = window.Element;
10
+ </script>
11
+ <script src="assets/prototype.js" type="text/javascript" charset="utf-8"></script>
12
+ <script src="assets/unittest.js" type="text/javascript" charset="utf-8"></script>
13
+ <link rel="stylesheet" href="assets/unittest.css" type="text/css" />
14
+
15
+
16
+ <script src="tests/unittest_test.js" type="text/javascript" charset="utf-8"></script>
17
+ </head>
18
+ <body>
19
+
20
+ <div id="testlog"></div>
21
+
22
+ <div id="testlog_2"> </div>
23
+
24
+ <!-- Test elements follow -->
25
+ <div id="test_1" class="a bbbbbbbbbbbb cccccccccc dddd"> </div>
26
+
27
+ <div id="test_2"> <span> </span>
28
+
29
+
30
+
31
+ <div><div></div> </div><span> </span>
32
+ </div>
33
+
34
+ <ul id="tlist"><li id="tlist_1">x1</li><li id="tlist_2">x2</li></ul>
35
+ <ul id="tlist2"><li class="a" id="tlist2_1">x1</li><li id="tlist2_2">x2</li></ul>
36
+
37
+ <div id="testmoveby" style="background-color:#333;width:100px;">XXXX</div>
38
+
39
+ <div id="testcss1">testcss1<span id="testcss1_span" style="display:none;">blah</span></div><div id="testcss2">testcss1</div>
40
+
41
+ </body>
42
+ </html>
43
+ <script type="text/javascript" charset="utf-8">
44
+ eventResults.endOfDocument = true;
45
+ </script>
@@ -0,0 +1 @@
1
+ 37bdd117a0a57c3d39075bd2d972de8dde71520f
@@ -0,0 +1,134 @@
1
+ // Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
2
+ //
3
+ // script.aculo.us is freely distributable under the terms of an MIT-style license.
4
+ // For details, see the script.aculo.us web site: http://script.aculo.us/
5
+
6
+ var Builder = {
7
+ NODEMAP: {
8
+ AREA: 'map',
9
+ CAPTION: 'table',
10
+ COL: 'table',
11
+ COLGROUP: 'table',
12
+ LEGEND: 'fieldset',
13
+ OPTGROUP: 'select',
14
+ OPTION: 'select',
15
+ PARAM: 'object',
16
+ TBODY: 'table',
17
+ TD: 'table',
18
+ TFOOT: 'table',
19
+ TH: 'table',
20
+ THEAD: 'table',
21
+ TR: 'table'
22
+ },
23
+ // note: For Firefox < 1.5, OPTION and OPTGROUP tags are currently broken,
24
+ // due to a Firefox bug
25
+ node: function(elementName) {
26
+ elementName = elementName.toUpperCase();
27
+
28
+ // try innerHTML approach
29
+ var parentTag = this.NODEMAP[elementName] || 'div';
30
+ var parentElement = document.createElement(parentTag);
31
+ try { // prevent IE "feature": http://dev.rubyonrails.org/ticket/2707
32
+ parentElement.innerHTML = "<" + elementName + "></" + elementName + ">";
33
+ } catch(e) {}
34
+ var element = parentElement.firstChild || null;
35
+
36
+ // see if browser added wrapping tags
37
+ if(element && (element.tagName.toUpperCase() != elementName))
38
+ element = element.getElementsByTagName(elementName)[0];
39
+
40
+ // fallback to createElement approach
41
+ if(!element) element = document.createElement(elementName);
42
+
43
+ // abort if nothing could be created
44
+ if(!element) return;
45
+
46
+ // attributes (or text)
47
+ if(arguments[1])
48
+ if(this._isStringOrNumber(arguments[1]) ||
49
+ (arguments[1] instanceof Array) ||
50
+ arguments[1].tagName) {
51
+ this._children(element, arguments[1]);
52
+ } else {
53
+ var attrs = this._attributes(arguments[1]);
54
+ if(attrs.length) {
55
+ try { // prevent IE "feature": http://dev.rubyonrails.org/ticket/2707
56
+ parentElement.innerHTML = "<" +elementName + " " +
57
+ attrs + "></" + elementName + ">";
58
+ } catch(e) {}
59
+ element = parentElement.firstChild || null;
60
+ // workaround firefox 1.0.X bug
61
+ if(!element) {
62
+ element = document.createElement(elementName);
63
+ for(attr in arguments[1])
64
+ element[attr == 'class' ? 'className' : attr] = arguments[1][attr];
65
+ }
66
+ if(element.tagName.toUpperCase() != elementName)
67
+ element = parentElement.getElementsByTagName(elementName)[0];
68
+ }
69
+ }
70
+
71
+ // text, or array of children
72
+ if(arguments[2])
73
+ this._children(element, arguments[2]);
74
+
75
+ return $(element);
76
+ },
77
+ _text: function(text) {
78
+ return document.createTextNode(text);
79
+ },
80
+
81
+ ATTR_MAP: {
82
+ 'className': 'class',
83
+ 'htmlFor': 'for'
84
+ },
85
+
86
+ _attributes: function(attributes) {
87
+ var attrs = [];
88
+ for(attribute in attributes)
89
+ attrs.push((attribute in this.ATTR_MAP ? this.ATTR_MAP[attribute] : attribute) +
90
+ '="' + attributes[attribute].toString().escapeHTML().gsub(/"/,'&quot;') + '"');
91
+ return attrs.join(" ");
92
+ },
93
+ _children: function(element, children) {
94
+ if(children.tagName) {
95
+ element.appendChild(children);
96
+ return;
97
+ }
98
+ if(typeof children=='object') { // array can hold nodes and text
99
+ children.flatten().each( function(e) {
100
+ if(typeof e=='object')
101
+ element.appendChild(e);
102
+ else
103
+ if(Builder._isStringOrNumber(e))
104
+ element.appendChild(Builder._text(e));
105
+ });
106
+ } else
107
+ if(Builder._isStringOrNumber(children))
108
+ element.appendChild(Builder._text(children));
109
+ },
110
+ _isStringOrNumber: function(param) {
111
+ return(typeof param=='string' || typeof param=='number');
112
+ },
113
+ build: function(html) {
114
+ var element = this.node('div');
115
+ $(element).update(html.strip());
116
+ return element.down();
117
+ },
118
+ dump: function(scope) {
119
+ if(typeof scope != 'object' && typeof scope != 'function') scope = window; //global scope
120
+
121
+ var tags = ("A ABBR ACRONYM ADDRESS APPLET AREA B BASE BASEFONT BDO BIG BLOCKQUOTE BODY " +
122
+ "BR BUTTON CAPTION CENTER CITE CODE COL COLGROUP DD DEL DFN DIR DIV DL DT EM FIELDSET " +
123
+ "FONT FORM FRAME FRAMESET H1 H2 H3 H4 H5 H6 HEAD HR HTML I IFRAME IMG INPUT INS ISINDEX "+
124
+ "KBD LABEL LEGEND LI LINK MAP MENU META NOFRAMES NOSCRIPT OBJECT OL OPTGROUP OPTION P "+
125
+ "PARAM PRE Q S SAMP SCRIPT SELECT SMALL SPAN STRIKE STRONG STYLE SUB SUP TABLE TBODY TD "+
126
+ "TEXTAREA TFOOT TH THEAD TITLE TR TT U UL VAR").split(/\s+/);
127
+
128
+ tags.each( function(tag){
129
+ scope[tag] = function() {
130
+ return Builder.node.apply(Builder, [tag].concat($A(arguments)));
131
+ };
132
+ });
133
+ }
134
+ };