js-test-driver-rails 0.2.1 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README +6 -1
- data/VERSION +1 -1
- data/lib/js_test_driver/runner.rb +50 -13
- data/lib/js_test_driver/tasks.rb +8 -0
- data/test/unit/runner_test.rb +8 -0
- metadata +4 -4
data/README
CHANGED
@@ -54,7 +54,7 @@ in your config file, somewhere before including your test files and you are gold
|
|
54
54
|
|
55
55
|
# the fixtures will be accessible through myApp.html["<fixture name goes here>"]
|
56
56
|
|
57
|
-
This gem comes with
|
57
|
+
This gem comes with some rake tasks:
|
58
58
|
|
59
59
|
# start the js test driver server
|
60
60
|
rake js_test_driver:start_server
|
@@ -65,4 +65,9 @@ rake js_test_driver:capture_browsers [BROWSERS=foo,bar,baz]
|
|
65
65
|
# run the tests (all or the specified ones)
|
66
66
|
rake js_test_driver:run_tests [TESTS=TestCase[.testMethod]]
|
67
67
|
|
68
|
+
# will run the server, capture the browsers and run tests all in one command
|
69
|
+
# this is mostly useful on CI, because it's much faster to run the server and capture the browsers once
|
70
|
+
# and then run the tests again and again
|
71
|
+
rake js_test_driver:run [TESTS=TestCase[.testMethod]] [BROWSERS=foo,bar,baz] [OUTPUT_XML=1 | OUTPUT_PATH=/some/dir] [CAPTURE_CONSOLE=1]
|
72
|
+
|
68
73
|
You can add these tasks by requiring "js_test_driver/tasks"
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.5
|
@@ -46,7 +46,11 @@ module JsTestDriver
|
|
46
46
|
|
47
47
|
# starts the server on the default port specified in the config file
|
48
48
|
def start_server
|
49
|
-
|
49
|
+
command = execute_jar
|
50
|
+
|
51
|
+
add_start_server(command)
|
52
|
+
|
53
|
+
command.run
|
50
54
|
end
|
51
55
|
|
52
56
|
# captures the browsers
|
@@ -54,7 +58,12 @@ module JsTestDriver
|
|
54
58
|
# by default it will capture the browsers specified in the config,
|
55
59
|
# but you can pass an argument like 'opera,chrome,firefox' to capture opera, chrome and firefox
|
56
60
|
def capture_browsers(browsers = nil)
|
57
|
-
|
61
|
+
command = execute_jar
|
62
|
+
|
63
|
+
add_with_config(command)
|
64
|
+
add_capture_browsers(command, browsers)
|
65
|
+
|
66
|
+
command.run
|
58
67
|
end
|
59
68
|
|
60
69
|
# runs the tests specified by the argument
|
@@ -63,34 +72,62 @@ module JsTestDriver
|
|
63
72
|
# 'TestCase' or 'TestCase.test'
|
64
73
|
# to run either a single test case or a single test
|
65
74
|
def run_tests(tests = nil)
|
66
|
-
|
75
|
+
command = execute_jar
|
76
|
+
|
77
|
+
add_with_config(command)
|
78
|
+
add_run_tests(command, tests)
|
79
|
+
|
80
|
+
command.run
|
67
81
|
end
|
68
82
|
|
69
|
-
|
83
|
+
def start_server_capture_and_run(tests, browsers, output_xml_path = nil, console = nil)
|
84
|
+
command = execute_jar
|
85
|
+
|
86
|
+
add_start_server(command)
|
87
|
+
add_with_config(command)
|
88
|
+
add_capture_browsers(command, browsers)
|
89
|
+
add_run_tests(command, tests)
|
90
|
+
add_output_directory(command, output_xml_path) if output_xml_path
|
91
|
+
add_capture_console(command) if console
|
70
92
|
|
71
|
-
|
72
|
-
execute_jar_command.option('--port', config.port)
|
93
|
+
command.run
|
73
94
|
end
|
74
95
|
|
75
|
-
def
|
76
|
-
|
96
|
+
def add_start_server(command)
|
97
|
+
command.option('--port', config.port)
|
77
98
|
end
|
78
99
|
|
79
|
-
def
|
100
|
+
def add_run_tests(command, tests)
|
101
|
+
command.option('--tests', tests || "all")
|
102
|
+
end
|
103
|
+
|
104
|
+
def add_capture_browsers(command, browsers)
|
80
105
|
browsers ||= config.browsers.join(',')
|
81
106
|
raise ArgumentError.new("No browsers defined!") if browsers == ""
|
82
|
-
|
107
|
+
command.option('--browser', browsers)
|
108
|
+
end
|
109
|
+
|
110
|
+
def add_output_directory(command, path)
|
111
|
+
path = File.expand_path(path)
|
112
|
+
FileUtils.mkdir_p(path) unless File.exists?(path)
|
113
|
+
command.option('--testOutput', path)
|
83
114
|
end
|
84
115
|
|
85
|
-
def
|
116
|
+
def add_capture_console(command)
|
117
|
+
command.option('--captureConsole')
|
118
|
+
end
|
119
|
+
|
120
|
+
def add_with_config(command)
|
86
121
|
save_config_file(config_yml_path)
|
87
|
-
|
122
|
+
command.option('--config', config_yml_path)
|
88
123
|
end
|
89
124
|
|
90
|
-
def
|
125
|
+
def execute_jar
|
91
126
|
Command.new('java').option('-jar', jar_path)
|
92
127
|
end
|
93
128
|
|
129
|
+
protected
|
130
|
+
|
94
131
|
def parse_config
|
95
132
|
source = ""
|
96
133
|
if File.exist?(config_path)
|
data/lib/js_test_driver/tasks.rb
CHANGED
@@ -17,4 +17,12 @@ namespace :js_test_driver do
|
|
17
17
|
JsTestDriver::Runner.new.capture_browsers(ENV['BROWSERS'])
|
18
18
|
end
|
19
19
|
|
20
|
+
desc "Starts the server, captures the browsers, runs the tests - all at the same time"
|
21
|
+
task :run do
|
22
|
+
config = JsTestDriver::Runner.new
|
23
|
+
output_path = ENV['OUTPUT_PATH']
|
24
|
+
output_path = config.generated_files_dir if ENV['OUTPUT_XML']
|
25
|
+
config.start_server_capture_and_run(ENV['TESTS'], ENV['BROWSERS'], output_path, ENV['CAPTURE_CONSOLE'])
|
26
|
+
end
|
27
|
+
|
20
28
|
end
|
data/test/unit/runner_test.rb
CHANGED
@@ -84,5 +84,13 @@ module JsTestDriver
|
|
84
84
|
runner.capture_browsers('aaa,bbb')
|
85
85
|
end
|
86
86
|
|
87
|
+
def test_should_run_with_all_arguments_at_once
|
88
|
+
runner = given_a_runner(:config => JsTestDriver::Config.new(:browsers => ['foo', 'bar', 'baz']))
|
89
|
+
|
90
|
+
expect_command_to_be_executed("java -jar #{runner.jar_path} --port 4224 --config #{runner.config_yml_path} --browser aaa,bbb --tests TestCase --testOutput #{File.expand_path('.js_test_driver')} --captureConsole")
|
91
|
+
|
92
|
+
runner.start_server_capture_and_run('TestCase', 'aaa,bbb', '.js_test_driver', true)
|
93
|
+
end
|
94
|
+
|
87
95
|
end
|
88
96
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: js-test-driver-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 5
|
10
|
+
version: 0.2.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Adam Pohorecki
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-09-
|
18
|
+
date: 2010-09-03 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|