Class: SeaCucumber::TestRunner
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- SeaCucumber::TestRunner
- Defined in:
- lib/seacucumber.rb
Class Attribute Summary collapse
-
.browsers ⇒ Object
Returns the value of attribute browsers.
-
.options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #define ⇒ Object
-
#initialize(&block) ⇒ TestRunner
constructor
A new instance of TestRunner.
- #mount(path, dir = nil) ⇒ Object
-
#run(test) ⇒ Object
test should be specified as a url.
Constructor Details
#initialize(&block) ⇒ TestRunner
Returns a new instance of TestRunner.
32 33 34 35 36 37 38 39 40 |
# File 'lib/seacucumber.rb', line 32 def initialize(&block) @name = [:name] @host = [:host] @port = [:port] @tests = [] @queue = Queue.new define(&block) end |
Class Attribute Details
.browsers ⇒ Object
Returns the value of attribute browsers.
30 31 32 |
# File 'lib/seacucumber.rb', line 30 def browsers @browsers end |
.options ⇒ Object
Returns the value of attribute options.
30 31 32 |
# File 'lib/seacucumber.rb', line 30 def @options end |
Instance Method Details
#define ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/seacucumber.rb', line 42 def define task @name do result = [] # Starting the server... # NOTE: this must be within the task, otherwise the server will be started regardless of whether the task was called puts "Starting WEBrick server (listening on #{@port})..." @server = WEBrick::HTTPServer.new(:Port => @port) @server.mount_proc("/results") do |req, res| @queue.push(req.query['result']) res.body = "OK" end yield self if block_given? trap("INT") { @server.shutdown } thread = Thread.new { @server.start } # run all combinations of browsers and tests browsers.values.each do |browser| if browser.supported? browser.setup @tests.each do |test| browser.visit("http://#{@host}:#{@port}/#{test}?resultsURL=http://#{@host}:#{@port}/results&t=" + ("%.6f" % Time.now.to_f)) result = @queue.pop puts "Testing '#{test}' on #{browser}: #{result}" end else puts "Skipping #{browser}, not supported on this OS" end browser.teardown end @server.shutdown thread.join end end |
#mount(path, dir = nil) ⇒ Object
81 82 83 84 85 |
# File 'lib/seacucumber.rb', line 81 def mount(path, dir=nil) dir = Dir.pwd + path unless dir @server.mount(path, WEBrick::HTTPServlet::FileHandler, dir) end |
#run(test) ⇒ Object
test should be specified as a url
88 89 90 |
# File 'lib/seacucumber.rb', line 88 def run(test) @tests << test end |