diff --git a/spec/spec-helper.coffee b/spec/spec-helper.coffee index c93dcf4fd..e1610748c 100644 --- a/spec/spec-helper.coffee +++ b/spec/spec-helper.coffee @@ -159,6 +159,17 @@ addCustomMatchers = (spec) -> @message = -> return "Expected path '" + @actual + "'" + notText + " to exist." fs.existsSync(@actual) + toHaveFocus: -> + notText = this.isNot and " not" or "" + if not document.hasFocus() + console.error "Specs will fail because the Dev Tools have focus. To fix this close the Dev Tools or click the spec runner." + + @message = -> return "Expected element '" + @actual + "' or its descendants" + notText + " to have focus." + element = @actual + element = element.get(0) if element.jquery + element.webkitMatchesSelector(":focus") or element.querySelector(":focus") + + window.keyIdentifierForKey = (key) -> if key.length > 1 # named key key