mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-17 15:50:13 +01:00
Merge branch 'master' of git://github.com/bsag/tracks
Conflicts: config/routes.rb
This commit is contained in:
commit
952a73e39d
1092 changed files with 52802 additions and 20798 deletions
|
|
@ -1,61 +1,56 @@
|
|||
module SeleniumOnRails
|
||||
module Paths
|
||||
def selenium_path
|
||||
@@selenium_path ||= find_selenium_path
|
||||
@@selenium_path
|
||||
end
|
||||
|
||||
def selenium_tests_path
|
||||
File.expand_path(File.join(RAILS_ROOT, 'test/selenium'))
|
||||
end
|
||||
|
||||
def view_path view
|
||||
File.expand_path(File.dirname(__FILE__) + '/../views/' + view)
|
||||
end
|
||||
|
||||
# Returns the path to the layout template. The path is relative in relation
|
||||
# to the app/views/ directory since Rails doesn't support absolute paths
|
||||
# to layout templates.
|
||||
def layout_path
|
||||
rails_root = Pathname.new File.expand_path(File.join(RAILS_ROOT, 'app/views'))
|
||||
view_path = Pathname.new view_path('layout')
|
||||
view_path.relative_path_from(rails_root).to_s
|
||||
end
|
||||
|
||||
def fixtures_path
|
||||
File.expand_path File.join(RAILS_ROOT, 'test/fixtures')
|
||||
end
|
||||
|
||||
def log_path log_file
|
||||
File.expand_path(File.dirname(__FILE__) + '/../../log/' + File.basename(log_file))
|
||||
end
|
||||
|
||||
def skip_file? file
|
||||
file.split('/').each do |f|
|
||||
return true if f.upcase == 'CVS' or f.starts_with?('.') or f.ends_with?('~') or f.starts_with?('_')
|
||||
end
|
||||
false
|
||||
end
|
||||
|
||||
private
|
||||
def find_selenium_path
|
||||
sel_dirs = SeleniumOnRailsConfig.get :selenium_path do
|
||||
ds = [File.expand_path(File.join(RAILS_ROOT, 'vendor/selenium')),
|
||||
File.expand_path(File.join(RAILS_ROOT, 'vendor/selenium-core'))]
|
||||
gems = Gem.source_index.find_name 'selenium', nil
|
||||
ds << gems.last.full_gem_path unless gems.empty?
|
||||
ds
|
||||
end
|
||||
|
||||
sel_dirs.to_a.each do |seleniumdir|
|
||||
['', 'core', 'selenium', 'javascript'].each do |subdir|
|
||||
path = File.join seleniumdir, subdir
|
||||
return path if File.exist?(File.join(path, 'TestRunner.html'))
|
||||
end
|
||||
end
|
||||
|
||||
raise 'Could not find Selenium Core installation'
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
module SeleniumOnRails
|
||||
module Paths
|
||||
def selenium_path
|
||||
@@selenium_path ||= find_selenium_path
|
||||
@@selenium_path
|
||||
end
|
||||
|
||||
def selenium_tests_path
|
||||
File.expand_path(File.join(RAILS_ROOT, 'test/selenium'))
|
||||
end
|
||||
|
||||
def view_path view
|
||||
File.expand_path(File.dirname(__FILE__) + '/../views/' + view)
|
||||
end
|
||||
|
||||
def layout_path
|
||||
'/layout.rhtml'
|
||||
end
|
||||
|
||||
def fixtures_path
|
||||
File.expand_path File.join(RAILS_ROOT, 'test/fixtures')
|
||||
end
|
||||
|
||||
def log_path log_file
|
||||
File.expand_path(File.dirname(__FILE__) + '/../../log/' + File.basename(log_file))
|
||||
end
|
||||
|
||||
def skip_file? file
|
||||
file.split('/').each do |f|
|
||||
return true if f.upcase == 'CVS' or f.starts_with?('.') or f.ends_with?('~') or f.starts_with?('_')
|
||||
end
|
||||
false
|
||||
end
|
||||
|
||||
private
|
||||
def find_selenium_path
|
||||
sel_dirs = SeleniumOnRailsConfig.get :selenium_path do
|
||||
ds = [File.expand_path(File.join(RAILS_ROOT, 'vendor/selenium')),
|
||||
File.expand_path(File.join(RAILS_ROOT, 'vendor/selenium-core'))]
|
||||
gems = Gem.source_index.find_name 'selenium', nil
|
||||
ds << gems.last.full_gem_path unless gems.empty?
|
||||
ds
|
||||
end
|
||||
|
||||
sel_dirs.to_a.each do |seleniumdir|
|
||||
['', 'core', 'selenium', 'javascript'].each do |subdir|
|
||||
path = File.join seleniumdir, subdir
|
||||
return path if File.exist?(File.join(path, 'TestRunner.html'))
|
||||
end
|
||||
end
|
||||
|
||||
raise 'Could not find Selenium Core installation'
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,35 +1,35 @@
|
|||
# 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::Base.register_template_handler 'rsel', SeleniumOnRails::RSelenese
|
||||
|
||||
class SeleniumOnRails::RSelenese < SeleniumOnRails::TestBuilder
|
||||
attr_accessor :view
|
||||
|
||||
# Create a new RSelenese renderer bound to _view_.
|
||||
def initialize view
|
||||
super view
|
||||
@view = view
|
||||
end
|
||||
|
||||
# Render _template_ using _local_assigns_.
|
||||
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
|
||||
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
|
||||
|
||||
# Create a new RSelenese renderer bound to _view_.
|
||||
def initialize view
|
||||
super view
|
||||
@view = view
|
||||
end
|
||||
|
||||
# Render _template_ using _local_assigns_.
|
||||
def render template
|
||||
title = @view.assigns['page_title']
|
||||
table(title) do
|
||||
test = self #to enable test.command
|
||||
eval template.source
|
||||
end
|
||||
end
|
||||
|
||||
def compilable?
|
||||
false
|
||||
end
|
||||
|
||||
end
|
||||
|
|
@ -1,81 +1,85 @@
|
|||
class SeleniumOnRails::Selenese
|
||||
end
|
||||
ActionView::Base.register_template_handler 'sel', SeleniumOnRails::Selenese
|
||||
|
||||
|
||||
class SeleniumOnRails::Selenese
|
||||
def initialize view
|
||||
@view = view
|
||||
end
|
||||
|
||||
def render template, local_assigns
|
||||
name = (@view.assigns['page_title'] or local_assigns['page_title'])
|
||||
lines = template.strip.split "\n"
|
||||
html = ''
|
||||
html << extract_comments(lines)
|
||||
html << extract_commands(lines, name)
|
||||
html << extract_comments(lines)
|
||||
raise 'You cannot have comments in the middle of commands!' if next_line lines, :any
|
||||
html
|
||||
end
|
||||
|
||||
private
|
||||
def next_line lines, expects
|
||||
while lines.any?
|
||||
l = lines.shift.strip
|
||||
next if (l.empty? and expects != :comment)
|
||||
comment = (l =~ /^\|.*\|$/).nil?
|
||||
if (comment and expects == :command) or (!comment and expects == :comment)
|
||||
lines.unshift l
|
||||
return nil
|
||||
end
|
||||
return l
|
||||
end
|
||||
end
|
||||
|
||||
def extract_comments lines
|
||||
comments = ''
|
||||
while (line = next_line lines, :comment)
|
||||
comments << line + "\n"
|
||||
end
|
||||
if defined? RedCloth
|
||||
comments = RedCloth.new(comments).to_html
|
||||
end
|
||||
comments += "\n" unless comments.empty?
|
||||
comments
|
||||
end
|
||||
|
||||
def extract_commands lines, name
|
||||
html = "<table>\n<tr><th colspan=\"3\">#{name}</th></tr>\n"
|
||||
while (line = next_line lines, :command)
|
||||
line = line[1..-2] #remove starting and ending |
|
||||
cells = line.split '|'
|
||||
if cells.first == 'includePartial'
|
||||
html << include_partial(cells[1..-1])
|
||||
next
|
||||
end
|
||||
raise 'There might only be a maximum of three cells!' if cells.length > 3
|
||||
html << '<tr>'
|
||||
(1..3).each do
|
||||
cell = cells.shift
|
||||
cell = (cell ? CGI.escapeHTML(cell.strip) : ' ')
|
||||
html << "<td>#{cell}</td>"
|
||||
end
|
||||
html << "</tr>\n"
|
||||
end
|
||||
html << "</table>\n"
|
||||
end
|
||||
|
||||
def include_partial params
|
||||
partial = params.shift
|
||||
locals = {}
|
||||
params.each do |assignment|
|
||||
next if assignment.empty?
|
||||
_, var, value = assignment.split(/^([a-z_][a-zA-Z0-9_]*)\s*=\s*(.*)$/)
|
||||
raise "Invalid format '#{assignment}'. Should be '|includePartial|partial|var1=value|var2=value|." unless var
|
||||
locals[var.to_sym] = value or ''
|
||||
end
|
||||
@view.render :partial => partial, :locals => locals
|
||||
end
|
||||
|
||||
class SeleniumOnRails::Selenese
|
||||
end
|
||||
ActionView::Template.register_template_handler 'sel', SeleniumOnRails::Selenese
|
||||
|
||||
|
||||
class SeleniumOnRails::Selenese
|
||||
def initialize view
|
||||
@view = view
|
||||
end
|
||||
|
||||
def render template
|
||||
name = @view.assigns['page_title']
|
||||
lines = template.strip.split "\n"
|
||||
html = ''
|
||||
html << extract_comments(lines)
|
||||
html << extract_commands(lines, name)
|
||||
html << extract_comments(lines)
|
||||
raise 'You cannot have comments in the middle of commands!' if next_line lines, :any
|
||||
html
|
||||
end
|
||||
|
||||
def compilable?
|
||||
false
|
||||
end
|
||||
|
||||
private
|
||||
def next_line lines, expects
|
||||
while lines.any?
|
||||
l = lines.shift.strip
|
||||
next if (l.empty? and expects != :comment)
|
||||
comment = (l =~ /^\|.*\|$/).nil?
|
||||
if (comment and expects == :command) or (!comment and expects == :comment)
|
||||
lines.unshift l
|
||||
return nil
|
||||
end
|
||||
return l
|
||||
end
|
||||
end
|
||||
|
||||
def extract_comments lines
|
||||
comments = ''
|
||||
while (line = next_line lines, :comment)
|
||||
comments << line + "\n"
|
||||
end
|
||||
if defined? RedCloth
|
||||
comments = RedCloth.new(comments).to_html
|
||||
end
|
||||
comments += "\n" unless comments.empty?
|
||||
comments
|
||||
end
|
||||
|
||||
def extract_commands lines, name
|
||||
html = "<table>\n<tr><th colspan=\"3\">#{name}</th></tr>\n"
|
||||
while (line = next_line lines, :command)
|
||||
line = line[1..-2] #remove starting and ending |
|
||||
cells = line.split '|'
|
||||
if cells.first == 'includePartial'
|
||||
html << include_partial(cells[1..-1])
|
||||
next
|
||||
end
|
||||
raise 'There might only be a maximum of three cells!' if cells.length > 3
|
||||
html << '<tr>'
|
||||
(1..3).each do
|
||||
cell = cells.shift
|
||||
cell = (cell ? CGI.escapeHTML(cell.strip) : ' ')
|
||||
html << "<td>#{cell}</td>"
|
||||
end
|
||||
html << "</tr>\n"
|
||||
end
|
||||
html << "</table>\n"
|
||||
end
|
||||
|
||||
def include_partial params
|
||||
partial = params.shift
|
||||
locals = {}
|
||||
params.each do |assignment|
|
||||
next if assignment.empty?
|
||||
_, var, value = assignment.split(/^([a-z_][a-zA-Z0-9_]*)\s*=\s*(.*)$/)
|
||||
raise "Invalid format '#{assignment}'. Should be '|includePartial|partial|var1=value|var2=value|." unless var
|
||||
locals[var.to_sym] = value or ''
|
||||
end
|
||||
@view.render :partial => partial, :locals => locals
|
||||
end
|
||||
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue