Class: Test::Unit::Assertions::AssertRjs::REPLACE_HTML

Inherits:
Test::Unit::Assertions::AssertRjs show all
Defined in:
lib/assert2/rjs.rb

Direct Known Subclasses

REPLACE

Instance Attribute Summary

Attributes inherited from Test::Unit::Assertions::AssertRjs

#command, #failure_message, #js, #scope

Instance Method Summary collapse

Methods inherited from Test::Unit::Assertions::AssertRjs

#assert_xhtml, #complain, #flunk, #initialize, #match, #match_or_flunk, #pwn_call, #wrap_expectation

Constructor Details

This class inherits a constructor from Test::Unit::Assertions::AssertRjs

Instance Method Details

#conceptObject



129
# File 'lib/assert2/rjs.rb', line 129

def concept;  'Element.update()';  end

#pwn(*args, &block) ⇒ Object



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/assert2/rjs.rb', line 104

def pwn *args, &block
  target, @matcher = args
  @matcher ||= //
  
  match concept do |thang|
    div_id, html = thang.value
    
    if target and html
      div_id = eval(div_id.value)
      html   = html.value.gsub('\u003C', '<').
                          gsub('\u003E', '>')  #  ERGO  give a crap about encoding! 
      html   = eval(html)

      if div_id == target.to_s
        cornplaint = complain("for ID #{ target } has incorrect payload, in")
        @text = html
        match_or_flunk cornplaint if @matcher
        assert_xhtml cornplaint, &block if block
        return html  #  TODO  match any html not just the first. Because!
      end
    end
  end

  flunk "for ID #{ target } not found in"
end