spec/javascripts/helpers/spec_helper.js.coffee in joosy-1.0.0.RC4 vs spec/javascripts/helpers/spec_helper.js.coffee in joosy-1.0.0.RC5
- old
+ new
@@ -43,7 +43,26 @@
unless spy.calledAfter previous
console.log "toBeSequenced: spy ##{i} wasn't called after spy ##{i - 1}"
return false
return true
+ toBeTag: (tagName, content, attrs) ->
+ @message = =>
+ "Expected #{@actual} to be a tag #{tagName} with attributes #{JSON.stringify attrs} and content #{content}"
+
+ tag = $ @actual
+ flag = true
+
+ flag = flag && tag.length == 1
+ flag = flag && tag[0].nodeName == tagName.toUpperCase()
+ if content != false
+ flag = flag && tag.html() == content
+
+ for name, val of attrs
+ flag = flag && !!(if val.constructor == RegExp then tag.attr(name).match(val) else tag.attr(name) == val)
+
+ flag = flag && tag[0].attributes.length == Object.keys(attrs).length
+
+ flag
+
afterEach ->
@ground.remove() unless @polluteGround
\ No newline at end of file