Skip to content

Commit 23e9394

Browse files
committed
more refactoring
1 parent 1456c44 commit 23e9394

File tree

1 file changed

+14
-34
lines changed

1 file changed

+14
-34
lines changed

tests/test.rb

Lines changed: 14 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
require 'rubygems'
22

33
RUNNER_DIR = Dir.pwd.gsub(/\/tests$/,"") + "/"
4+
45
def execute(cmd)
56
`#{cmd}`
67
end
@@ -31,55 +32,34 @@ def runBg(cmd, linestomatch, genre, test_strings)
3132
end
3233

3334
class Test
34-
def run_project
35-
end
36-
37-
def qunit
35+
def run_project(reponame, test_framework, passed_array, browser_url)
3836
repo_path = "#{RUNNER_DIR}tests/external-repos/"
3937
conf_path = "#{RUNNER_DIR}tests/conf/"
40-
execute("cd #{repo_path}underscorejs && npm install")
41-
execute("cd #{repo_path}underscorejs && cp #{conf_path}underscorejs.json #{repo_path}underscorejs/browserstack.json")
42-
pid = runBg("cd #{repo_path}underscorejs && ../../../bin/cli.js", 1, "qunit-underscorejs", ["631 of 631 passed"])
43-
execute("open http://localhost:8888/test/index.html")
38+
39+
execute("cd #{repo_path}#{reponame} && npm install")
40+
execute("cd #{repo_path}#{reponame} && cp #{conf_path}#{reponame}.json #{repo_path}#{reponame}/browserstack.json")
41+
pid = runBg("cd #{repo_path}#{reponame} && ../../../bin/cli.js", 1, "#{test_framework}-#{reponame}", passed_array)
42+
execute("open http://localhost:8888/#{browser_url}")
4443
Process.wait(pid)
4544
sleep(1)
46-
47-
execute("cd #{repo_path}Modernizr && npm install")
48-
execute("cd #{repo_path}Modernizr && cp #{conf_path}Modernizr.json #{repo_path}Modernizr/browserstack.json")
49-
pid2 = runBg("cd #{repo_path}Modernizr && ../../../bin/cli.js", 1, "qunit-Modernizr", ["20 of 41 passed"])
50-
execute("open http://localhost:8888/test/index.html")
51-
Process.wait(pid2)
52-
45+
end
46+
47+
def qunit
48+
run_project("underscorejs", "qunit", ["631 of 631 passed"], "test/index.html")
49+
run_project("Modernizr", "qunit", ["20 of 41 passed"], "test/index.html")
5350
# https://github.com/bitovi/funcunit/
5451
# https://github.com/twbs/bootstrap
5552
end
5653

5754
def mocha
58-
repo_path = "#{RUNNER_DIR}tests/external-repos/"
59-
conf_path = "#{RUNNER_DIR}tests/conf/"
60-
61-
execute("cd #{repo_path}url.js && npm install")
62-
execute("cd #{repo_path}url.js && cp #{conf_path}url.js.json #{repo_path}url.js/browserstack.json")
63-
pid = runBg("cd #{repo_path}url.js && ../../../bin/cli.js", 1, "mocha-urlJs", ["35 of 35 passed"])
64-
execute("open http://localhost:8888/test.html")
65-
Process.wait(pid)
66-
sleep(1)
67-
55+
run_project("url.js", "mocha", ["35 of 35 passed"], "test.html")
6856
# https://github.com/browserstack/microjungle
6957
# https://github.com/dhimil/mocha
7058
# https://github.com/auth0/auth0.js
7159
end
7260

7361
def jasmine
74-
repo_path = "#{RUNNER_DIR}tests/external-repos/"
75-
conf_path = "#{RUNNER_DIR}tests/conf/"
76-
77-
execute("cd #{repo_path}mout && npm install")
78-
execute("cd #{repo_path}mout && cp #{conf_path}mout.json #{repo_path}mout/browserstack.json")
79-
pid = runBg("cd #{repo_path}mout && ../../../bin/cli.js", 1, "jasmine-mout", ["978 of 978 passed"])
80-
execute("open http://localhost:8888/tests/runner.html")
81-
Process.wait(pid)
82-
sleep(1)
62+
run_project("mout", "jasmine", ["978 of 978 passed"], "tests/runner.html")
8363
end
8464

8565
def run

0 commit comments

Comments
 (0)