js/assertions/attributeMatches.js
function assertion(selector, attribute, regexp) {
	var _this = this;

	var msg = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;

	this.message = msg;
	if (!this.message) {
		this.message = _util2.default.format('Testing if element <%s> has attribute <%s> that matches %s', selector, attribute, regexp.toString());
	}
	this.expected = regexp;

	this.pass = function (value) {
		return _this.expected.test(value);
	};

	this.value = function (result) {
		if (result.value.error) {
			console.error(result.value);
			return "";
		}

		return result.value;
	};

	this.command = function (callback) {
		return _this.api.getAttribute(selector, attribute, callback);
	};
}
function assertion(selector, attribute, regexp) {
	var _this = this;

	var msg = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;

	this.message = msg;
	if (!this.message) {
		this.message = _util2.default.format('Testing if element <%s> has attribute <%s> that matches %s', selector, attribute, regexp.toString());
	}
	this.expected = regexp;

	this.pass = function (value) {
		return _this.expected.test(value);
	};

	this.value = function (result) {
		if (result.value.error) {
			console.error(result.value);
			return "";
		}

		return result.value;
	};

	this.command = function (callback) {
		return _this.api.getAttribute(selector, attribute, callback);
	};
}
function assertion ( selector , attribute , regexp ) { var _this = this ; var msg = arguments . length > 3 && arguments [ 3 ] !== undefined ? arguments [ 3 ] : null ; this . message = msg ; if ( ! this . message ) { this . message = _util2 . default . format ( 'Testing if element <%s> has attribute <%s> that matches %s' , selector , attribute , regexp . toString ( ) ) ; } this . expected = regexp ; this . pass = function ( value ) { return _this . expected . test ( value ) ; } ; this . value = function ( result ) { if ( result . value . error ) { console . error ( result . value ) ; return "" ; } return result . value ; } ; this . command = function ( callback ) { return _this . api . getAttribute ( selector , attribute , callback ) ; } ; }
Assert that the element identified by the selector has an attribute that matches
the provided regexp.

h3 Examples:

browser
.url("http://www.github.com")
.assert.attributeMatches("body", "class", /body-class/g)

browser
.url("http://www.github.com")
.assert.attributeMatches("body", "class", new RegExp("body-class", "g")

@author maxgalbu
@param {String} selector - the element selector
@param {String} attribute - the element attribute
@param {RegExp} regexp - the regexp that should match the attribute
@param {String} [msg] - output to identify the assertion
Assert that the element identified by the selector has an attribute that matches the provided regexp .