visionmedia-jspec 2.6.0 → 2.7.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.
data/History.rdoc CHANGED
@@ -1,4 +1,9 @@
1
1
 
2
+ === 2.7.0 / 2009-07-14
3
+
4
+ * Added fixture() utility function
5
+ * Templates initialize with example paths to lib
6
+
2
7
  === 2.6.0 / 2009-07-09
3
8
 
4
9
  * Added Ruby on Rails support
data/Manifest CHANGED
@@ -17,6 +17,9 @@ server/browsers.rb
17
17
  server/server.rb
18
18
  spec/async
19
19
  spec/env.js
20
+ spec/fixtures/test.html
21
+ spec/fixtures/test.json
22
+ spec/fixtures/test.xml
20
23
  spec/jquery-1.3.1.js
21
24
  spec/modules.js
22
25
  spec/spec.dom.html
data/README.rdoc CHANGED
@@ -14,6 +14,7 @@ and much more.
14
14
  * Rhino support
15
15
  * Node.js support
16
16
  * Async support
17
+ * Fixture support
17
18
  * Ruby JavaScript testing server
18
19
  * Nested describes
19
20
  * Does not pollute core object prototypes
@@ -378,6 +379,23 @@ OR
378
379
  .exec('...')
379
380
  .run({ formatter : JSpec.formatters.Terminal })
380
381
  .report()
382
+
383
+ == Fixtures
384
+
385
+ The fixture() utility function may be used in order to load arbitrary file contents
386
+ for use with your specifications. JSpec will resolve fixture('data') in the following
387
+ manor:
388
+
389
+ - 'data'
390
+ - 'spec/data'
391
+ - 'spec/fixtures/data'
392
+ - 'spec/fixtures/data.html'
393
+
394
+ So if the file 'spec/fixtures/data.html' exists, we can simply use fixture('data'),
395
+ where as 'spec/fixtures/xml/data.xml' must be specified with fixture('xml/data.xml').
396
+
397
+ If you prefer not to store fixtures in the 'fixtures' directory you must be more specific
398
+ with the path supplied.
381
399
 
382
400
  == Custom Matchers
383
401
 
data/bin/jspec CHANGED
@@ -11,7 +11,7 @@ require 'fileutils'
11
11
  RHINO = 'java org.mozilla.javascript.tools.shell.Main'
12
12
 
13
13
  program :name, 'JSpec'
14
- program :version, '2.6.0'
14
+ program :version, '2.7.0'
15
15
  program :description, 'JavaScript BDD Testing Framework'
16
16
  default_command :bind
17
17
 
data/jspec.gemspec CHANGED
@@ -2,17 +2,17 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{jspec}
5
- s.version = "2.6.0"
5
+ s.version = "2.7.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["TJ Holowaychuk"]
9
- s.date = %q{2009-07-09}
9
+ s.date = %q{2009-07-14}
10
10
  s.default_executable = %q{jspec}
11
11
  s.description = %q{JavaScript BDD Testing Framework}
12
12
  s.email = %q{tj@vision-media.ca}
13
13
  s.executables = ["jspec"]
14
14
  s.extra_rdoc_files = ["bin/jspec", "lib/images/bg.png", "lib/images/hr.png", "lib/images/loading.gif", "lib/images/sprites.bg.png", "lib/images/sprites.png", "lib/images/vr.png", "lib/jspec.css", "lib/jspec.jquery.js", "lib/jspec.js", "README.rdoc"]
