Class: Awat

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
lib/awat.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.filesObject



20
21
22
23
# File 'lib/awat.rb', line 20

def self.files
  path = AwatConfig['path']
  File.file?(path) ? [path] : Dir.glob(File.join(path,'**/*')).select {|f| File.file?(f)}
end

.generate_testsObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/awat.rb', line 25

def self.generate_tests
  files.map do |f|
    AwatConfig['browsers'].to_a.map do |b|
      # browsers
      method = %Q{def test__#{ (b + '__' +f).gsub(/\W/,'_')}()
                    @page = ::Selenium::Client::Driver.new(#{AwatConfig['selenium'].update(:browser => b.sub(/^\*?/,'*')).inspect})
                    @page.start_new_browser_session
                    #{File.read(f)}
                    ensure
                    @page.close_current_browser_session
                  end}

      Awat.module_eval(method)
    end
  end
end

Instance Method Details

#depend(name) ⇒ Object



12
13
14
# File 'lib/awat.rb', line 12

def depend(name)
  eval File.read(File.join(AwatConfig['directory'],'test',name))
end

#screenshot(name, path) ⇒ Object



16
17
18
# File 'lib/awat.rb', line 16

def screenshot(name,path)
  puts "screenshot #TODO" #TODO
end