jspec 2.11.13 → 3.0.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 (77) hide show
  1. data/History.md +714 -0
  2. data/Manifest +51 -36
  3. data/README.md +968 -0
  4. data/Rakefile +4 -53
  5. data/bin/jspec +93 -224
  6. data/jspec.gemspec +5 -5
  7. data/lib/images/sprites.png +0 -0
  8. data/lib/jspec.css +2 -2
  9. data/lib/jspec.growl.js +115 -0
  10. data/lib/jspec.jquery.js +1 -1
  11. data/lib/jspec.js +98 -101
  12. data/lib/jspec.shell.js +5 -2
  13. data/lib/jspec.timers.js +1 -1
  14. data/lib/jspec.xhr.js +12 -2
  15. data/spec/commands/example_command.rb +19 -0
  16. data/spec/dom.html +33 -0
  17. data/spec/node.js +32 -0
  18. data/spec/rhino.js +24 -0
  19. data/spec/ruby/bin/init_spec.rb +101 -0
  20. data/spec/ruby/bin/install_spec.rb +141 -0
  21. data/spec/ruby/bin/run_spec.rb +0 -0
  22. data/spec/ruby/bin/shell_spec.rb +13 -0
  23. data/spec/ruby/bin/spec_helper.rb +25 -0
  24. data/spec/ruby/bin/update_spec.rb +72 -0
  25. data/spec/server.html +29 -0
  26. data/spec/server.rb +1 -1
  27. data/spec/{env.js → support/env.js} +554 -664
  28. data/spec/support/jquery.js +4376 -0
  29. data/spec/{helpers.js → unit/helpers.js} +2 -0
  30. data/spec/{spec.fixtures.js → unit/spec.fixtures.js} +0 -1
  31. data/spec/{spec.grammar-less.js → unit/spec.grammar-less.js} +0 -0
  32. data/spec/{spec.grammar.js → unit/spec.grammar.js} +1 -11
  33. data/spec/{spec.jquery.js → unit/spec.jquery.js} +0 -17
  34. data/spec/{spec.jquery.xhr.js → unit/spec.jquery.xhr.js} +13 -2
  35. data/spec/unit/spec.js +187 -0
  36. data/spec/{spec.matchers.js → unit/spec.matchers.js} +141 -66
  37. data/spec/{spec.modules.js → unit/spec.modules.js} +0 -0
  38. data/spec/{spec.shared-behaviors.js → unit/spec.shared-behaviors.js} +0 -0
  39. data/spec/{spec.utils.js → unit/spec.utils.js} +123 -22
  40. data/spec/{spec.xhr.js → unit/spec.xhr.js} +11 -10
  41. data/{server → src}/browsers.rb +23 -0
  42. data/{server → src}/helpers.rb +2 -17
  43. data/src/installables.rb +229 -0
  44. data/src/project.rb +340 -0
  45. data/{server → src}/routes.rb +1 -1
  46. data/{server → src}/server.rb +0 -0
  47. data/support/js.jar +0 -0
  48. data/templates/default/History.md +5 -0
  49. data/templates/default/{README.rdoc → Readme.md} +3 -3
  50. data/templates/default/lib/{yourlib.core.js → yourlib.js} +0 -0
  51. data/templates/default/spec/commands/example_command.rb +19 -0
  52. data/templates/default/spec/{spec.dom.html → dom.html} +5 -3
  53. data/templates/default/spec/rhino.js +10 -0
  54. data/templates/default/spec/server.html +18 -0
  55. data/templates/default/spec/unit/spec.helper.js +0 -0
  56. data/templates/default/spec/{spec.core.js → unit/spec.js} +0 -0
  57. data/templates/rails/commands/example_commands.rb +19 -0
  58. data/templates/rails/{spec.dom.html → dom.html} +4 -2
  59. data/templates/rails/rhino.js +10 -0
  60. data/templates/rails/server.html +18 -0
  61. data/templates/rails/unit/spec.helper.js +0 -0
  62. data/templates/rails/{spec.application.js → unit/spec.js} +0 -0
  63. metadata +56 -41
  64. data/History.rdoc +0 -590
  65. data/README.rdoc +0 -842
  66. data/spec/async +0 -1
  67. data/spec/jquery.js +0 -19
  68. data/spec/spec.dom.html +0 -34
  69. data/spec/spec.js +0 -166
  70. data/spec/spec.node.js +0 -46
  71. data/spec/spec.rhino.js +0 -23
  72. data/spec/spec.server.html +0 -29
  73. data/templates/default/History.rdoc +0 -4
  74. data/templates/default/spec/spec.rhino.js +0 -8
  75. data/templates/default/spec/spec.server.html +0 -16
  76. data/templates/rails/spec.rhino.js +0 -8
  77. data/templates/rails/spec.server.html +0 -16