15
- s.files = ["bin/jspec", "History.rdoc", "jspec.gemspec", "lib/images/bg.png", "lib/images/hr.png", "lib/images/loading.gif", "lib/images/sprites.bg.png", "lib/images/sprites.png", "lib/images/vr.png", "lib/jspec.css", "lib/jspec.jquery.js", "lib/jspec.js", "Manifest", "Rakefile", "README.rdoc", "server/browsers.rb", "server/server.rb", "spec/async", "spec/env.js", "spec/jquery-1.3.1.js", "spec/modules.js", "spec/spec.dom.html", "spec/spec.grammar-less.js", "spec/spec.grammar.js", "spec/spec.jquery.js", "spec/spec.js", "spec/spec.matchers.js", "spec/spec.modules.js", "spec/spec.node.js", "spec/spec.rhino.js", "spec/spec.server.html", "spec/spec.shared-behaviors.js", "spec/spec.utils.js", "templates/default/History.rdoc", "templates/default/lib/yourlib.core.js", "templates/default/README.rdoc", "templates/default/spec/spec.core.js", "templates/default/spec/spec.dom.html", "templates/default/spec/spec.rhino.js", "templates/default/spec/spec.server.html", "templates/rails/spec.application.js", "templates/rails/spec.dom.html", "templates/rails/spec.rhino.js", "templates/rails/spec.server.html"]
15
+ s.files = ["bin/jspec", "History.rdoc", "jspec.gemspec", "lib/images/bg.png", "lib/images/hr.png", "lib/images/loading.gif", "lib/images/sprites.bg.png", "lib/images/sprites.png", "lib/images/vr.png", "lib/jspec.css", "lib/jspec.jquery.js", "lib/jspec.js", "Manifest", "Rakefile", "README.rdoc", "server/browsers.rb", "server/server.rb", "spec/async", "spec/env.js", "spec/fixtures/test.html", "spec/fixtures/test.json", "spec/fixtures/test.xml", "spec/jquery-1.3.1.js", "spec/modules.js", "spec/spec.dom.html", "spec/spec.grammar-less.js", "spec/spec.grammar.js", "spec/spec.jquery.js", "spec/spec.js", "spec/spec.matchers.js", "spec/spec.modules.js", "spec/spec.node.js", "spec/spec.rhino.js", "spec/spec.server.html", "spec/spec.shared-behaviors.js", "spec/spec.utils.js", "templates/default/History.rdoc", "templates/default/lib/yourlib.core.js", "templates/default/README.rdoc", "templates/default/spec/spec.core.js", "templates/default/spec/spec.dom.html", "templates/default/spec/spec.rhino.js", "templates/default/spec/spec.server.html", "templates/rails/spec.application.js", "templates/rails/spec.dom.html", "templates/rails/spec.rhino.js", "templates/rails/spec.server.html"]
16
16
  s.homepage = %q{http://visionmedia.github.com/jspec}
17
17
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Jspec", "--main", "README.rdoc"]
18
18
  s.require_paths = ["lib"]
data/lib/jspec.js CHANGED
@@ -5,7 +5,8 @@
5
5
 
6
6
  JSpec = {
7
7
 
8
- version : '2.6.0',
8
+ version : '2.7.0',
9
+ cache : {},
9
10
  suites : [],
10
11
  modules : [],
11
12
  allSuites : [],
@@ -46,6 +47,21 @@
46
47
 
47
48
  an_instance_of : function(constructor) {
48
49
  return { an_instance_of : constructor }
50
+ },
51
+
52
+ fixture : function(path) {
53
+ if (JSpec.cache[path]) return JSpec.cache[path]
54
+ function tryLoading(path) {
55
+ try { return JSpec.load(path) }
56
+ catch (e) {}
57
+ }
58
+ return JSpec.cache[path] =
59
+ tryLoading(path) ||
60
+ tryLoading('fixtures/' + path) ||
61
+ tryLoading('fixtures/' + path + '.html') ||
62
+ tryLoading('spec/' + path) ||
63
+ tryLoading('spec/fixtures/' + path) ||
64
+ tryLoading('spec/fixtures/' + path + '.html')
49
65
  }
50
66
  },
51
67
 
@@ -0,0 +1 @@
1
+ <p>test</p>
@@ -0,0 +1 @@
1
+ { users : { tj : { email : 'tj@vision-media.ca' }}}
@@ -0,0 +1,5 @@
1
+ <users>
2
+ <user name="tj">
3
+ <email>tj@vision-media.ca</email>
4
+ </user>
5
+ </users>
data/spec/spec.utils.js CHANGED
@@ -255,4 +255,19 @@ describe 'Utility'
255
255
  JSpec.contentsOf(-{ return 'foo' }).should.include 'return', 'foo'
256
256
  end
257
257
  end
258
+
259
+ describe 'fixture()'
260
+ it 'should return a files contents'
261
+ fixture('fixtures/test.html').should.eql '<p>test</p>'
262
+ fixture('test.html').should.eql '<p>test</p>'
263
+ fixture('test').should.eql '<p>test</p>'
264
+ end
265
+
266
+ it 'should cache contents'
267
+ contents = fixture('test')
268
+ JSpec.cache['test'].should.eql contents
269
+ JSpec.cache['test'] = 'foo'
270
+ fixture('test').should.eql 'foo'
271
+ end
272
+ end
258
273
  end
@@ -1,5 +1,6 @@
1
1
 
2
2
  load('JSPEC_ROOT/lib/jspec.js')
3
+ load('lib/yourlib.core.js')
3
4
 
4
5
  JSpec
5
6
  .exec('spec/spec.core.js')
@@ -1,6 +1,7 @@
1
1
  <html>
2
2
  <head>
3
3
  <script src="jspec.js"></script>
4
+ <script src="../lib/yourlib.core.js"></script>
4
5
  <script>
5
6
  function runSuites() {
6
7
  JSpec
@@ -1,5 +1,6 @@
1
1
 
2
2
  load('JSPEC_ROOT/lib/jspec.js')
3
+ load('public/javascripts/application.js')
3
4
 
4
5
  JSpec
5
6
  .exec('spec/spec.application.js')
@@ -1,6 +1,7 @@
1
1
  <html>
2
2
  <head>
3
3
  <script src="jspec.js"></script>
4
+ <script src="../public/javascripts/application.js"></script>
4
5
  <script>
5
6
  function runSuites() {
6
7
  JSpec
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: visionmedia-jspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.0
4
+ version: 2.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - TJ Holowaychuk
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-07-09 00:00:00 -07:00
12
+ date: 2009-07-14 00:00:00 -07:00
13
13
  default_executable: jspec
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -70,6 +70,9 @@ files:
70
70
  - server/server.rb
71
71
  - spec/async
72
72
  - spec/env.js
73
+ - spec/fixtures/test.html
74
+ - spec/fixtures/test.json
75
+ - spec/fixtures/test.xml
73
76
  - spec/jquery-1.3.1.js
74
77
  - spec/modules.js
75
78
  - spec/spec.dom.html