jasmine-core 1.2.0.rc1 → 1.2.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
@@ -352,6 +352,33 @@ describe("jasmine.Matchers", function() {
352
352
  }]).toEqual(["a", jasmine.any(Function)])).toPass();
353
353
  });
354
354
 
355
+ describe("toEqual with an object implementing jasmineMatches", function () {
356
+ var matcher;
357
+ beforeEach(function () {
358
+ matcher = {
359
+ jasmineMatches: jasmine.createSpy("jasmineMatches")
360
+ };
361
+ });
362
+
363
+ describe("on the left side", function () {
364
+ it("uses the jasmineMatches function", function () {
365
+ matcher.jasmineMatches.andReturn(false);
366
+ expect(match(matcher).toEqual("foo")).toFail();
367
+ matcher.jasmineMatches.andReturn(true);
368
+ expect(match(matcher).toEqual("foo")).toPass();
369
+ });
370
+ });
371
+
372
+ describe("on the right side", function () {
373
+ it("uses the jasmineMatches function", function () {
374
+ matcher.jasmineMatches.andReturn(false);
375
+ expect(match("foo").toEqual(matcher)).toFail();
376
+ matcher.jasmineMatches.andReturn(true);
377
+ expect(match("foo").toEqual(matcher)).toPass();
378
+ });
379
+ });
380
+ });
381
+
355
382
  it("toEqual handles circular objects ok", function() {
356
383
  expect(match({foo: "bar", baz: jasmine.undefined}).toEqual({foo: "bar", baz: jasmine.undefined})).toPass();
357
384
  expect(match({foo:['bar','baz','quux']}).toEqual({foo:['bar','baz','quux']})).toPass();
@@ -830,6 +857,252 @@ describe("jasmine.Matchers", function() {
830
857
  });
831
858
  });
832
859
 
