vendor/plugins/respond_to_parent/lib/parent_selector_assertion.rb
# :call-seq:
#   assert_select_parent()
#   assert_select_parent() { |script| ... }
#
# Selects JavaScript that is generated for the `parent' window.
#
# Without a block, #assert_select_parent asserts that the response
# is generated by responds_to_parent.
#
# With a block, #assert_select_parent selects script that is supposed
# to be evaluated in the parent window and passes it to the block.
# Typically #assert_select_rjs is used in the block.


Selects JavaScript that is generated for the `parent' window.

Without a block, #assert_select_parent asserts that the response
is generated by responds_to_parent.

With a block, #assert_select_parent selects script that is supposed
to be evaluated in the parent window and passes it to the block.
Typically #assert_select_rjs is used in the block.
Selects JavaScript that is generated for the ` parent ' window . Without a block #assert_select_parent asserts that the response is generated by responds_to_parent . With a block #assert_select_parent selects script that is supposed to be evaluated in the parent window and passes it to the block . Typically #assert_select_rjs is used in the block .
def assert_select_parent(*args, &block)
        wrapper_re_str = Regexp.escape("with(window.parent) { setTimeout(function() { window.eval('") +
                       "(.*)" +
                       Regexp.escape("'); loc.replace('about:blank'); }, 1) }")
        match = @response.body.match(Regexp.new(wrapper_re_str))
        if match
          escaped_js = match[1]
          unescaped_js = escaped_js.
            gsub(%r!</scr"\+"ipt>!, '</script>').
            gsub(/\\(\'|\")/, '\1').
            gsub(/((?:^|[^\\])(?:\\\\)*)\\n/, "\\1\n"). 
            gsub(/\\\\/, '\\')
          @response.body = unescaped_js 
          if block_given?
            begin
              in_scope, @selected = @selected, unescaped_js
              yield unescaped_js
            ensure
              @selected = in_scope
            end
          end
          unescaped_js
        else
          flunk args.shift || "No content for the parent window."
        end
      end
def assert_select_parent ( * args , & block ) wrapper_re_str = Regexp . escape ( "with(window.parent) { setTimeout(function() { window.eval('" ) + "(.*)" + Regexp . escape ( "'); loc.replace('about:blank'); }, 1) }" ) match = @response . body . match ( Regexp . new ( wrapper_re_str ) ) if match escaped_js = match [ 1 ] unescaped_js = escaped_js . gsub ( %r! </scr" \+ "ipt> ! , '</script>' ) . gsub ( / \\ ( \' | \" ) / , '\1' ) . gsub ( / ((?:^|[^ \\ ])(?: \\ \\ )*) \\ n / , "\\1\n" ) . gsub ( / \\ \\ / , '\\' ) @response . body = unescaped_js if block_given? begin in_scope , @selected = @selected , unescaped_js yield unescaped_js ensure @selected = in_scope end end unescaped_js else flunk args . shift || "No content for the parent window." end end
:call-seq:
assert_select_parent()
assert_select_parent() { |script| ... }
: call - seq : assert_select_parent () assert_select_parent () { |script| ... }
# replace `n' with odd number of backslash. # assert_select_rjs refers @response.body. # doesn't seem a responds_to_parent content.
args
<not_specific>
block
<not_specific>