data/lib/jspec.shell.js CHANGED
@@ -15,7 +15,8 @@
15
15
 
16
16
  commands: {
17
17
  quit: ['Terminate the shell', function(){ _quit() }],
18
- exit: ['Terminate the shell', function(){ _quit() }]
18
+ exit: ['Terminate the shell', function(){ _quit() }],
19
+ p: ['Inspect an object', function(o){ return o.toSource() }]
19
20
  },
20
21
 
21
22
  /**
@@ -27,7 +28,9 @@
27
28
  start : function() {
28
29
  for (var name in this.commands)
29
30
  if (this.commands.hasOwnProperty(name))
30
- this.main.__defineGetter__(name, this.commands[name][1])
31
+ this.commands[name][1].length ?
32
+ this.main[name] = this.commands[name][1] :
33
+ this.main.__defineGetter__(name, this.commands[name][1])
31
34
  }
32
35
  }
33
36
 
data/lib/jspec.timers.js CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- // Mock Timers - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)
2
+ // JSpec - Mock Timers - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)
3
3
 
4
4
  ;(function(){
5
5
 
data/lib/jspec.xhr.js CHANGED
@@ -8,7 +8,10 @@
8
8
  var OriginalXMLHttpRequest = 'XMLHttpRequest' in this ?
9
9
  XMLHttpRequest :
10
10
  function(){}
11
-
11
+ var OriginalActiveXObject = 'ActiveXObject' in this ?
12
+ ActiveXObject :
13
+ undefined
14
+
12
15
  // --- MockXMLHttpRequest
13
16
 
14
17
  var MockXMLHttpRequest = function() {
@@ -66,11 +69,15 @@
66
69
  */
67
70
 
68
71
  send : function(data) {
72
+ var self = this
69
73
  this.data = data
70
74
  this.readyState = 4
71
75
  if (this.method == 'HEAD') this.responseText = null
72
76
  this.responseHeaders['content-length'] = (this.responseText || '').length
73
77
  if(this.async) this.onreadystatechange()
78
+ lastRequest = function(){
79
+ return self
80
+ }
74
81
  }
75
82
  }
76
83
 
