visionmedia-jspec 1.1.5 → 1.1.6
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 +5 -0
- data/bin/jspec +1 -1
- data/jspec.gemspec +2 -2
- data/lib/jspec.js +57 -37
- data/spec/spec.grammar.js +6 -0
- metadata +2 -2
data/History.rdoc
CHANGED
data/bin/jspec
CHANGED
data/jspec.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{jspec}
|
5
|
-
s.version = "1.1.
|
5
|
+
s.version = "1.1.6"
|
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-
|
9
|
+
s.date = %q{2009-04-22}
|
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}
|
data/lib/jspec.js
CHANGED
@@ -3,9 +3,9 @@
|
|
3
3
|
|
4
4
|
(function(){
|
5
5
|
|
6
|
-
JSpec = {
|
6
|
+
var JSpec = {
|
7
7
|
|
8
|
-
version : '1.1.
|
8
|
+
version : '1.1.6',
|
9
9
|
file : '',
|
10
10
|
suites : [],
|
11
11
|
matchers : {},
|
@@ -524,23 +524,40 @@
|
|
524
524
|
},
|
525
525
|
|
526
526
|
/**
|
527
|
-
*
|
527
|
+
* Perform an assertion.
|
528
528
|
*
|
529
|
-
*
|
529
|
+
* expect(true).to('be', true)
|
530
|
+
* expect('foo').not_to('include', 'bar')
|
531
|
+
* expect([1, [2]]).to('include', 1, [2])
|
530
532
|
*
|
531
|
-
* @param {
|
532
|
-
* @
|
533
|
-
* @
|
534
|
-
* @param {array} expected
|
535
|
-
* @return {bool}
|
536
|
-
* @api private
|
533
|
+
* @param {mixed} actual
|
534
|
+
* @return {hash}
|
535
|
+
* @api public
|
537
536
|
*/
|
538
537
|
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
538
|
+
expect : function(actual) {
|
539
|
+
assert = function(name, args, negate) {
|
540
|
+
expected = []
|
541
|
+
for (i = 1; i < args.length; i++) expected.push(args[i])
|
542
|
+
assertion = new JSpec.Assertion(JSpec.matchers[name], actual, expected, negate)
|
543
|
+
JSpec.currentSpec.assertions.push(assertion.exec())
|
544
|
+
return assertion.passed
|
545
|
+
}
|
546
|
+
|
547
|
+
to = function(name) {
|
548
|
+
return assert(name, arguments, false)
|
549
|
+
}
|
550
|
+
|
551
|
+
not_to = function(name) {
|
552
|
+
return assert(name, arguments, true)
|
553
|
+
}
|
554
|
+
|
555
|
+
return {
|
556
|
+
to : to,
|
557
|
+
should : to,
|
558
|
+
not_to: not_to,
|
559
|
+
should_not : not_to,
|
560
|
+
}
|
544
561
|
},
|
545
562
|
|
546
563
|
/**
|
@@ -723,7 +740,9 @@
|
|
723
740
|
replace(/(\d+)\.\.(\d+)/g, function(_, a, b){ return range(a, b) }).
|
724
741
|
replace(/([\s\(]+)\./gm, '$1this.').
|
725
742
|
replace(/\.should([_\.]not)?[_\.](\w+)(?: |$)(.*)$/gm, '.should$1_$2($3)').
|
726
|
-
replace(/([\/ ]*)(.+?)\.(should(?:[_\.]not)?)[_\.](\w+)\((.*)\)$/gm, '$1
|
743
|
+
replace(/([\/ ]*)(.+?)\.(should(?:[_\.]not)?)[_\.](\w+)\((.*)\)$/gm, '$1 expect($2).$3("$4", $5)').
|
744
|
+
replace(/, \)/gm, ')').
|
745
|
+
replace(/should\.not/gm, 'should_not')
|
727
746
|
},
|
728
747
|
|
729
748
|
/**
|
@@ -836,7 +855,7 @@
|
|
836
855
|
|
837
856
|
requires : function(dependency, message) {
|
838
857
|
try { eval(dependency) }
|
839
|
-
catch (e) { error('JSpec depends on ' + dependency + ' ' + message
|
858
|
+
catch (e) { error('JSpec depends on ' + dependency + ' ' + message) }
|
840
859
|
},
|
841
860
|
|
842
861
|
/**
|
@@ -959,25 +978,26 @@
|
|
959
978
|
|
960
979
|
// --- Utility functions
|
961
980
|
|
962
|
-
main = this
|
963
|
-
puts = print
|
964
|
-
map = JSpec.map
|
965
|
-
any = JSpec.any
|
966
|
-
last = JSpec.last
|
967
|
-
fail = JSpec.fail
|
968
|
-
range = JSpec.range
|
969
|
-
each = JSpec.each
|
970
|
-
option = JSpec.option
|
971
|
-
inject = JSpec.inject
|
972
|
-
error = JSpec.error
|
973
|
-
escape = JSpec.escape
|
974
|
-
extend = JSpec.extend
|
975
|
-
print = JSpec.print
|
976
|
-
hash = JSpec.hash
|
977
|
-
query = JSpec.query
|
978
|
-
strip = JSpec.strip
|
979
|
-
color = JSpec.color
|
980
|
-
|
981
|
+
var main = this
|
982
|
+
var puts = print
|
983
|
+
var map = JSpec.map
|
984
|
+
var any = JSpec.any
|
985
|
+
var last = JSpec.last
|
986
|
+
var fail = JSpec.fail
|
987
|
+
var range = JSpec.range
|
988
|
+
var each = JSpec.each
|
989
|
+
var option = JSpec.option
|
990
|
+
var inject = JSpec.inject
|
991
|
+
var error = JSpec.error
|
992
|
+
var escape = JSpec.escape
|
993
|
+
var extend = JSpec.extend
|
994
|
+
var print = JSpec.print
|
995
|
+
var hash = JSpec.hash
|
996
|
+
var query = JSpec.query
|
997
|
+
var strip = JSpec.strip
|
998
|
+
var color = JSpec.color
|
999
|
+
var expect = JSpec.expect
|
1000
|
+
var addMatchers = JSpec.addMatchers
|
981
1001
|
|
982
1002
|
// --- Matchers
|
983
1003
|
|
@@ -1081,4 +1101,4 @@
|
|
1081
1101
|
|
1082
1102
|
this.JSpec = JSpec
|
1083
1103
|
|
1084
|
-
})();
|
1104
|
+
})();
|
data/spec/spec.grammar.js
CHANGED
@@ -28,6 +28,12 @@ describe 'Grammar'
|
|
28
28
|
-{ throw 'test' }.should.throw_error
|
29
29
|
end
|
30
30
|
|
31
|
+
it 'should allow grammar-less assertions'
|
32
|
+
expect(true).to('be', true)
|
33
|
+
expect([1,2,3]).to('include', 1, 2, 3)
|
34
|
+
expect(true).not_to('be', false)
|
35
|
+
end
|
36
|
+
|
31
37
|
it 'should allow commenting out of conversions'
|
32
38
|
// -{ throw 'foo' }.should.throw_error
|
33
39
|
// foo.should.not.eql 'bar'
|
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: 1.1.
|
4
|
+
version: 1.1.6
|
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-04-
|
12
|
+
date: 2009-04-22 00:00:00 -07:00
|
13
13
|
default_executable: jspec
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|