Commit 7b38c3a6 7b38c3a61112aac8734cae299ac977703ca77ac2 by Nicolas Perriault

added Tester.assertTitleMatch() method

1 parent 169aca86
......@@ -8,6 +8,7 @@ XXXX-XX-XX, v0.6.11
- fixes [#140](https://github.com/n1k0/casperjs/issues/140) - `casper test` now resolves local paths urls
- closed [#144](https://github.com/n1k0/casperjs/issues/144) - added a `safeLogs` option to blur password values in debug logs. **This option is set to `true` by default.**
- added [`Casper.userAgent()`](http://casperjs.org/api.html#casper.userAgent) to ease a more dynamic setting of user-agent string
- added `Tester.assertTitleMatch()` method
- switched to more standard `.textContent` property to get a node text; this allows a better compatibility of the clientutils bookmarklet with non-webkit browsers
- casper modules now all use [javascript strict mode](http://www.nczonline.net/blog/2012/03/13/its-time-to-start-using-javascript-strict-mode/)
......
Subproject commit 23bd43286ab953b7c4b3fa74aeee1216320ae308
Subproject commit ed91017f48fd77e8c3a268ecdbb78adac7bce0b5
......
......@@ -390,6 +390,25 @@ var Tester = function Tester(casper, options) {
};
/**
* Asserts that title of the remote page matched the provided pattern.
*
* @param RegExp pattern The pattern to test the title against
* @param String message Test description
* @return Object An assertion result object
*/
this.assertTitleMatch = this.assertTitleMatches = function assertTitleMatch(pattern, message) {
var currentTitle = casper.getTitle();
return this.assert(pattern.test(currentTitle), message, {
type: "assertTitle",
details: "Page title does not match the provided pattern",
values: {
subject: currentTitle,
pattern: pattern
}
});
};
/**
* Asserts that the provided subject is of the given type.
*
* @param mixed subject The value to test
......
......@@ -96,6 +96,9 @@ casper.then(function() {
t.comment('Tester.assertTitle()');
t.assertTitle('CasperJS test index', 'Tester.assertTitle() works as expected');
t.comment('Tester.assertTitleMatch()');
t.assertTitleMatch(/test index/, 'Tester.assertTitleMatch() works as expected');
t.comment('Tester.assertType()');
t.assertType("plop", "string", "Tester.assertType() works as expected");
......