visionmedia-jspec 1.1.5 → 1.1.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,9 @@
1
1
 
2
+ === 1.1.6 / 2009-04-22
3
+
4
+ * Fixed typo in requires()
5
+ * Added expect()
6
+
2
7
  === 1.1.5 / 2009-04-17
3
8
 
4
9
  * Strengthened specs for cascading hooks
data/bin/jspec CHANGED
@@ -10,7 +10,7 @@ require 'fileutils'
10
10
  RHINO = 'java org.mozilla.javascript.tools.shell.Main'
11
11
 
12
12
  program :name, 'JSpec'
13
- program :version, '1.1.5'
13
+ program :version, '1.1.6'
14
14
  program :description, 'JavaScript BDD Testing Framework'
15
15
  default_command :bind
16
16
 
@@ -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"
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-17}
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}
@@ -3,9 +3,9 @@
3
3
 
4
4
  (function(){
5
5
 
6
- JSpec = {
6
+ var JSpec = {
7
7
 
8
- version : '1.1.5',
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
- * Invoke a matcher.
527
+ * Perform an assertion.
528
528
  *
529
- * this.match('test', 'should', 'be_a', [String])
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 {object} actual
532
- * @param {bool, string} negate
533
- * @param {string} name
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
- match : function(actual, negate, name, expected) {
540
- if (typeof negate == 'string') negate = negate == 'should' ? false : true
541
- assertion = new JSpec.Assertion(this.matchers[name], actual, expected, negate)
542
- this.currentSpec.assertions.push(assertion.exec())
543
- return assertion.passed
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 JSpec.match($2, "$3", "$4", [$5]);')
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
- addMatchers = JSpec.addMatchers
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
+ })();
@@ -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.5
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-17 00:00:00 -07:00
12
+ date: 2009-04-22 00:00:00 -07:00
13
13
  default_executable: jspec
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency