jspec-steventux 3.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. data/History.md +763 -0
  2. data/Manifest +73 -0
  3. data/README.md +974 -0
  4. data/Rakefile +44 -0
  5. data/bin/jspec +178 -0
  6. data/jspec-steventux.gemspec +44 -0
  7. data/lib/images/bg.png +0 -0
  8. data/lib/images/hr.png +0 -0
  9. data/lib/images/loading.gif +0 -0
  10. data/lib/images/sprites.bg.png +0 -0
  11. data/lib/images/sprites.png +0 -0
  12. data/lib/images/vr.png +0 -0
  13. data/lib/jspec.css +149 -0
  14. data/lib/jspec.growl.js +115 -0
  15. data/lib/jspec.jquery.js +72 -0
  16. data/lib/jspec.js +1756 -0
  17. data/lib/jspec.shell.js +39 -0
  18. data/lib/jspec.timers.js +90 -0
  19. data/lib/jspec.xhr.js +195 -0
  20. data/spec/commands/example_command.rb +19 -0
  21. data/spec/dom.html +33 -0
  22. data/spec/fixtures/test.html +1 -0
  23. data/spec/fixtures/test.json +1 -0
  24. data/spec/fixtures/test.xml +5 -0
  25. data/spec/node.js +17 -0
  26. data/spec/rhino.js +23 -0
  27. data/spec/ruby/bin/init_spec.rb +101 -0
  28. data/spec/ruby/bin/install_spec.rb +142 -0
  29. data/spec/ruby/bin/run_spec.rb +0 -0
  30. data/spec/ruby/bin/shell_spec.rb +13 -0
  31. data/spec/ruby/bin/spec_helper.rb +8 -0
  32. data/spec/ruby/bin/update_spec.rb +72 -0
  33. data/spec/server.html +29 -0
  34. data/spec/server.rb +2 -0
  35. data/spec/support/env.js +10118 -0
  36. data/spec/support/jquery.js +4376 -0
  37. data/spec/unit/helpers.js +64 -0
  38. data/spec/unit/spec.fixtures.js +17 -0
  39. data/spec/unit/spec.grammar-less.js +34 -0
  40. data/spec/unit/spec.grammar.js +241 -0
  41. data/spec/unit/spec.jquery.js +178 -0
  42. data/spec/unit/spec.jquery.xhr.js +84 -0
  43. data/spec/unit/spec.js +187 -0
  44. data/spec/unit/spec.matchers.js +577 -0
  45. data/spec/unit/spec.modules.js +51 -0
  46. data/spec/unit/spec.shared-behaviors.js +80 -0
  47. data/spec/unit/spec.utils.js +346 -0
  48. data/spec/unit/spec.xhr.js +157 -0
  49. data/src/browsers.rb +294 -0
  50. data/src/helpers.rb +67 -0
  51. data/src/installables.rb +229 -0
  52. data/src/project.rb +341 -0
  53. data/src/routes.rb +57 -0
  54. data/src/server.rb +99 -0
  55. data/support/js.jar +0 -0
  56. data/templates/default/History.md +5 -0
  57. data/templates/default/Readme.md +29 -0
  58. data/templates/default/lib/yourlib.js +2 -0
  59. data/templates/default/spec/commands/example_command.rb +19 -0
  60. data/templates/default/spec/dom.html +22 -0
  61. data/templates/default/spec/node.js +10 -0
  62. data/templates/default/spec/rhino.js +10 -0
  63. data/templates/default/spec/server.html +18 -0
  64. data/templates/default/spec/server.rb +4 -0
  65. data/templates/default/spec/unit/spec.helper.js +0 -0
  66. data/templates/default/spec/unit/spec.js +8 -0
  67. data/templates/rails/commands/example_commands.rb +19 -0
  68. data/templates/rails/dom.html +22 -0
  69. data/templates/rails/rhino.js +10 -0
  70. data/templates/rails/server.html +18 -0
  71. data/templates/rails/server.rb +4 -0
  72. data/templates/rails/unit/spec.helper.js +0 -0
  73. data/templates/rails/unit/spec.js +8 -0
  74. metadata +185 -0
