forked from paytonrules/selenium-on-rails
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'origin/try_fix_frozen_error'
- Loading branch information
Showing
3 changed files
with
54 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters