Method: AssertJavaScript#deny_js_replace_html

Defined in:
lib/assert_javascript.rb

#deny_js_replace_html(element_id, matcher = nil, diagnostic = nil) ⇒ Object

Negates assert_js_replace_html

  • element_id - first argument to replace_html - the target HTML Element’s id

  • matcher - optional regular expression to not match the raw contents of the second argument to replace_html

  • diagnostic - optional string to add to failure message

If the matcher is nil or not provided, the element_id must /not/ match any Element.update call in its context. If the matcher /is/ provided, the element_id /must/ match, and the matcher must /not/ agree with its contents

Example: AssertJavaScriptTest#test_deny_js_replace_html



294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
# File 'lib/assert_javascript.rb', line 294

def deny_js_replace_html(element_id, matcher = nil, diagnostic = nil)
  path = object_method_xpath('Element', 'update', element_id)

#  ERGO  don't let subsequent updates with the same element_id confuse the matcher!

  if matcher and node = @xdoc.get_path(path)
    stash_xdoc do
      @xdoc = node
      assert_no_match matcher, assert_js_argument(2), diagnostic
      return  #  ERGO  pass node for 1st arg to assert_js_argument
    end
  end

  deny_xpath path, diagnostic
end