Commit 47eff271 47eff271d0d8d7747b2bc010533303ada34b3ff3 by Julian Gruber

added assertNotEquals, the inverse of assertEquals

1 parent 51a03f65
...@@ -143,6 +143,41 @@ var Tester = function Tester(casper, options) { ...@@ -143,6 +143,41 @@ var Tester = function Tester(casper, options) {
143 }; 143 };
144 144
145 /** 145 /**
146 * Asserts that two values are strictly not equals.
147 *
148 * @param Mixed subject The value to test
149 * @param Mixed expected The unwanted value
150 * @param String message Test description
151 */
152
153 this.assertNotEquals = function assertNotEquals(subject, shouldnt, message) {
154 var eventName;
155 message = message || "";
156 if (!this.testEquals(subject, shouldnt)) {
157 eventName = "success";
158 casper.echo(this.colorize(this.options.passText, 'INFO') + ' ' + this.formatMessage(message));
159 this.testResults.passed++;
160 } else {
161 eventName = "fail";
162 casper.echo(this.colorize(this.options.failText, 'RED_BAR') + ' ' + this.formatMessage(message, 'WARNING'));
163 this.comment(' got: ' + utils.serialize(subject));
164 this.comment(' shouldnt: ' + utils.serialize(shouldnt));
165 this.testResults.failed++;
166 }
167 this.emit(eventName, {
168 type: "assertNotEquals",
169 message: message,
170 details: f("test failed; shouldnt: %s; got: %s", shouldnt, subject),
171 file: this.currentTestFile,
172 values: {
173 subject: subject,
174 shouldnt: shouldnt
175 }
176 });
177 };
178
179
180 /**
146 * Asserts that a code evaluation in remote DOM resolves to true. 181 * Asserts that a code evaluation in remote DOM resolves to true.
147 * 182 *
148 * @param Function fn A function to be evaluated in remote DOM 183 * @param Function fn A function to be evaluated in remote DOM
......