@@ -132,6 +139,7 @@
132
139
  function mockRequest() {
133
140
  return { and_return : function(body, type, status, headers) {
134
141
  XMLHttpRequest = MockXMLHttpRequest
142
+ ActiveXObject = false
135
143
  status = status || 200
136
144
  headers = headers || {}
137
145
  headers['content-type'] = type
@@ -152,6 +160,7 @@
152
160
 
153
161
  function unmockRequest() {
154
162
  XMLHttpRequest = OriginalXMLHttpRequest
163
+ ActiveXObject = OriginalActiveXObject
155
164
  }
156
165
 
157
166
  JSpec.include({
@@ -175,7 +184,8 @@
175
184
  DSLs : {
176
185
  snake : {
177
186
  mock_request: mockRequest,
178
- unmock_request: unmockRequest
187
+ unmock_request: unmockRequest,
188
+ last_request: function(){ return lastRequest() }
179
189
  }
180
190
  }
181
191
 
@@ -0,0 +1,19 @@
1
+
2
+ # uncomment and call with `$ jspec example `
3
+
4
+ # command :example do |c|
5
+ # c.syntax = 'jspec example [options]'
6
+ # c.description = 'Just an example command'
7
+ # c.option '-f', '--foo string', 'Does some foo with <string>'
8
+ # c.option '-b', '--bar [string]', 'Does some bar with [string]'
9
+ # c.example 'Do some foo', 'jspec example --foo bar'
10
+ # c.example 'Do some bar', 'jspec example --bar'
11
+ # c.when_called do |args, options|
12
+ # p args
13
+ # p options.__hash__
14
+ # # options.foo
15
+ # # options.bar
16
+ # # options.__hash__[:foo]
17
+ # # options.__hash__[:bar]
18
+ # end
19
+ # end
data/spec/dom.html ADDED
@@ -0,0 +1,33 @@
1
+ <html>
2
+ <head>
3
+ <link type="text/css" rel="stylesheet" href="../lib/jspec.css" />
4
+ <script src="support/jquery.js"></script>
5
+ <script src="../lib/jspec.js"></script>
6
+ <script src="../lib/jspec.jquery.js"></script>
7
+ <script src="../lib/jspec.xhr.js"></script>
8
+ <script src="unit/helpers.js"></script>
9
+ <script src="unit/spec.grammar-less.js"></script>
10
+ <script>
11
+ function runSuites() {
12
+ JSpec
13
+ .exec('unit/spec.grammar.js')
14
+ .exec('unit/spec.js')
15
+ .exec('unit/spec.matchers.js')
16
+ .exec('unit/spec.utils.js')
17
+ .exec('unit/spec.fixtures.js')
18
+ .exec('unit/spec.shared-behaviors.js')
19
+ .exec('unit/spec.jquery.js')
20
+ .exec('unit/spec.modules.js')
21
+ .exec('unit/spec.xhr.js')
22
+ .exec('unit/spec.jquery.xhr.js')
23
+ .run({ failuresOnly: true, fixturePath: 'fixtures' })
24
+ .report()
25
+ }
26
+ </script>
27
+ </head>
28
+ <body class="jspec" onLoad="runSuites();">
29
+ <div id="jspec-top"><h2 id="jspec-title">JSpec <em><script>document.write(JSpec.version)</script></em></h2></div>
30
+ <div id="jspec"><div class="loading"></div></div>
31
+ <div id="jspec-bottom"></div>
32
+ </body>
33
+ </html>
data/spec/node.js ADDED
@@ -0,0 +1,32 @@
1
+
2
+ require.paths.unshift('./lib', './spec');
3
+ process.mixin(require('sys'))
4
+
5
+ require("jspec")
6
+ require("unit/helpers")
7
+
8
+ quit = process.exit
9
+ print = puts
10
+
11
+ readFile = function(path) {
12
+ var promise = require('posix').cat(path, "utf8")
13
+ var result = ''
14
+ promise.addErrback(function(){ throw new Error("failed to read file `" + path + "'") })
15
+ promise.addCallback(function(contents){
16
+ result = contents
17
+ })
18
+ promise.wait()
19
+ return result
20
+ }
21
+
22
+ JSpec
23
+ .exec('spec/unit/spec.js')
24
+ .exec('spec/unit/spec.utils.js')
25
+ .exec('spec/unit/spec.modules.js')
26
+ .exec('spec/unit/spec.matchers.js')
27
+ .exec('spec/unit/spec.shared-behaviors.js')
28
+ .exec('spec/unit/spec.grammar.js')
29
+ .exec('spec/unit/spec.grammar-less.js')
30
+ //.exec('spec/unit/spec.fixtures.js') TODO: when exceptions bubble properly uncomment
31
+ .run({ reporter: JSpec.reporters.Terminal, failuresOnly: true, fixturePath: 'spec/fixtures' })
32
+ .report()
data/spec/rhino.js ADDED
@@ -0,0 +1,24 @@
1
+
2
+ load('spec/support/env.js')
3
+ Envjs('spec/fixtures/test.html')
4
+ load('spec/support/jquery.js')
5
+ load('lib/jspec.js')
6
+ load('lib/jspec.xhr.js')
7
+ load('lib/jspec.growl.js')
8
+ load('lib/jspec.jquery.js')
9
+ load('spec/unit/helpers.js')
10
+ load('spec/unit/spec.grammar-less.js')
11
+
12
+ JSpec
13
+ .exec('spec/unit/spec.grammar.js')
14
+ .exec('spec/unit/spec.js')
15
+ .exec('spec/unit/spec.matchers.js')
16
+ .exec('spec/unit/spec.utils.js')
17
+ .exec('spec/unit/spec.jquery.js')
18
+ .exec('spec/unit/spec.fixtures.js')
19
+ .exec('spec/unit/spec.shared-behaviors.js')
20
+ .exec('spec/unit/spec.modules.js')
21
+ .exec('spec/unit/spec.xhr.js')
22
+ .exec('spec/unit/spec.jquery.xhr.js')
23
+ .run({ reporter: JSpec.reporters.Terminal, failuresOnly: true, fixturePath: 'spec/fixtures' })
24
+ .report()
@@ -0,0 +1,101 @@
1
+
2
+ include FileUtils
3
+
4
+ describe "jspec" do
5
+ describe "init" do
6
+ before :each do
7
+ @dest = File.dirname(__FILE__) + '/test'
8
+ mkdir @dest
9
+ end
10
+
11
+ after :each do
12
+ rm_rf @dest
13
+ end
14
+
15
+ it "should initialize a default project at the current directory when no destination is passed" do
16
+ Dir.chdir @dest do
17
+ jspec(:init)
18
+ File.directory?(@dest).should be_true
19
+ end
20
+ end
21
+
22
+ it "should initialize a default project at the given path" do
23
+ jspec(:init, @dest).should include('ruby/bin/test')
24
+ File.directory?(@dest).should be_true
25
+ end
26
+
27
+ it "should initialize a rails project when using -R or --rails" do
28
+ mkdir @dest + '/vendor'
29
+ jspec(:init, @dest, '--rails')
30
+ File.directory?(@dest).should be_true
31
+ File.directory?(@dest + '/jspec').should be_true
32
+ end
33
+
34
+ it "should initialize a rails project without --rails when the destination looks like a rails app" do
35
+ mkdir @dest + '/vendor'
36
+ jspec(:init, @dest)
37
+ File.directory?(@dest).should be_true
38
+ File.directory?(@dest + '/jspec').should be_true
39
+ end
40
+
41
+ it "should symlink jspec's library to spec/lib when using --symlink" do
42
+ jspec(:init, @dest, '--symlink')
43
+ File.directory?(@dest).should be_true
44
+ File.symlink?(@dest + '/spec/lib').should be_true
45
+ end
46
+
47
+ it "should symlink jspec's library to jspec/lib when using --symlink and --rails" do
48
+ mkdir @dest + '/vendor'
49
+ jspec(:init, @dest, '--symlink', '--rails')
50
+ File.directory?(@dest).should be_true
51
+ File.directory?(@dest + '/jspec').should be_true
52
+ File.symlink?(@dest + '/jspec/lib').should be_true
53
+ end
54
+
55
+ it "should vendorize jspec's library to spec/lib when using --freeze" do
56
+ jspec(:init, @dest, '--freeze')
57
+ File.directory?(@dest).should be_true
58
+ File.directory?(@dest + '/spec/lib').should be_true
59
+ File.exists?(@dest + '/spec/lib/jspec.js').should be_true
60
+ end
61
+
62
+ it "should vendor jspec's library to jspec/lib when using --freeze and --rails" do
63
+ mkdir @dest + '/vendor'
64
+ jspec(:init, @dest, '--freeze', '--rails')
65
+ File.directory?(@dest).should be_true
66
+ File.directory?(@dest + '/jspec').should be_true
67
+ File.directory?(@dest + '/jspec/lib').should be_true
68
+ File.exists?(@dest + '/jspec/lib/jspec.js').should be_true
69
+ end
70
+
71
+ it "should set jspec's DOM root to jspec's gem directory" do
72
+ jspec(:init, @dest)
73
+ File.read(@dest + '/spec/dom.html').should include('src="/')
74
+ end
75
+
76
+ it "should set jspec's DOM root to ../lib/ when using --freeze" do
77
+ jspec(:init, @dest, '--freeze')
78
+ File.read(@dest + '/spec/dom.html').should include('src="./lib/jspec.js')
79
+ end
80
+
81
+ it "should set jspec's DOM root to ../lib/ when using --symlink" do
82
+ jspec(:init, @dest, '--symlink')
83
+ File.read(@dest + '/spec/dom.html').should include('src="./lib/jspec.js')
84
+ end
85
+
86
+ it "should set jspec's Rhino root to jspec's gem directory" do
87
+ jspec(:init, @dest)
88
+ File.read(@dest + '/spec/rhino.js').should_not include("load('./spec/lib/jspec.js')")
89
+ end
90
+
91
+ it "should set jspec's Rhino root to ./spec/lib/ when using --freeze" do
92
+ jspec(:init, @dest, '--freeze')
93
+ File.read(@dest + '/spec/rhino.js').should include("load('./spec/lib/jspec.js')")
94
+ end
95
+
96
+ it "should set jspec's Rhino root to ./spec/lib/ when using --symlink" do
97
+ jspec(:init, @dest, '--symlink')
98
+ File.read(@dest + '/spec/rhino.js').should include("load('./spec/lib/jspec.js')")
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,141 @@
1
+
2
+ include FileUtils
3
+
4
+ describe "jspec" do
5
+ describe "install" do
6
+ before :each do
7
+ @dest = File.dirname(__FILE__) + '/test'
8
+ mkdir @dest
9
+ jspec(:init, @dest)
10
+ end
11
+
12
+ after :each do
13
+ rm_rf @dest
14
+ end
15
+
16
+ describe "jquery" do
17
+ it "should install to spec/support/jquery.js by default" do
18
+ Dir.chdir @dest do
19
+ jspec(:install, 'jquery')
20
+ File.exists?('spec/support/jquery.js').should be_true
21
+ end
22
+ end
23
+
24
+ it "should install to the destination passed" do
25
+ jspec(:install, 'jquery', "#{@dest}/spec")
26
+ File.exists?("#{@dest}/spec/jquery.js").should be_true
27
+ end
28
+
29
+ it "should install specific versions" do
30
+ Dir.chdir @dest do
31
+ jspec(:install, 'jquery', '--release', '1.3.1')
32
+ File.exists?('spec/support/jquery.js').should be_true
33
+ File.read('spec/support/jquery.js').should include('1.3.1')
34
+ end
35
+ end
36
+ end
37
+
38
+ describe "jqueryui" do
39
+ it "should install to spec/support/jquery.ui.js by default" do
40
+ Dir.chdir @dest do
41
+ jspec(:install, 'jqueryui')
42
+ File.exists?('spec/support/jquery.ui.js').should be_true
43
+ end
44
+ end
45
+
46
+ it "should install to the destination passed" do
47
+ jspec(:install, 'jqueryui', "#{@dest}/spec")
48
+ File.exists?("#{@dest}/spec/jquery.ui.js").should be_true
49
+ end
50
+
51
+ it "should install specific versions" do
52
+ Dir.chdir @dest do
53
+ jspec(:install, 'jqueryui', '--release', '1.6')
54
+ File.exists?('spec/support/jquery.ui.js').should be_true
55
+ File.read('spec/support/jquery.ui.js').should include('1.6')
56
+ end
57
+ end
58
+ end
59
+
60
+ describe "prototype" do
61
+ it "should install to spec/support/prototype.js by default" do
62
+ Dir.chdir @dest do
63
+ jspec(:install, 'prototype')
64
+ File.exists?('spec/support/prototype.js').should be_true
65
+ end
66
+ end
67
+
68
+ it "should install to the destination passed" do
69
+ jspec(:install, 'prototype', "#{@dest}/spec")
70
+ File.exists?("#{@dest}/spec/prototype.js").should be_true
71
+ end
72
+
73
+ it "should install specific versions" do
74
+ Dir.chdir @dest do
75
+ jspec(:install, 'prototype', '--release', '1.6.0.2')
76
+ File.exists?('spec/support/prototype.js').should be_true
77
+ File.read('spec/support/prototype.js').should include('1.6.0.2')
78
+ end
79
+ end
80
+ end
81
+
82
+ describe "mootools" do
83
+ it "should install to spec/support/mootools.js by default" do
84
+ Dir.chdir @dest do
85
+ jspec(:install, 'mootools')
86
+ File.exists?('spec/support/mootools.js').should be_true
87
+ end
88
+ end
89
+
90
+ it "should install to the destination passed" do
91
+ jspec(:install, 'mootools', "#{@dest}/spec")
92
+ File.exists?("#{@dest}/spec/mootools.js").should be_true
93
+ end
94
+
95
+ it "should install specific versions" do
96
+ Dir.chdir @dest do
97
+ jspec(:install, 'mootools', '--release', '1.2.1')
98
+ File.exists?('spec/support/mootools.js').should be_true
99
+ File.read('spec/support/mootools.js').should include('1.2.1')
100
+ end
101
+ end
102
+ end
103
+
104
+ describe "envjs" do
105
+ it "should install to spec/support/env.js by default" do
106
+ Dir.chdir @dest do
107
+ jspec(:install, 'envjs')
108
+ File.exists?('spec/support/env.js').should be_true
109
+ end
110
+ end
111
+
112
+ it "should install to the destination passed" do
113
+ jspec(:install, 'envjs', "#{@dest}/spec")
114
+ File.exists?("#{@dest}/spec/env.js").should be_true
115
+ end
116
+ end
117
+
118
+ describe "dojo" do
119
+ it "should install to spec/support/dojo.js by default" do
120
+ Dir.chdir @dest do
121
+ jspec(:install, 'dojo')
122
+ File.exists?('spec/support/dojo.js').should be_true
123
+ end
124
+ end
125
+
126
+ it "should install to the destination passed" do
127
+ jspec(:install, 'dojo', "#{@dest}/spec")
128
+ File.exists?("#{@dest}/spec/dojo.js").should be_true
129
+ end
130
+
131
+ it "should install specific versions" do
132
+ Dir.chdir @dest do
133
+ jspec(:install, 'dojo', '--release', '1.1.1')
134
+ File.exists?('spec/support/dojo.js').should be_true
135
+ File.read('spec/support/dojo.js').should include('1.1.1')
136
+ end
137
+ end
138
+ end
139
+
140
+ end
141
+ end
File without changes
@@ -0,0 +1,13 @@
1
+
2
+ # describe "jspec" do
3
+ # describe "shell" do
4
+ # it "should load jspec.js" do
5
+ # shell('print(JSpec.version)', 'quit()').should include('JSpec')
6
+ # end
7
+ #
8
+ # it "should quit when quit or exit commands are called" do
9
+ # shell('print(JSpec.version)', 'quit').should include('JSpec')
10
+ # shell('print(JSpec.version)', 'exit').should include('JSpec')
11
+ # end
12
+ # end
13
+ # end