860
+ describe("ObjectContaining", function () {
861
+ describe("with an empty object", function () {
862
+ var containing;
863
+ beforeEach(function () {
864
+ containing = new jasmine.Matchers.ObjectContaining({});
865
+ });
866
+ it("matches everything", function () {
867
+ expect(containing.jasmineMatches("foo", [], [])).toBe(true);
868
+ });
869
+
870
+ it("says it didn't expect to contain anything", function () {
871
+ expect(containing.jasmineToString()).toEqual("<jasmine.objectContaining({ })>");
872
+ });
873
+ });
874
+
875
+ describe("with an object with items in it", function () {
876
+ var containing, mismatchKeys, mismatchValues;
877
+ beforeEach(function () {
878
+ mismatchKeys = [];
879
+ mismatchValues = [];
880
+ containing = new jasmine.Matchers.ObjectContaining({foo: "fooVal", bar: "barVal"});
881
+ });
882
+
883
+ it("doesn't match an empty object", function () {
884
+ expect(containing.jasmineMatches({}, mismatchKeys, mismatchValues)).toBe(false);
885
+ });
886
+
887
+ it("doesn't match an object with none of the specified options", function () {
888
+ expect(containing.jasmineMatches({baz:"stuff"}, mismatchKeys, mismatchValues)).toBe(false);
889
+ });
890
+
891
+ it("adds a message for each missing key", function () {
892
+ containing.jasmineMatches({foo: "fooVal"}, mismatchKeys, mismatchValues);
893
+ expect(mismatchKeys.length).toEqual(1);
894
+ });
895
+
896
+ it("doesn't match an object when the values are different", function () {
897
+ expect(containing.jasmineMatches({foo:"notFoo", bar:"notBar"}, mismatchKeys, mismatchValues)).toBe(false);
898
+ });
899
+
900
+ it("adds a message when values don't match", function () {
901
+ containing.jasmineMatches({foo: "fooVal", bar: "notBar"}, mismatchKeys, mismatchValues);
902
+ expect(mismatchValues.length).toEqual(1);
903
+ });
904
+
905
+ it("doesn't match an object with only one of the values matching", function () {
906
+ expect(containing.jasmineMatches({foo:"notFoo", bar:"barVal"}, mismatchKeys, mismatchValues)).toBe(false);
907
+ });
908
+
909
+ it("matches when all the values are the same", function () {
910
+ expect(containing.jasmineMatches({foo: "fooVal", bar: "barVal"}, mismatchKeys, mismatchValues)).toBe(true);
911
+ });
912
+
913
+ it("matches when there are additional values", function () {
914
+ expect(containing.jasmineMatches({foo: "fooVal", bar: "barVal", baz: "bazVal"}, mismatchKeys, mismatchValues)).toBe(true);
915
+ });
916
+
917
+ it("doesn't modify missingKeys or missingValues when match is successful", function () {
918
+ containing.jasmineMatches({foo: "fooVal", bar: "barVal"}, mismatchKeys, mismatchValues);
919
+ expect(mismatchKeys.length).toEqual(0);
920
+ expect(mismatchValues.length).toEqual(0);
921
+ });
922
+
923
+ it("says what it expects to contain", function () {
924
+ expect(containing.jasmineToString()).toEqual("<jasmine.objectContaining(" + jasmine.pp({foo:"fooVal", bar:"barVal"}) + ")>");
925
+ });
926
+ });
927
+
928
+ describe("in real life", function () {
929
+ var method;
930
+ beforeEach(function () {
931
+ method = jasmine.createSpy("method");
932
+ method({a:"b", c:"d"});
933
+ });
934
+ it("works correctly for positive matches", function () {
935
+ expect(method).toHaveBeenCalledWith(jasmine.objectContaining({a:"b"}));
936
+ });
937
+
938
+ it("works correctly for negative matches", function () {
939
+ expect(method).not.toHaveBeenCalledWith(jasmine.objectContaining({z:"x"}));
940
+ });
941
+ });
942
+ });
943
+
944
+ describe("Matchers.Any", function () {
945
+ var any;
946
+ describe(".jasmineToString", function () {
947
+ describe("with Object", function () {
948
+ it("says it's looking for an object", function () {
949
+ any = jasmine.any(Object);
950
+ expect(any.jasmineToString()).toMatch(/<jasmine\.any\(function Object.*\)>/);
951
+ });
952
+ });
953
+
954
+ describe("with Function", function () {
955
+ it("says it's looking for a function", function () {
956
+ any = jasmine.any(Function);
957
+ expect(any.jasmineToString()).toMatch(/<jasmine\.any\(function Function.*\)>/);
958
+ });
959
+ });
960
+
961
+ describe("with String", function () {
962
+ it("says it's looking for a string", function () {
963
+ any = jasmine.any(String);
964
+ expect(any.jasmineToString()).toMatch(/<jasmine\.any\(function String.*\)>/);
965
+ });
966
+ });
967
+
968
+ describe("with Number", function () {
969
+ it("says it's looking for a number", function () {
970
+ any = jasmine.any(Number);
971
+ expect(any.jasmineToString()).toMatch(/<jasmine\.any\(function Number.*\)>/);
972
+ });
973
+ });
974
+
975
+ describe("with some other defined 'class'", function () {
976
+ it("says it's looking for an object", function () {
977
+ function MyClass () {}
978
+ any = jasmine.any(MyClass);
979
+ expect(any.jasmineToString()).toMatch(/<jasmine\.any\(function MyClass.*\)>/);
980
+ });
981
+ });
982
+ });
983
+
984
+ describe(".jasmineMatches", function () {
985
+ describe("with Object", function () {
986
+ beforeEach(function () {
987
+ any = jasmine.any(Object);
988
+ });
989
+
990
+ it("matches an empty object", function () {
991
+ expect(any.jasmineMatches({})).toEqual(true);
992
+ });
993
+
994
+ it("matches a newed up object", function () {
995
+ expect(any.jasmineMatches(new Object())).toEqual(true);
996
+ });
997
+
998
+ it("doesn't match a string", function () {
999
+ expect(any.jasmineMatches("")).toEqual(false);
1000
+ });
1001
+
1002
+ it("doesn't match a number", function () {
1003
+ expect(any.jasmineMatches(123)).toEqual(false);
1004
+ });
1005
+
1006
+ it("doesn't match a function", function () {
1007
+ expect(any.jasmineMatches(function () {})).toEqual(false);
1008
+ });
1009
+ });
1010
+
1011
+ describe("with Function", function () {
1012
+ beforeEach(function () {
1013
+ any = jasmine.any(Function);
1014
+ });
1015
+
1016
+ it("doesn't match an object", function () {
1017
+ expect(any.jasmineMatches({})).toEqual(false);
1018
+ });
1019
+
1020
+ it("doesn't match a string", function () {
1021
+ expect(any.jasmineMatches("")).toEqual(false);
1022
+ });
1023
+
1024
+ it("doesn't match a number", function () {
1025
+ expect(any.jasmineMatches(123)).toEqual(false);
1026
+ });
1027
+
1028
+ it("matches a function", function () {
1029
+ expect(any.jasmineMatches(function () {})).toEqual(true);
1030
+ });
1031
+ });
1032
+
1033
+ describe("with Number", function () {
1034
+ beforeEach(function () {
1035
+ any = jasmine.any(Number);
1036
+ });
1037
+
1038
+ it("doesn't match an object", function () {
1039
+ expect(any.jasmineMatches({})).toEqual(false);
1040
+ });
1041
+
1042
+ it("doesn't match a string", function () {
1043
+ expect(any.jasmineMatches("")).toEqual(false);
1044
+ });
1045
+
1046
+ it("matches a number", function () {
1047
+ expect(any.jasmineMatches(123)).toEqual(true);
1048
+ });
1049
+
1050
+ it("doesn't match a function", function () {
1051
+ expect(any.jasmineMatches(function () {})).toEqual(false);
1052
+ });
1053
+ });
1054
+
1055
+ describe("with String", function () {
1056
+ beforeEach(function () {
1057
+ any = jasmine.any(String);
1058
+ });
1059
+
1060
+ it("doesn't match an object", function () {
1061
+ expect(any.jasmineMatches({})).toEqual(false);
1062
+ });
1063
+
1064
+ it("matches a string", function () {
1065
+ expect(any.jasmineMatches("")).toEqual(true);
1066
+ });
1067
+
1068
+ it("doesn't match a number", function () {
1069
+ expect(any.jasmineMatches(123)).toEqual(false);
1070
+ });
1071
+
1072
+ it("doesn't match a function", function () {
1073
+ expect(any.jasmineMatches(function () {})).toEqual(false);
1074
+ });
1075
+ });
1076
+
1077
+ describe("with some defined 'class'", function () {
1078
+ function MyClass () {}
1079
+ beforeEach(function () {
1080
+ any = jasmine.any(MyClass);
1081
+ });
1082
+
1083
+ it("doesn't match an object", function () {
1084
+ expect(any.jasmineMatches({})).toEqual(false);
1085
+ });
1086
+
1087
+ it("doesn't match a string", function () {
1088
+ expect(any.jasmineMatches("")).toEqual(false);
1089
+ });
1090
+
1091
+ it("doesn't match a number", function () {
1092
+ expect(any.jasmineMatches(123)).toEqual(false);
1093
+ });
1094
+
1095
+ it("doesn't match a function", function () {
1096
+ expect(any.jasmineMatches(function () {})).toEqual(false);
1097
+ });
1098
+
1099
+ it("matches an instance of the defined class", function () {
1100
+ expect(any.jasmineMatches(new MyClass())).toEqual(true);
1101
+ });
1102
+ });
1103
+ });
1104
+ });
1105
+
833
1106
  describe("all matchers", function() {
834
1107
  it("should return null, for future-proofing, since we might eventually allow matcher chaining", function() {
835
1108
  expect(match(true).toBe(true)).toBeUndefined();
@@ -83,5 +83,12 @@ describe("jasmine.pp", function () {
83
83
  expect(jasmine.pp(jasmine.createSpy("something"))).toEqual("spy on something");
84
84
  });
85
85
 
86
+ it("should stringify objects that implement jasmineToString", function () {
87
+ var obj = {
88
+ jasmineToString: function () { return "strung"; }
89
+ };
90
+
91
+ expect(jasmine.pp(obj)).toEqual("strung");
92
+ });
86
93
  });
87
94
 
@@ -44,8 +44,23 @@ describe("HtmlReporter", function() {
44
44
  expect(htmlReporter.specFilter(fakeSpec("not run this"))).toBeFalsy();
45
45
  });
46
46
 
47
- describe('Matcher reporting', function () {
48
- var getResultMessageDiv = function (body) {
47
+ describe("running without any specs", function() {
48
+ var runner;
49
+ beforeEach(function() {
50
+ runner = env.currentRunner();
51
+ env.addReporter(htmlReporter);
52
+ });
53
+
54
+ it("should not error", function() {
55
+ var exec = function() {
56
+ runner.execute();
57
+ };
58
+ expect(exec).not.toThrow();
59
+ });
60
+ });
61
+
62
+ describe('Matcher reporting', function() {
63
+ var getResultMessageDiv = function(body) {
49
64
  var divs = body.getElementsByTagName("div");
50
65
  for (var i = 0; i < divs.length; i++) {
51
66
  if (divs[i].className.match(/resultMessage/)) {
@@ -55,7 +70,7 @@ describe("HtmlReporter", function() {
55
70
  };
56
71
 
57
72
  var runner, spec, fakeTimer;
58
- beforeEach(function () {
73
+ beforeEach(function() {
59
74
  fakeTimer = new jasmine.FakeTimer();
60
75
  env.setTimeout = fakeTimer.setTimeout;
61
76
  env.clearTimeout = fakeTimer.clearTimeout;
@@ -70,9 +85,9 @@ describe("HtmlReporter", function() {
70
85
  env.addReporter(htmlReporter);
71
86
  });
72
87
 
73
- describe('toContain', function () {
74
- it('should show actual and expected', function () {
75
- spec.runs(function () {
88
+ describe('toContain', function() {
89
+ it('should show actual and expected', function() {
90
+ spec.runs(function() {
76
91
  this.expect('foo').toContain('bar');
77
92
  });
78
93
  runner.execute();
@@ -85,7 +100,7 @@ describe("HtmlReporter", function() {
85
100
  });
86
101
  });
87
102
 
88
- describe("failure messages (integration)", function () {
103
+ describe("failure messages (integration)", function() {
89
104
  var spec, results, expectationResult;
90
105
 
91
106
  it("should add the failure message to the DOM (non-toEquals matchers)", function() {
@@ -168,7 +183,7 @@ describe("HtmlReporter", function() {
168
183
  });
169
184
 
170
185
  describe('#reportSpecStarting', function() {
171
- beforeEach(function () {
186
+ beforeEach(function() {
172
187
  env.describe("suite 1", function() {
173
188
  env.it("spec 1", function() {
174
189
  });
@@ -1,5 +1,5 @@
1
1
  var fs = require('fs');
2
- var sys = require('sys');
2
+ var util = require('util');
3
3
  var path = require('path');
4
4
 
5
5
  // yes, really keep this here to keep us honest, but only for jasmine's own runner! [xw]
@@ -37,7 +37,7 @@ jasmine.executeSpecs = function(specs, done, isVerbose, showColors) {
37
37
  }
38
38
 
39
39
  var jasmineEnv = jasmine.getEnv();
40
- var consoleReporter = new jasmine.ConsoleReporter(sys.print, done, showColors);
40
+ var consoleReporter = new jasmine.ConsoleReporter(util.print, done, showColors);
41
41
 
42
42
  jasmineEnv.addReporter(consoleReporter);
43
43
  jasmineEnv.execute();
@@ -1,6 +1,6 @@
1
1
  module Jasmine
2
2
  module Core
3
- VERSION = "1.2.0.rc1"
3
+ VERSION = "1.2.0.rc2"
4
4
  end
5
5
  end
6
6
 
metadata CHANGED
@@ -1,73 +1,135 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: jasmine-core
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.2.0.rc2
4
5
  prerelease: 6
5
- version: 1.2.0.rc1
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Rajan Agaskar
9
- - Davis Frank
9
+ - Davis W. Frank
10
10
  - Christian Williams
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
-
15
- date: 2011-09-14 00:00:00 -04:00
16
- default_executable:
17
- dependencies:
18
- - !ruby/object:Gem::Dependency
19
- name: term-ansicolor
14
+ date: 2012-04-03 00:00:00.000000000Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: json_pure
18
+ requirement: &70301242145020 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ! '>='
22
+ - !ruby/object:Gem::Version
23
+ version: 1.4.3
24
+ type: :development
20
25
  prerelease: false
21
- requirement: &id001 !ruby/object:Gem::Requirement
26
+ version_requirements: *70301242145020
27
+ - !ruby/object:Gem::Dependency
28
+ name: frank
29
+ requirement: &70301242144600 !ruby/object:Gem::Requirement
22
30
  none: false
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: "0"
31
+ requirements:
32
+ - - ! '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
27
35
  type: :development
28
- version_requirements: *id001
29
- - !ruby/object:Gem::Dependency
30
- name: json_pure
31
36
  prerelease: false
32
- requirement: &id002 !ruby/object:Gem::Requirement
37
+ version_requirements: *70301242144600
38
+ - !ruby/object:Gem::Dependency
39
+ name: sass
40
+ requirement: &70301242144140 !ruby/object:Gem::Requirement
33
41
  none: false
34
- requirements:
35
- - - ">="
36
- - !ruby/object:Gem::Version
37
- version: 1.4.3
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
38
46
  type: :development
39
- version_requirements: *id002
40
- - !ruby/object:Gem::Dependency
41
- name: frank
42
47
  prerelease: false
43
- requirement: &id003 !ruby/object:Gem::Requirement
48
+ version_requirements: *70301242144140
49
+ - !ruby/object:Gem::Dependency
50
+ name: compass
51
+ requirement: &70301242180060 !ruby/object:Gem::Requirement
44
52
  none: false
45
- requirements:
46
- - - ">="
47
- - !ruby/object:Gem::Version
48
- version: "0"
53
+ requirements:
54
+ - - ! '>='
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
49
57
  type: :development
50
- version_requirements: *id003
51
- - !ruby/object:Gem::Dependency
58
+ prerelease: false
59
+ version_requirements: *70301242180060
60
+ - !ruby/object:Gem::Dependency
52
61
  name: ragaskar-jsdoc_helper
62
+ requirement: &70301242179640 !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ! '>='
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: *70301242179640
71
+ - !ruby/object:Gem::Dependency
72
+ name: rspec
73
+ requirement: &70301242179220 !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ type: :development
80
+ prerelease: false
81
+ version_requirements: *70301242179220
82
+ - !ruby/object:Gem::Dependency
83
+ name: fuubar
84
+ requirement: &70301242178800 !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ! '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: *70301242178800
93
+ - !ruby/object:Gem::Dependency
94
+ name: awesome_print
95
+ requirement: &70301242178380 !ruby/object:Gem::Requirement
96
+ none: false
97
+ requirements:
98
+ - - ! '>='
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ type: :development
102
+ prerelease: false
103
+ version_requirements: *70301242178380
104
+ - !ruby/object:Gem::Dependency
105
+ name: thor
106
+ requirement: &70301242177960 !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ! '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ type: :development
53
113
  prerelease: false
54
- requirement: &id004 !ruby/object:Gem::Requirement
114
+ version_requirements: *70301242177960
115
+ - !ruby/object:Gem::Dependency
116
+ name: nokogiri
117
+ requirement: &70301242177540 !ruby/object:Gem::Requirement
55
118
  none: false
56
- requirements:
57
- - - ">="
58
- - !ruby/object:Gem::Version
59
- version: "0"
119
+ requirements:
120
+ - - ! '>='
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
60
123
  type: :development
61
- version_requirements: *id004
62
- description: Test your JavaScript without any framework dependencies, in any environment, and with a nice descriptive syntax.
124
+ prerelease: false
125
+ version_requirements: *70301242177540
126
+ description: Test your JavaScript without any framework dependencies, in any environment,
127
+ and with a nice descriptive syntax.
63
128
  email: jasmine-js@googlegroups.com
64
129
  executables: []
65
-
66
130
  extensions: []
67
-
68
131
  extra_rdoc_files: []
69
-
70
- files:
132
+ files:
71
133
  - ./lib/jasmine-core/example/spec/PlayerSpec.js
72
134
  - ./lib/jasmine-core/example/spec/SpecHelper.js
73
135
  - ./lib/jasmine-core/example/SpecRunner.html
@@ -104,33 +166,29 @@ files:
104
166
  - ./lib/jasmine-core/spec/html/PrettyPrintHtmlSpec.js
105
167
  - ./lib/jasmine-core/spec/html/TrivialReporterSpec.js
106
168
  - ./lib/jasmine-core/spec/node_suite.js
107
- has_rdoc: true
108
169
  homepage: http://pivotal.github.com/jasmine
109
- licenses: []
110
-
170
+ licenses:
171
+ - MIT
111
172
  post_install_message:
112
173
  rdoc_options: []
113
-
114
- require_paths:
174
+ require_paths:
115
175
  - lib
116
- required_ruby_version: !ruby/object:Gem::Requirement
176
+ required_ruby_version: !ruby/object:Gem::Requirement
117
177
  none: false
118
- requirements:
119
- - - ">="
120
- - !ruby/object:Gem::Version
121
- version: "0"
122
- required_rubygems_version: !ruby/object:Gem::Requirement
178
+ requirements:
179
+ - - ! '>='
180
+ - !ruby/object:Gem::Version
181
+ version: '0'
182
+ required_rubygems_version: !ruby/object:Gem::Requirement
123
183
  none: false
124
- requirements:
125
- - - ">"
126
- - !ruby/object:Gem::Version
184
+ requirements:
185
+ - - ! '>'
186
+ - !ruby/object:Gem::Version
127
187
  version: 1.3.1
128
188
  requirements: []
129
-
130
189
  rubyforge_project: jasmine-core
131
- rubygems_version: 1.6.2
190
+ rubygems_version: 1.8.6
132
191
  signing_key:
133
192
  specification_version: 3
134
193
  summary: JavaScript BDD framework
135
194
  test_files: []
136
-