lib/holygrail.rb
# Execute javascript within the context of a view.
#
# @example
#
#     class PeopleControllerTest < ActionController::TestCase
#       get :index
#       assert_equal 'People: index', js('document.title')
#     end
#
# @param [String]
#   code javascript code to evaluate
#
# @return [Object]
#   value of last javascript statement, cast to an equivalent ruby object
#
# @raise [Johnson::Error]
#   javascript code exception
#
Execute javascript within the context of a view.
Execute javascript within the context of a view .
def js(code)
      XhrProxy.context = self
      @__page ||= Harmony::Page.new(XHR_MOCK_SCRIPT + rewrite_script_paths(@response.body.to_s))
      Harmony::Page::Window::BASE_RUNTIME.wait
      @__page.execute_js(code)
    end
def js ( code ) XhrProxy . context = self @__page ||= Harmony :: Page . new ( XHR_MOCK_SCRIPT + rewrite_script_paths ( @response . body . to_s ) ) Harmony :: Page :: Window :: BASE_RUNTIME . wait @__page . execute_js ( code ) end
Execute javascript within the context of a view.
Execute javascript within the context of a view .
value of last javascript statement, cast to an equivalent ruby object
value of last javascript statement cast to an equivalent ruby object
Object
[Johnson::Error] javascript code exception
[ Johnson :: Error ] javascript code exception
code
<not_specific>
<not_specific>
code javascript code to evaluate
code javascript code to evaluate
example
class PeopleControllerTest < ActionController::TestCase get :index assert_equal 'People: index', js('document.title') end
class PeopleControllerTest < ActionController :: TestCase get : index assert_equal ' People : index ' js ( ' document . title ' ) end