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, #hash_match, #initialize, #match, #match_or_flunk, #props_to_hash, #pwn_call, #wrap_expectation

Constructor Details

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

Instance Method Details

#conceptObject



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

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

#pwn(*args, &block) ⇒ Object



153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# File 'lib/assert2/rjs.rb', line 153

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