@@ -0,0 +1,64 @@
1
+
2
+ JSpec.include({
3
+ name: 'Helpers',
4
+ utilities : {
5
+ mock_it : function(body) {
6
+ JSpec.assert = false
7
+ var spec = new JSpec.Spec('mock', body)
8
+ var prev = JSpec.currentSpec
9
+ JSpec.runSpec(spec)
10
+ JSpec.currentSpec = prev
11
+ JSpec.assert = true
12
+ return spec
13
+ }
14
+ },
15
+
16
+ matchers : {
17
+ have_failure_message : function(spec, expected) {
18
+ return JSpec.any(spec.assertions, function(assertion){
19
+ if (assertion.passed) return
20
+ switch (expected.constructor) {
21
+ case String: return assertion.message == expected
22
+ case RegExp: return expected.test(assertion.message)
23
+ default : return false
24
+ }
25
+ })
26
+ }
27
+ }
28
+ })
29
+
30
+ JSpec.include({
31
+ name: 'ExampleModule',
32
+ utilities : {
33
+ doFoo : function(){ return 'foo' },
34
+ doBar : function(){ return 'bar' }
35
+ },
36
+ randomHook : function(a, b) {
37
+ return [a, b]
38
+ },
39
+ beforeSpec : function() { addedBeforeSpec = true; this.utilities.doFoo() },
40
+ afterSpec : function() { addedAfterSpec = true },
41
+ beforeSuite : function() { addedBeforeSuite = true },
42
+ afterSuite : function() { addedAfterSuite = true },
43
+ matchers : {
44
+ be_foo_bar : function() {
45
+ return true
46
+ }
47
+ },
48
+ DSLs : {
49
+ snake : {
50
+ some_snake_case_stuff : function(){
51
+ return true
52
+ }
53
+ },
54
+ camel : {
55
+ someCamelCaseStuff : function() {
56
+ return true
57
+ }
58
+ }
59
+ }
60
+ })
61
+
62
+ JSpec.include({
63
+ name : 'EmptyModule'
64
+ })
@@ -0,0 +1,17 @@
1
+
2
+ describe 'Utility'
3
+ describe 'fixture()'
4
+ it 'should return a files contents'
5
+ fixture('test.html').should.eql '<p>test</p>'
6
+ fixture('test').should.eql '<p>test</p>'
7
+ end
8
+
9
+ it 'should cache contents'
10
+ contents = fixture('test')
11
+ JSpec.cache['test'].should.eql contents
12
+ JSpec.cache['test'] = 'foo'
13
+ fixture('test').should.eql 'foo'
14
+ delete JSpec.cache['test']
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,34 @@
1
+
2
+ JSpec.describe('Grammar-less', function(){
3
+ before(function(){
4
+ n = 1
5
+ })
6
+
7
+ it('should work', function(){
8
+ expect(true).to(be, true)
9
+ expect(n).to(equal, 1)
10
+ })
11
+
12
+ describe('with nested describes', function(){
13
+ before(function(){
14
+ hits = []
15
+ })
16
+
17
+ before_each(function(){
18
+ n++
19
+ hits.push('before_each')
20
+ })
21
+
22
+ it('should work', function(){
23
+ expect(true).not_to(be, false)
24
+ expect(n).to(eql, 2)
25
+ expect(hits).to(eql, ['before_each'])
26
+ })
27
+
28
+ it('should work again', function(){
29
+ expect(n).to(eql, 3)
30
+ expect(hits).to(eql, ['before_each', 'before_each'])
31
+ })
32
+ })
33
+
34
+ })
@@ -0,0 +1,241 @@
1
+
2
+ describe 'Grammar'
3
+
4
+ it 'should allow "it" spec literal'
5
+ true.should.be_true
6
+ end
7
+
8
+ n = 10
9
+
10
+ it 'should allow literal javascript outside of blocks'
11
+ n.should.eql 10
12
+ end
13
+
14
+ it 'should escape <html> in <p>descriptions</p> and body'
15
+ '<p></p>'.should.eql '<p></p>'
16
+ end
17
+
18
+ it 'should parse correctly when "it" is within the body'
19
+ text = 'Get it at Github'
20
+ text.should.include 'it'
21
+ end
22
+
23
+ it 'should parse correctly when "describe" is within the body'
24
+ text = 'It should work with describe'
25
+ text.should.include 'describe'
26
+ end
27
+
28
+ it 'should parse correctly when "end" is within the body'
29
+ text = 'This should not end the parsing :)'
30
+ text.should.include 'not'
31
+ end
32
+
33
+ it 'should parse correctly with "before" and "after" within the body'
34
+ text = 'This comes before that, which is after the rest'
35
+ text.should.include 'before'
36
+ end
37
+
38
+ it 'should allow parens to be optional when no args are passed'
39
+ true.should.be_true
40
+ true.should.be_true()
41
+ end
42
+
43
+ it 'should not mess up with words like it or append in descriptions'
44
+ -{ element.append().end() }.should.throw_error
45
+ end
46
+
47
+ it 'should not mess up "end" in strings'
48
+ 'foo end bar'.should.not.eql 'foo }); bar'
49
+ end
50
+
51
+ it 'should allow semicolons'
52
+ true.should.be_true;
53
+ true.should.be_true();
54
+ true.should.be_true() ;
55
+ end
56
+
57
+ it 'should allow parens to be optional with args'
58
+ 'foobar'.should.include 'foo'
59
+ 'rawr'.should.not_include 'foo'
60
+ end
61
+
62
+ it 'should allow literals without defining variables variables'
63
+ {}.should.be_an Object
64
+ end
65
+
66
+ it 'should allow alternative closure literal'
67
+ -{ throw 'test' }.should.throw_error
68
+ end
69
+
70
+ it 'should allow grammar-less assertions'
71
+ expect(true).to(be, true)
72
+ expect([1,2,3]).to(include, 1, 2, 3)
73
+ expect(true).not_to(be, false)
74
+ end
75
+
76
+ it 'should allow multi-line expect() assertions'
77
+ expect(' \
78
+ foo \
79
+ bar \
80
+ ').to(include, 'foo', 'bar')
81
+ end
82
+
83
+ it 'should allow commenting out of conversions'
84
+ // -{ throw 'foo' }.should.throw_error
85
+ // foo.should.not.eql 'bar'
86
+ end
87
+
88
+ it 'should allow inclusive range literal n..n'
89
+ 1..5.should.eql [1,2,3,4,5]
90
+ 3..4.should.eql [3,4]
91
+ 1..1.should.eql [1]
92
+ 3..1.should.eql [3,2,1]
93
+ end
94
+
95
+ it 'should allow snakecase style assertions'
96
+ 'foo'.should_equal('foo')
97
+ 'foo'.should_equal 'foo'
98
+ 'bar'.should_not_equal('foo')
99
+ 'bar'.should_not_equal 'foo'
100
+ end
101
+
102
+ it 'should allow dot style assertions'
103
+ 'foo'.should.equal('foo')
104
+ 'foo'.should.equal 'foo'
105
+ 'bar'.should.not.equal('foo')
106
+ 'bar'.should.not.equal 'foo'
107
+ end
108
+
109
+ describe 'with tabs'
110
+ before_each
111
+ foo = 'bar'
112
+ end
113
+
114
+ it 'should work'
115
+ foo.should.eql 'bar'
116
+ end
117
+
118
+ it 'should work'
119
+ true.should.be true
120
+ true.should.be(true)
121
+ true.should.be(true);
122
+ end
123
+ end
124
+
125
+ describe 'with nested describe'
126
+ it 'should work'
127
+ true.should.be_true
128
+ end
129
+
130
+ describe 'nested again'
131
+ it 'should still work'
132
+ true.should.be_true
133
+ end
134
+ end
135
+ end
136
+
137
+ describe 'before / after blocks'
138
+ before
139
+ n = 1
140
+ hits = []
141
+ hits.push('before')
142
+ end
143
+
144
+ after
145
+ n = 0
146
+ hits.push('after')
147
+ end
148
+
149
+ it 'should work'
150
+ n.should.eql 1
151
+ hits.should.eql ['before']
152
+ n++
153
+ end
154
+
155
+ it 'should persist'
156
+ n.should.eql 2
157
+ hits.should.eql ['before']
158
+ end
159
+
160
+ describe 'with nested describe'
161
+ it 'should be accessable'
162
+ n.should.eql 1
163
+ hits.should.eql ['before']
164
+ end
165
+ end
166
+ end
167
+
168
+ describe 'before_each / after_each blocks'
169
+ hits = []
170
+
171
+ before_each
172
+ n = 1
173
+ hits.push('before_each')
174
+ end
175
+
176
+ after_each
177
+ o = 2
178
+ hits.push('after_each')
179
+ end
180
+
181
+ it 'should work'
182
+ n.should.eql 1
183
+ hits.should.eql ['before_each']
184
+ n = 2
185
+ end
186
+
187
+ it 'should not persist'
188
+ n.should.eql 1
189
+ o.should.eql 2
190
+ hits.should.eql ['before_each', 'after_each', 'before_each']
191
+ end
192
+
193
+ describe 'with nested describe'
194
+ it 'should be accessable'
195
+ n.should.eql 1
196
+ o.should.eql 2
197
+ hits.should.eql ['before_each', 'after_each', 'before_each', 'after_each', 'before_each']
198
+ end
199
+
200
+ it 'should continue hits'
201
+ hits.should.eql ['before_each', 'after_each', 'before_each', 'after_each', 'before_each', 'after_each', 'before_each']
202
+ end
203
+
204
+ describe 'with more hooks'
205
+ before_each
206
+ hits.push('before_each')
207
+ end
208
+
209
+ after_each
210
+ hits.push('after_each')
211
+ end
212
+
213
+ it 'should continue hits, while cascading properly'
214
+ hits.should.eql ['before_each', 'after_each', 'before_each', 'after_each', 'before_each', 'after_each', 'before_each', 'after_each', 'before_each', 'before_each']
215
+ end
216
+ end
217
+
218
+ describe 'with multiple hooks'
219
+ before_each
220
+ hits = []
221
+ end
222
+
223
+ before_each
224
+ hits.push('before_each')
225
+ end
226
+
227
+ it 'should work'
228
+ hits.should.eql ['before_each']
229
+ end
230
+ end
231
+ end
232
+ end
233
+
234
+ end
235
+
236
+ __END__
237
+
238
+ this should not matter because it is
239
+ considered a comment by the JSpec grammar :)
240
+ and is sometimes useful for temp reference info
241
+ when writting specs.
@@ -0,0 +1,178 @@
1
+
2
+ describe 'jQuery'
3
+ describe 'puts()'
4
+ it 'should output selector when present'
5
+ object = { jquery: '1.3.2', selector: '.foo bar' }
6
+ puts(object).should.eql 'selector ".foo bar"'
7
+ end
8
+
9
+ it 'should output outerHTML otherwise'
10
+ puts($('<p>Foo</p>')).should.match(/<p>Foo<\/p>/i)
11
+ end
12
+ end
13
+
14
+ describe 'with elements'
15
+ it 'should output the outerHTML'
16
+ puts($('<p>Foo</p>').get(0)).should.match(/<p>Foo<\/p>/i)
17
+ end
18
+ end
19
+
20
+ describe 'sandbox()'
21
+ before
22
+ dom = sandbox()
23
+ end
24
+
25
+ it 'should provide an empty DOM sandbox'
26
+ dom.prepend('<em>test</em>')
27
+ dom.should.have_text 'test'
28
+ end
29
+ end
30
+
31
+ describe 'element() / elements()'
32
+ it 'should alias jQuery'
33
+ element.should.be jQuery
34
+ elements.should.be jQuery
35
+ end
36
+ end
37
+
38
+ describe 'matchers'
39
+ before_each
40
+ html = '<p><label><em>Save?</em></label> \
41
+ <select class="save form-select" style="display: none;"> \
42
+ <option value="0">No</option> \
43
+ <option value="1">Yes</option> \
44
+ </select> \
45
+ <strong>test</strong> \
46
+ <strong>test</strong> \
47
+ </p>'
48
+ elem = $(html)
49
+ end
50
+
51
+ it 'should fail with pretty print of element'
52
+ spec = mock_it(function() {
53
+ elem.should.not.have_tag 'label'
54
+ })
55
+ spec.should.have_failure_message(/<label>\s*<em>Save?/i)
56
+ end
57
+
58
+ describe 'have_tag / have_one'
59
+ it 'should check if a single child is present'
60
+ elem.should.have_tag 'label'
61
+ elem.should.have_tag 'em'
62
+ elem.should.have_one 'label'
63
+ elem.should.not.have_tag 'input'
64
+ end
65
+ end
66
+
67
+ describe 'have_tags / have_many / have_any'
68
+ it 'should check if more than one child is present'
69
+ elem.should.have_tags 'option'
70
+ elem.should.have_many 'option'
71
+ elem.should.not.have_many 'label'
72
+ elem.find('option').remove()
73
+ elem.should.not.have_any 'option'
74
+ end
75
+ end
76
+
77
+ describe 'have_child'
78
+ it 'should check if a direct child is present'
79
+ elem.should.have_child 'label'
80
+ elem.should.not.have_child 'em'
81
+ end
82
+ end
83
+
84
+ describe 'have_children'
85
+ it 'should check if more than one direct children are present'
86
+ elem.should.have_children 'strong'
87
+ elem.should.not.have_children 'select'
88
+ end
89
+ end
90
+
91
+ describe 'have_text'
92
+ it 'should check for plain text'
93
+ $('label', elem).should.have_text 'Save?'
94
+ end
95
+ end
96
+
97
+ describe 'have_value'
98
+ it 'should check if an element has the given value'
99
+ elem.find('option').get(1).should.have_value '1'
100
+ end
101
+ end
102
+
103
+ describe 'have_class'
104
+ it 'should check if an element has the given class'
105
+ $('select', elem).should.have_class 'save'
106
+ end
107
+ end
108
+
109
+ describe 'have_classes'
110
+ it 'should check if an element has the classes given'
111
+ $('select', elem).should.have_classes 'save', 'form-select'
112
+ $('select', elem).should.not.have_classes 'save', 'foo'
113
+ $('select', elem).should.not.have_classes 'foo', 'save'
114
+ end
115
+ end
116
+
117
+ describe 'be_visible'
118
+ it 'should check that an element is not hidden or set to display of none'
119
+ element('#jspec-report').should.be_visible
120
+ '#jspec-report'.should.be_visible
121
+ '<input style="visibility: hidden;"/>'.should.not.be_visible
122
+ '<input style="display: none;"/>'.should.not.be_visible
123
+ '<input />'.should.be_visible
124
+ end
125
+ end
126
+
127
+ describe 'be_enabled'
128
+ it 'should check that an element is currently enabled'
129
+ '<input type="button"/>'.should.be_enabled
130
+ '<input type="button" disabled="disabled" />'.should.not.be_enabled
131
+ end
132
+ end
133
+
134
+ describe 'be_BOOLATTR'
135
+ it 'should check that an element is currently selected, disabled, checked etc'
136
+ '<input type="button"/>'.should.not.be_disabled
137
+ '<input type="button" disabled="disabled" />'.should.be_disabled
138
+ '<option value="foo" selected="selected">Foo</option>'.should.be_selected
139
+ end
140
+ end
141
+
142
+ describe 'have_ATTR'
143
+ it 'should check if an attribute exists'
144
+ '<input type="checkbox"/>'.should.have_type
145
+ end
146
+
147
+ it 'should check if an attribute has a specific value'
148
+ '<input type="checkbox"/>'.should.have_type 'checkbox'
149
+ end
150
+ end
151
+
152
+ describe 'be_hidden'
153
+ it 'should check if an element is hidden'
154
+ '<input style="display: none;" />'.should.be_hidden
155
+ '<input style="visibility: hidden;" />'.should.be_hidden
156
+ '<input />'.should.not.be_hidden
157
+ end
158
+ end
159
+
160
+ describe 'have_attr'
161
+ before_each
162
+ elem = '<input type="button" title="some foo" value="Foo" />'
163
+ end
164
+
165
+ it 'should check that an element has the given attribute'
166
+ elem.should.have_attr 'title'
167
+ elem.should.not_have_attr 'rawr'
168
+ end
169
+
170
+ it 'should check that the given attribute has a specific value'
171
+ elem.should.have_attr 'title', 'some foo'
172
+ elem.should.not.have_attr 'some', 'rawr'
173
+ elem.should.not.have_attr 'title', 'bar'
174
+ end
175
+ end
176
+ end
177
+
178
+ end