code: function(attr) {
      var selector = this._obj,
          attrs = casper.getElementsAttribute(selector, attr)
      if (utils.flag(this, 'element')) {
        this.assert(attrs.some(function(a) {
          return a
        }), ('Expected some elements matching selector ' + selector + ' to have attribute') + ('' + attr + ' set, but none did'), ('Expected no elements matching selector ' + selector + ' to have attribute') + ('' + attr + ' set, but at least one did'))
      } else {
        this.assert(attrs.every(function(a) {
          return a
        }), ('Expected all elements matching selector ' + selector + ' to have attribute ') + ('' + attr + ' set, but some did not have it'), ('Expected no elements matching selector ' + selector + ' to have attribute ') + ('' + attr + ' set, but some had it'))
      }
      return utils.flag(this, 'object', attrs)
    }
docs: /*
  Casper-Chai Assertions
  ----------
  
  The following are the assertion tests that are added onto `Chai.Assertion`.
   /*
  @@@@ attr(attributeName) / attribute(attributeName)
  
  Asserts that attribute `attribute_name` are on all elements matched by `selector`.
  If the `element` chain was used, it asserts that any element has that selector.
  
  ```javascript
  expect("#my_header").to.have.attr('class')
  expect("ul.header li").to.have.an.element.with.attribute('aria-selected')
  ```
  
  It also changes the subject of the assertion to the attributes, so you can do
  further assertions on those attributes
  
  ````javascript
  "#tabs li a".should.have.an.element.with.attribute('aria-selected')[0].that.equals('true')
  "section a.add".should.have.attr('data-bind')[0].and.contains('click:')
  ````