visionmedia-jspec 1.1.3 → 1.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,37 @@
1
1
 
2
+ === 1.1.4 / 2009-04-17
3
+
4
+ * Added rhino and server template files
5
+ * Added JSpec.hasXhr()
6
+ * Added JSpec.xhr()
7
+ * Added Ruby javascript testing server
8
+ * Added support for options passed to run()
9
+ * Added failuresOnly for Terminal formatter
10
+ * Added terminal assertion graphs
11
+ * Addec color() utility
12
+ * Added main.puts() since we use print() as a utility
13
+ * Added rhino support
14
+ * Added fail() utility function
15
+ * Added JSpec.Assertion
16
+ * Added normalizeMatcherMessage()
17
+ * Added normalizeMatcherBody()
18
+ * Added have_classes [#19]
19
+ * Added extend() utility
20
+ * Added be_an_instance_of matcher
21
+ * Added constructor checking support for throw_error matcher [#72]
22
+ * Added file support for exception messages, making them much easier to debug
23
+ * Added catching of exceptions throw within specs [#46]
24
+ * Changed; executable aborts when template does not exist
25
+ * Changed; matchers now normalized upon creation, accepts function, hash, or string.
26
+ * Changed be() matcher to be strict [#57]
27
+ * Changed error() to conditionally show line number when available
28
+ * Renamed Jspec.addSuite to JSpec.describe and Suite#addSpec to Suite#it
29
+ * Refactored be_a_TYPE_input matchers so that the deprication warning is logged only when calling the method
30
+ * Fixed JSpec.requires() now works with latest version of JSpec.error()
31
+ * Fixed error() now displays exceptions throw that do not respond to .message
32
+ * Fixed commenting bug [#37]
33
+ * Removed JSpec.main, now just using local main
34
+
2
35
  === 1.1.3 / 2009-04-14
3
36
 
4
37
  * Removed /test used for the executable, causing gem to fail building
data/Manifest CHANGED
@@ -12,15 +12,29 @@ lib/jspec.js
12
12
  Manifest
13
13
  Rakefile
14
14
  README.rdoc
15
+ server/browsers.rb
16
+ server/server.rb
15
17
  spec/async
16
18
  spec/jquery-1.3.1.js
19
+ spec/server.html
17
20
  spec/spec.core.dom.js
18
21
  spec/spec.core.js
19
22
  spec/spec.grammar.js
20
23
  spec/spec.html
21
24
  spec/spec.jquery.js
25
+ spec/spec.rhino.js
22
26
  templates/default/History.rdoc
23
27
  templates/default/lib/yourlib.core.js
24
28
  templates/default/README.rdoc
25
29
  templates/default/spec/spec.core.js
26
30
  templates/default/spec/spec.html
31
+ templates/rhino/History.rdoc
32
+ templates/rhino/lib/yourlib.core.js
33
+ templates/rhino/README.rdoc
34
+ templates/rhino/spec/spec.core.js
35
+ templates/rhino/spec/spec.js
36
+ templates/server/History.rdoc
37
+ templates/server/lib/yourlib.core.js
38
+ templates/server/README.rdoc
39
+ templates/server/spec/spec.core.js
40
+ templates/server/spec/spec.html
@@ -8,15 +8,17 @@ and much more.
8
8
 
9
9
  == Features
10
10
 
11
- * Sexiest syntax of them all
11
+ * Highly readable
12
12
  * Framework / DOM independent
13
+ * Rhino support
14
+ * Async support
15
+ * Ruby JavaScript testing server
13
16
  * Nested describes
14
17
  * Does not pollute core object prototypes
15
- * Async support
16
18
  * Extremely simple and intuitive matcher declaration
17
19
  * Over 45 core matchers
18
20
  * Allows parens to be optional when using matchers to increase readability
19
- * Several helpful formatters (dom, console, terminal, ...)
21
+ * Several helpful formatters (DOM, Console, Terminal, ...)
20
22
  * Assertion graphs displaying how many, and which assertions pass or failed
21
23
  * Default / customizable evaluation contexts
22
24
  * DOM sandbox support
@@ -25,6 +27,13 @@ and much more.
25
27
  * Profiling
26
28
  * Tiny (15 kb compressed, 1000-ish LOC)
27
29
 
30
+ == Features Coming Soon
31
+
32
+ * 'Spy' or 'Proxy' assertions. person.should.receive('addPet').with('suki').and_return(['suki'])
33
+ * Grammar-less option. Dislike JSpec's grammar? well we will soon have grammar-less support,
34
+ which in turn will make your specs look much like traditional JavaScript BDD frameworks:
35
+ expect(this).to('be_coming', 'soon')
36
+
28
37
  == Example
29
38
 
30
39
  describe 'ShoppingCart'
@@ -54,8 +63,8 @@ and much more.
54
63
  Simply download JSpec and include JSpec.css and JSpec.js in your markup.
55
64
  Head over to the downloads section on Github, clone this public repo, or
56
65
  add JSpec as a git submodule with in your project. Alternatively JSpec is
57
- also available as a Ruby Gem, which also provides the `jspec` executable. To
58
- install as a gem simply:
66
+ also available as a Ruby Gem (though this is not required), which also
67
+ provides the `jspec` executable. To install as a gem simply:
59
68
  $ sudo gem install visionmedia-jspec
60
69
 
61
70
  At which point you may:
@@ -70,7 +79,7 @@ loaded using the exec method. Below is an example:
70
79
  JSpec
71
80
  .exec('spec.core.js')
72
81
  .exec('spec.jquery.js')
73
- .run()
82
+ .run({ failuresOnly : true })
74
83
  .report()
75
84
  }
76
85
  </script>
@@ -84,44 +93,45 @@ each release.
84
93
  == Options
85
94
 
86
95
  You may alter the way JSpec operates by assigning options via the
87
- JSpec.options hash, or by passing string-based option values via the
88
- query string. For example JSpec.options.failuresOnly = true, and ?failuresOnly=1
89
- will both work.
96
+ JSpec.options hash, by passing string-based option values via the
97
+ query string, or passing a hash to run(). For example
98
+ JSpec.options.failuresOnly = true, and ?failuresOnly=1 will both work.
90
99
 
91
- * profile {bool} when enabled, uses console.time() in order to display performance information in your console log as specs are completed.
92
- * failuresOnly {bool} displays only failing specs, making them quick to discover and fix
93
- * reportToId {string} an element id to report to when using the DOM formatter
100
+ * profile {bool} when enabled, uses console.time() in order to display performance information in your console log as specs are completed. (DOM, Console)
101
+ * failuresOnly {bool} displays only failing specs, making them quick to discover and fix (DOM, Terminal)
102
+ * reportToId {string} an element id to report to when using the DOM formatter (DOM)
94
103
 
95
104
  == Matchers
96
105
 
97
106
  * Core
98
107
 
99
- - equal ===
100
- - be_a, be_an have constructor of x
101
- - be_at_least >=
102
- - be_at_most <=
103
- - be_null == null
104
- - be_empty length of 0
105
- - be_true == true
106
- - be_false == false
107
- - be_type be type of x
108
- - be_greater_than >
109
- - be_less_than <
110
- - throw_error should throw an error, optionally supply the error string for comparison
111
- - have object should have n of property (person.should.have(2, 'pets'))
112
- - have_at_least object should have at least n of property
113
- - have_at_most object should have a maximum n of property
114
- - have_within object should have within n..n of property (person.should.have_within(1..3, 'pets')
115
- - have_length length of n
116
- - have_prop object should have property x, optionally supplying an expected value
117
- - have_property strict version of have_prop
118
- - be_within checks if n is within the range passed
119
- - include include substring, array element, or hash key
120
- - match string should match regexp x
121
- - respond_to property x should be a function
122
- - eql, be matches simple literals (strings, numbers) with == .
123
- However composites like arrays or 'hashes' are recursively matched,
124
- meaning that [1, 2, [3]].should_eql([1, 2, [3]]) will be true.
108
+ - equal, be ===
109
+ - be_a, be_an have constructor of x
110
+ - be_an_instance_of instanceof x
111
+ - be_at_least >=
112
+ - be_at_most <=
113
+ - be_null == null
114
+ - be_empty length of 0
115
+ - be_true == true
116
+ - be_false == false
117
+ - be_type be type of x
118
+ - be_greater_than >
119
+ - be_less_than <
120
+ - throw_error should throw an error, optionally supply the error string for comparison
121
+ - have object should have n of property (person.should.have(2, 'pets'))
122
+ - have_at_least object should have at least n of property
123
+ - have_at_most object should have a maximum n of property
124
+ - have_within object should have within n..n of property (person.should.have_within(1..3, 'pets')
125
+ - have_length length of n
126
+ - have_prop object should have property x, optionally supplying an expected value
127
+ - have_property strict version of have_prop
128
+ - be_within checks if n is within the range passed
129
+ - include include substring, array element, or hash key
130
+ - match string should match regexp x
131
+ - respond_to property x should be a function
132
+ - eql matches simple literals (strings, numbers) with ==
133
+ However composites like arrays or 'hashes' are recursively matched,
134
+ meaning that [1, 2, [3]].should_eql([1, 2, [3]]) will be true.
125
135
 
126
136
  * jQuery
127
137
 
@@ -294,21 +304,16 @@ Another option is to declare a variable outside of the spec closures:
294
304
  == Formatters
295
305
 
296
306
  To change a formatter simply alter the options hash like below, assigning
297
- a new constructor:
307
+ a new constructor, or pass it within the hash to run():
298
308
 
299
309
  JSpec.options.formatter = JSpec.formatters.Console
300
310
 
301
- === DOM
302
-
303
- Clean attractive HTML reporting
304
-
305
- === Console
311
+ OR
306
312
 
307
- Reporting utilizing the console object (tested using Firebug and Safari 4)
308
-
309
- === Terminal
310
-
311
- Coming soon
313
+ JSpec
314
+ .exec('...')
315
+ .run({ formatter : JSpec.formatters.Terminal })
316
+ .report()
312
317
 
313
318
  == Custom Matchers
314
319
 
@@ -376,14 +381,53 @@ For additional usage execute:
376
381
  Or for specific usage:
377
382
  $ jspec help run
378
383
 
384
+ == Rhino
385
+
386
+ JSpec provides transparent support for Rhino, while using the Terminal formatter.
387
+ Simply create a JavaScript file with contents similar to below, and then execute
388
+ the command following it:
389
+
390
+ load('lib/jspec.js')
391
+
392
+ JSpec
393
+ .exec('spec/spec.grammar.js')
394
+ .exec('spec/spec.core.js')
395
+ .run({ formatter : JSpec.formatters.Terminal, failuresOnly : true })
396
+ .report()
397
+
398
+ Initialize project with:
399
+ $ jspec init myproject --template rhino
400
+
401
+ Run with:
402
+ $ jspec run --rhino
403
+
404
+ Or bind (automated testing):
405
+ $ jspec --rhino
406
+
407
+ == Server
408
+
409
+ The Ruby JavaScript testing server included with JSpec simply runs
410
+ the spec suites within each browser you specify, while reporting result
411
+ back to the terminal. It is essentially the same as using the DOM formatter
412
+ and auto-testing each browser, however results are centralized to the terminal,
413
+ removing the need to manually view each browser's output.
414
+
415
+ Initialize project with:
416
+ $ jspec init myproject --template server
417
+
418
+ Run with:
419
+ $ jspec run --server
420
+
379
421
  == More Information
380
422
 
381
423
  * Syntax comparison with other frameworks http://gist.github.com/92283
382
-
383
424
  * Get the TextMate bundle at https://github.com/visionmedia/jspec.tmbundle/tree
384
-
385
425
  * For more information consult the JSpec source code documentation or visit http://visionmedia.github.com/jspec
386
426
 
427
+ == Known Issues
428
+
429
+ * Opera likes to break for various reasons ... we are working on fixing these compat issues
430
+
387
431
  == License
388
432
 
389
433
  (The MIT License)
data/bin/jspec CHANGED
@@ -1,32 +1,53 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ JSPEC_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
4
+ $:.unshift JSPEC_ROOT
5
+
3
6
  require 'rubygems'
4
7
  require 'commander'
5
8
  require 'fileutils'
6
9
 
7
- JSPEC_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
10
+ RHINO = 'java org.mozilla.javascript.tools.shell.Main'
8
11
 
9
12
  program :name, 'JSpec'
10
- program :version, '1.1.3'
13
+ program :version, '1.1.4'
11
14
  program :description, 'JavaScript BDD Testing Framework'
12
15
  default_command :bind
13
16
 
14
17
  command :init do |c|
15
18
  c.syntax = 'jspec init [dest]'
16
19
  c.summary = 'Initialize a JSpec project template'
17
- c.description = 'Initialize a JSpec project template. Defaults to the current directory when
18
- <dest> is not specified.'
20
+ c.description = 'Initialize a JSpec project template. Defaults to the current directory
21
+ when [dest] is not specified. Currently three templates are available:
22
+
23
+ "default" : runs specs in browser(s) using the DOM formatter.
24
+ "rhino" : runs specs with Rhino using the Terminal formatter.
25
+ "server" : runs specs using a Ruby server/client solution which
26
+ starts each browser and reports back to the terminal.'
19
27
  c.example 'Create a directory foo, initialized with a jspec template', 'jspec init foo'
28
+ c.example 'Initialize a rhino based project in the current directory', 'jspec init --template rhino'
29
+ c.example 'Initialize a server based project in foo', 'jspec init foo --template server'
30
+ c.option '-T', '--template name', 'Template to use. Valid choices are default, rhino, and server.'
20
31
  c.when_called do |args, options|
21
32
  dest = args.shift || '.'
33
+ options.default :template => 'default'
22
34
  unless Dir[dest + '/*'].empty?
23
35
  abort unless agree "'#{dest}' is not empty; continue? "
24
36
  end
37
+ template = File.join JSPEC_ROOT, 'templates', options.template, '.'
38
+ abort "template #{options.template} does not exist" unless File.exists? template
25
39
  FileUtils.mkdir_p dest
26
- FileUtils.cp_r File.join(JSPEC_ROOT, 'templates', 'default', '.'), dest
27
- spec = File.join dest, 'spec', 'spec.html'
28
- contents = File.read(spec).gsub 'JSPEC_ROOT', JSPEC_ROOT
29
- File.open(spec, 'w') { |file| file.write contents }
40
+ FileUtils.cp_r template, dest
41
+ path = case options.template
42
+ when 'default' ; 'spec.html'
43
+ when 'rhino' ; 'spec.js'
44
+ else
45
+ end
46
+ if path
47
+ spec = File.join dest, 'spec', path
48
+ contents = File.read(spec).gsub 'JSPEC_ROOT', JSPEC_ROOT
49
+ File.open(spec, 'w') { |file| file.write contents }
50
+ end
30
51
  say "Template initialized at '#{dest}'"
31
52
  end
32
53
  end
@@ -36,7 +57,9 @@ command :update do |c|
36
57
  c.summary = 'Update JSpec releases'
37
58
  c.description = 'Update JSpec release in [paths], this will allow you to utilize the latest
38
59
  JSpec features. If you have suites running at a path other than the regular
39
- spec/spec.html simply pass them as arguments to this sub-command.'
60
+ spec/spec.html simply pass them as arguments to this sub-command.
61
+
62
+ This is only needed when using the default, or rhino project templates.'
40
63
  c.when_called do |args, options|
41
64
  args = %w( spec/spec.html ) if args.empty?
42
65
  args.each do |path|
@@ -54,30 +77,61 @@ command :run do |c|
54
77
  c.description = 'Run specifications, defaulting [path] to spec/spec.html. You will need
55
78
  supply [path] if your specs do not reside in this location. `run --bind` is
56
79
  the default sub-command of jspec so you may simply execute `jspec` in order
57
- to bind execution of your specs when a file is altered.'
80
+ to bind execution of your specs when a file is altered.
81
+
82
+ JSpec supports Rhino execution when installed. The [path] is assumed to be
83
+ spec/spec.js unless specified. See examples below for using the --rhino switch.'
58
84
  c.example 'Run once in Safari', 'jspec run'
59
85
  c.example 'Run once in Safari and Firefox', 'jspec run --browsers Safari,Firefox'
60
86
  c.example 'Run custom spec file', 'jspec run foo.html'
61
- c.example 'Auto-refresh browsers when a file is altered', 'jspec run --bind --browsers Safari,Firefox'
87
+ c.example 'Auto-run browsers when a file is altered', 'jspec run --bind --browsers Safari,Firefox'
62
88
  c.example 'Shortcut for the previous example', 'jspec --browsers Safari,Firefox'
89
+ c.example 'Auto-run rhino when a file is altered', 'jspec --rhino'
90
+ c.example 'Run Rhino specs once', 'jspec run --rhino'
63
91
  c.option '-b', '--browsers BROWSERS', Array, 'Specify browsers to test, defaults to Safari'
64
92
  c.option '-p', '--paths PATHS', Array, 'Specify paths when binding, defaults to javascript within ./lib and ./spec'
65
93
  c.option '-B', '--bind', 'Auto-run specs when source files or specs are altered'
94
+ c.option '-R', '--rhino', 'Run specs using Rhino'
95
+ c.option '-S', '--server', 'Run specs using the JSpec server'
96
+ c.option '-s', '--server-only', 'Start JSpec server without running browsers'
66
97
  c.when_called do |args, options|
67
98
  begin
68
99
  require 'bind'
69
- spec = args.shift || 'spec/spec.html'
70
100
  options.default :browsers => %w( Safari ), :paths => ['lib/**/*.js', 'spec/**/*.js']
71
- action = Bind::Actions::RefreshBrowsers.new spec, *options.browsers
101
+
102
+ # Actions
103
+ if options.rhino
104
+ spec = args.shift || 'spec/spec.js'
105
+ action = lambda { rhino spec }
106
+ elsif options.server
107
+ spec = args.shift || 'spec/spec.html'
108
+ action = lambda { start_server options, spec }
109
+ else
110
+ spec = args.shift || 'spec/spec.html'
111
+ action = Bind::Actions::RefreshBrowsers.new spec, *options.browsers
112
+ end
113
+
114
+ # Binding
72
115
  if options.bind
73
116
  listener = Bind::Listener.new :paths => options.paths, :interval => 1, :actions => [action], :debug => $stdout
74
117
  listener.run!
75
118
  else
76
- action.call spec
119
+ action.call File.new(spec)
77
120
  end
121
+
78
122
  rescue LoadError
79
123
  abort "jspec run requires the visionmedia-bind gem; http://visionmedia.github.com/bind/"
80
124
  end
81
125
  end
82
126
  end
83
127
  alias_command :bind, :run, '--bind'
128
+
129
+ def rhino file
130
+ abort "#{file} not found" unless File.exists? file
131
+ system "#{RHINO} #{file}"
132
+ end
133
+
134
+ def start_server options, spec
135
+ require 'server/server'
136
+ JSpec::Server.start options, spec
137
+ end
@@ -2,17 +2,17 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{jspec}
5
- s.version = "1.1.3"
5
+ s.version = "1.1.4"
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-04-14}
9
+ s.date = %q{2009-04-17}
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/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/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", "spec/async", "spec/jquery-1.3.1.js", "spec/spec.core.dom.js", "spec/spec.core.js", "spec/spec.grammar.js", "spec/spec.html", "spec/spec.jquery.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.html"]
15
+ s.files = ["bin/jspec", "History.rdoc", "jspec.gemspec", "lib/images/bg.png", "lib/images/hr.png", "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/jquery-1.3.1.js", "spec/server.html", "spec/spec.core.dom.js", "spec/spec.core.js", "spec/spec.grammar.js", "spec/spec.html", "spec/spec.jquery.js", "spec/spec.rhino.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.html", "templates/rhino/History.rdoc", "templates/rhino/lib/yourlib.core.js", "templates/rhino/README.rdoc", "templates/rhino/spec/spec.core.js", "templates/rhino/spec/spec.js", "templates/server/History.rdoc", "templates/server/lib/yourlib.core.js", "templates/server/README.rdoc", "templates/server/spec/spec.core.js", "templates/server/spec/spec.html"]
16
16
  s.has_rdoc = true
17
17
  s.homepage = %q{http://visionmedia.github.com/jspec}
18
18
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Jspec", "--main", "README.rdoc"]
@@ -1,68 +1,74 @@
1
1
 
2
2
  // JSpec - jQuery - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)
3
3
 
4
- (function($, $$){
4
+ (function(){
5
5
 
6
6
  // --- Dependencies
7
7
 
8
- $$.requires('jQuery', 'when using jspec.jquery.js')
8
+ JSpec.requires('jQuery', 'when using jspec.jquery.js')
9
9
 
10
10
  // --- Async Support
11
11
 
12
- $.ajaxSetup({ async : false })
12
+ jQuery.ajaxSetup({ async : false })
13
13
 
14
14
  // --- Helpers
15
15
 
16
- $$.defaultContext.element = $
17
- $$.defaultContext.elements = $
18
- $$.defaultContext.defaultSandbox = $$.defaultContext.sandbox
19
- $$.defaultContext.sandbox = function() { return $($$.defaultContext.defaultSandbox()) }
16
+ JSpec.defaultContext.element = jQuery
17
+ JSpec.defaultContext.elements = jQuery
18
+ JSpec.defaultContext.defaultSandbox = JSpec.defaultContext.sandbox
19
+ JSpec.defaultContext.sandbox = function() { return jQuery(JSpec.defaultContext.defaultSandbox()) }
20
20
 
21
21
  // --- Matchers
22
22
 
23
- $$.addMatchers({
23
+ JSpec.addMatchers({
24
24
  have_tag : "jQuery(expected, actual).length == 1",
25
25
  have_one : "alias have_tag",
26
26
  have_tags : "jQuery(expected, actual).length > 1",
27
27
  have_many : "alias have_tags",
28
28
  have_child : "jQuery(actual).children(expected).length == 1",
29
29
  have_children : "jQuery(actual).children(expected).length > 1",
30
- have_class : "jQuery(actual).hasClass(expected)",
31
30
  have_text : "jQuery(actual).text() == expected",
32
31
  have_value : "jQuery(actual).val() == expected",
33
32
  be_visible : "!jQuery(actual).is(':hidden')",
34
33
  be_hidden : "jQuery(actual).is(':hidden')",
35
34
  be_enabled : "!jQuery(actual).attr('disabled')",
35
+ have_class : "jQuery(actual).hasClass(expected)",
36
36
 
37
- have_attr : { match : function(actual, attr, value) {
38
- if (value) return $(actual).attr(attr) == value
39
- else return $(actual).attr(attr)
40
- }
37
+ have_classes : function(actual) {
38
+ for (i = 1; i < arguments.length; i++)
39
+ if (!jQuery(actual).hasClass(arguments[i])) return false
40
+ return true
41
+ },
42
+
43
+ have_attr : function(actual, attr, value) {
44
+ return value ? jQuery(actual).attr(attr) == value:
45
+ jQuery(actual).attr(attr)
41
46
  }
42
47
  })
43
48
 
44
49
  // --- be_BOOLATTR
45
50
 
46
- $$.each('disabled selected checked', function(attr){
47
- $$.matchers['be_' + attr] = "jQuery(actual).attr('" + attr + "')"
51
+ JSpec.each('disabled selected checked', function(attr){
52
+ JSpec.addMatcher('be_' + attr, "jQuery(actual).attr('" + attr + "')")
48
53
  })
49
54
 
50
55
  // --- have_ATTR
51
56
 
52
- $$.each('type id title alt href src rel rev name target', function(attr){
53
- $$.matchers['have_' + attr] = { match : function(actual, value) {
54
- return $$.matchers.have_attr.match(actual, attr, value)
55
- }
56
- }
57
+ JSpec.each('type id title alt href src rel rev name target', function(attr){
58
+ JSpec.addMatcher('have_' + attr, function(actual, value) {
59
+ return JSpec.matchers.have_attr.match(actual, attr, value)
60
+ })
57
61
  })
58
62
 
59
63
  // --- be_a_TYPE_input (deprecated)
60
64
 
61
- $$.each('checkbox radio file password submit image text reset button', function(type){
62
- console.warn("be_a_" + type + "_input is deprected; use have_type('" + type + "')");
63
- JSpec.matchers['be_a_' + type + '_input'] = "jQuery(actual).get(0).type == '" + type + "'"
65
+ JSpec.each('checkbox radio file password submit image text reset button', function(type){
66
+ JSpec.addMatcher('be_a_' + type + '_input', function(actual, expected) {
67
+ console.warn("be_a_" + type + "_input is deprected; use have_type('" + type + "')");
68
+ return jQuery(actual).get(0).type == type
69
+ })
64
70
  })
65
71
 
66
- })(jQuery, JSpec)
72
+ })()
67
73
 
68
74