public
Description: Embedded 'reply' links in blog comments
Homepage: http://drnicjavascript.rubyforge.org/comment_replies
Clone URL: git://github.com/drnic/comment_replies.git
add functional tests + rake task
drnic (author)
Sat Feb 16 20:02:54 -0800 2008
commit  4acfddf909de45b28c1e2cbcf27c192d93cb3062
tree    66059bb7efe094cd40ac66103fe2b0ffd2525dbf
parent  67a2490969354c1634741e017a9569e1eb9da456
...
74
75
76
77
 
78
79
80
81
 
82
83
84
...
98
99
100
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
102
103
...
74
75
76
 
77
78
79
80
 
81
82
83
84
...
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
0
@@ -74,11 +74,11 @@ Rake::PackageTask.new(APP_NAME, APP_VERSION) do |package|
0
 end
0
 
0
 desc "Builds the distribution, runs the JavaScript unit tests and collects their results."
0
-task :test => [:dist, :test_units]
0
+task :test => [:dist, :test_units, :test_functionals]
0
 
0
 require 'jstest'
0
 desc "Runs all the JavaScript unit tests and collects the results"
0
-JavaScriptTestTask.new(:test_units) do |t|
0
+JavaScriptTestTask.new(:test_units, 4711) do |t|
0
   testcases = ENV['TESTCASES']
0
   tests_to_run = ENV['TESTS'] && ENV['TESTS'].split(',')
0
   browsers_to_test = ENV['BROWSERS'] && ENV['BROWSERS'].split(',')
0
@@ -98,6 +98,27 @@ JavaScriptTestTask.new(:test_units) do |t|
0
   end
0
 end
0
 
0
+desc "Runs all the JavaScript unit tests and collects the results"
0
+JavaScriptTestTask.new(:test_functionals, 4712) do |t|
0
+ testcases = ENV['TESTCASES']
0
+ tests_to_run = ENV['TESTS'] && ENV['TESTS'].split(',')
0
+ browsers_to_test = ENV['BROWSERS'] && ENV['BROWSERS'].split(',')
0
+
0
+ t.mount("/dist")
0
+ t.mount("/src")
0
+ t.mount("/test")
0
+
0
+ Dir["test/functional/*_test.html"].sort.each do |test_file|
0
+ tests = testcases ? { :url => "/#{test_file}", :testcases => testcases } : "/#{test_file}"
0
+ test_filename = test_file[/.*\/(.+?)\.html/, 1]
0
+ t.run(tests) unless tests_to_run && !tests_to_run.include?(test_filename)
0
+ end
0
+
0
+ %w( safari firefox ie konqueror opera ).each do |browser|
0
+ t.browser(browser.to_sym) unless browsers_to_test && !browsers_to_test.include?(browser)
0
+ end
0
+end
0
+
0
 task :clean_package_source do
0
   rm_rf File.join(APP_PKG_DIR, "#{APP_NAME}-#{APP_VERSION}")
0
 end
...
268
269
270
271
 
272
273
274
275
 
276
277
278
 
279
280
281
...
308
309
310
311
 
312
313
314
315
316
 
317
318
319
...
268
269
270
 
271
272
273
274
 
275
276
277
 
278
279
280
281
...
308
309
310
 
311
312
313
314
315
 
316
317
318
319
0
@@ -268,14 +268,14 @@ end
0
 
0
 class JavaScriptTestTask < ::Rake::TaskLib
0
 
0
- def initialize(name=:test)
0
+ def initialize(name=:test, port=4711)
0
     @name = name
0
     @tests = []
0
     @browsers = []
0
-
0
+ @port = port
0
     @queue = Queue.new
0
 
0
- @server = WEBrick::HTTPServer.new(:Port => 4711) # TODO: make port configurable
0
+ @server = WEBrick::HTTPServer.new(:Port => @port) # TODO: make port configurable
0
     @server.mount_proc("/results") do |req, res|
0
       @queue.push({
0
         :tests => req.query['tests'].to_i,
0
@@ -308,12 +308,12 @@ class JavaScriptTestTask < ::Rake::TaskLib
0
           browser.setup
0
           puts "\nStarted tests in #{browser}"
0
           @tests.each do |test|
0
- params = "resultsURL=http://localhost:4711/results&t=" + ("%.6f" % Time.now.to_f)
0
+ params = "resultsURL=http://localhost:#{@port}/results&t=" + ("%.6f" % Time.now.to_f)
0
             if test.is_a?(Hash)
0
               params << "&tests=#{test[:testcases]}" if test[:testcases]
0
               test = test[:url]
0
             end
0
- browser.visit("http://localhost:4711#{test}?#{params}")
0
+ browser.visit("http://localhost:#{@port}#{test}?#{params}")
0
  
0
             result = @queue.pop
0
             result.each { |k, v| results[k] += v }

Comments

    No one has commented yet.