Skip to content

Commit

Permalink
Merge branch 'origin/try_fix_frozen_error'
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Smith committed Mar 7, 2009
2 parents 1f24502 + da8537a commit 37fccff
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 41 deletions.
86 changes: 50 additions & 36 deletions lib/selenium_on_rails/rselenese.rb
Original file line number Diff line number Diff line change
@@ -1,36 +1,50 @@
# Renders Selenium test templates in a fashion analogous to +rxml+ and
# +rjs+ templates.
#
# setup
# open :controller => 'customer', :action => 'list'
# assert_title 'Customers'
#
# See SeleniumOnRails::TestBuilder for a list of available commands.
class SeleniumOnRails::RSelenese < SeleniumOnRails::TestBuilder
end
ActionView::Template.register_template_handler 'rsel', SeleniumOnRails::RSelenese

class SeleniumOnRails::RSelenese < SeleniumOnRails::TestBuilder
attr_accessor :view

def initialize view
super view
@view = view
end

def render template, local_assigns
title = (@view.assigns['page_title'] or local_assigns['page_title'])
table(title) do
test = self #to enable test.command

assign_locals_code = ''
local_assigns.each_key {|key| assign_locals_code << "#{key} = local_assigns[#{key.inspect}];"}

eval assign_locals_code + "\n" + template.source
end
end

def self.call(template)
"#{name}.new(self).render(template, local_assigns)"
end
end
# Renders Selenium test templates in a fashion analogous to +rxml+ and
# +rjs+ templates.
#
# setup
# open :controller => 'customer', :action => 'list'
# assert_title 'Customers'
#
# See SeleniumOnRails::TestBuilder for a list of available commands.
class SeleniumOnRails::RSelenese < SeleniumOnRails::TestBuilder
end
ActionView::Template.register_template_handler 'rsel', SeleniumOnRails::RSelenese

class SeleniumOnRails::RSelenese < SeleniumOnRails::TestBuilder
attr_accessor :view

def initialize view
super view
@view = view
end

def render template, local_assigns
title = (@view.assigns['page_title'] or local_assigns['page_title'])
# table(title) do
# test = self #to enable test.command
#
# assign_locals_code = ''
# local_assigns.each_key {|key| assign_locals_code << "#{key} = local_assigns[#{key.inspect}];"}
#
# eval assign_locals_code + "\n" + template.source
# end
assign_locals_code = ''
local_assigns.each_key {|key| assign_locals_code << "#{key} = local_assigns[#{key.inspect}];"}

evaluator = Evaluator.new(@view)
evaluator.run_script title, assign_locals_code + "\n" + template.source, local_assigns
end

def self.call(template)
"#{name}.new(self).render(template, local_assigns)"
end

class Evaluator < SeleniumOnRails::TestBuilder
def run_script(title, script, local_assigns)
table(title) do
test = self #to enable test.command
eval script
end
end
end
end
5 changes: 2 additions & 3 deletions lib/selenium_on_rails/test_builder_actions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -503,9 +503,8 @@ def wait_for_page_to_load timeout
def self.generate_and_wait_actions
public_instance_methods.each do |method|
define_method method + '_and_wait' do |*args|
make_command_waiting do
send method, *args
end
methods_array = method.split("_")
send 'command_and_wait', methods_array.first.downcase + methods_array[1..-1].collect{|part| part.camelize}.join, *args
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions test_data/rselenese.rsel
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ test.setup :fixtures => :all
setup :fixtures => [:foo, 'bar']
setup :clear_tables => [:foo, :bar], :fixtures => :all
assert_absolute_location :controller => 'selenium', :action => 'setup' #urls must be tested with a controller
assert_title view.controller.controller_name #make sure we can access the view easily
include_partial 'partial', :source => 'RSelenese'
assert_title @view.controller.controller_name #make sure we can access the view easily
include_partial 'partial', :source => 'RSelenese'

0 comments on commit 37fccff

Please sign in to comment.