js-test-driver-rails 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +6 -0
- data/LICENSE +19 -0
- data/README +28 -0
- data/Rakefile +34 -0
- data/VERSION +1 -0
- data/lib/js_test_driver.rb +2 -0
- data/lib/js_test_driver/config.rb +116 -0
- data/lib/js_test_driver/runner.rb +143 -0
- data/lib/js_test_driver/tasks.rb +20 -0
- data/test/test_helper.rb +9 -0
- data/test/unit/config_test.rb +154 -0
- data/test/unit/jsTestDriver.conf +2 -0
- data/test/unit/runner_test.rb +88 -0
- data/vendor/js_test_driver.jar +0 -0
- metadata +138 -0
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2010 by Adam Pohorecki
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
js-test-driver-rails is a thin wrapper for the JsTestDriver library: http://code.google.com/p/js-test-driver/
|
2
|
+
|
3
|
+
To take advantage of it, you should create a js_test_driver.rb file in your RAILS_ROOT/config/ directory.
|
4
|
+
|
5
|
+
The file may contain following directives:
|
6
|
+
|
7
|
+
includes 'foo', 'bar', 'public/javascripts/*.js' # files to be included
|
8
|
+
excludes 'public/javascripts/fail.js' # files to be excluded, useful with globbing
|
9
|
+
|
10
|
+
host 'my-laptop' # the host to which the test runner will connect, by default 'localhost'
|
11
|
+
port 6666 # the port to which test runner will connect, and on which the test server will start, by default 4224
|
12
|
+
|
13
|
+
browser 'firefox' # you can specify the default browsers which will be captured
|
14
|
+
|
15
|
+
Note, that this is a ruby file, so the file/browser list can be generated dynamically - it's completely up to you.
|
16
|
+
|
17
|
+
This gem comes with 3 rake tasks:
|
18
|
+
|
19
|
+
# start the js test driver server
|
20
|
+
rake js_test_driver:start_server
|
21
|
+
|
22
|
+
# capture the default (or specified) browsers
|
23
|
+
rake js_test_driver:capture_browsers [BROWSERS=foo,bar,baz]
|
24
|
+
|
25
|
+
# run the tests (all or the specified ones)
|
26
|
+
rake js_test_driver:run_tests [TESTS=TestCase[.testMethod]]
|
27
|
+
|
28
|
+
You can add these tasks by requiring "js_test_driver/tasks"
|
data/Rakefile
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
|
4
|
+
Bundler.setup
|
5
|
+
|
6
|
+
require 'rake'
|
7
|
+
require 'rake/testtask'
|
8
|
+
require 'jeweler'
|
9
|
+
|
10
|
+
Rake::TestTask.new("test") do |test|
|
11
|
+
test.libs << 'test'
|
12
|
+
test.pattern = 'test/unit/**/*_test.rb'
|
13
|
+
test.verbose = true
|
14
|
+
end
|
15
|
+
|
16
|
+
Jeweler::Tasks.new do |gem|
|
17
|
+
gem.name = "js-test-driver-rails"
|
18
|
+
gem.summary = "A wrapper for JsTestDriver for use with ruby/rails projects"
|
19
|
+
gem.description = "Use ruby to configure JsTestDriver, capture browsers and run tests."
|
20
|
+
gem.email = "adam@pohorecki.pl"
|
21
|
+
gem.homepage = "http://github.com/psyho/js-test-driver-rails"
|
22
|
+
gem.authors = ["Adam Pohorecki"]
|
23
|
+
gem.rubyforge_project = "js-test-driver-rails"
|
24
|
+
gem.add_development_dependency "jeweler"
|
25
|
+
gem.add_development_dependency "mocha"
|
26
|
+
gem.add_development_dependency "jeweler"
|
27
|
+
gem.add_dependency "rake"
|
28
|
+
gem.files = FileList["[A-Z]*", "{bin,generators,lib,test,vendor}/**/*"]
|
29
|
+
end
|
30
|
+
|
31
|
+
Jeweler::GemcutterTasks.new
|
32
|
+
Jeweler::RubyforgeTasks.new do |rubyforge|
|
33
|
+
rubyforge.doc_task = "rdoc"
|
34
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
@@ -0,0 +1,116 @@
|
|
1
|
+
module JsTestDriver
|
2
|
+
# The Config class represents the YAML config file that is passed to JsTestDriver
|
3
|
+
#
|
4
|
+
# includes corresponds to load
|
5
|
+
# excludes corresponds to exclude
|
6
|
+
# server can be configures either using server, or host and port
|
7
|
+
#
|
8
|
+
# The configuration is very basic, however the fact that it is done in Ruby, gives the
|
9
|
+
# user a significant amount of freedom in terms of what is and is not loaded, and so on
|
10
|
+
class Config
|
11
|
+
|
12
|
+
def initialize(attributes = {})
|
13
|
+
self.attributes = attributes
|
14
|
+
end
|
15
|
+
|
16
|
+
# Adds a file to be loaded, the path *must* be relative to the yml config file (which is placed in the RAILS_ROOT
|
17
|
+
# by default)
|
18
|
+
#
|
19
|
+
# JsTestDriver supports globbing
|
20
|
+
def includes(*paths)
|
21
|
+
paths.each do |path|
|
22
|
+
self.included_files << path
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# Files specified here will not be loaded, it's useful when combined with globbing in includes
|
27
|
+
#
|
28
|
+
# paths should be relative to RAILS_ROOT
|
29
|
+
def excludes(*paths)
|
30
|
+
paths.each do |path|
|
31
|
+
self.excluded_files << path
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# Defines a browser to be captured by default
|
36
|
+
#
|
37
|
+
# This should be a string with no spaces (if you need to pass parameters to the browser you will
|
38
|
+
# need to create a shell script ans put it's name here)
|
39
|
+
def browser(browsers)
|
40
|
+
browsers.each do |browser|
|
41
|
+
self.browsers << browser
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
# config variable which has a regular setter,
|
46
|
+
# but also can be set by calling the "getter" with an argument
|
47
|
+
# and if called without an argument the getter will return the passed block
|
48
|
+
#
|
49
|
+
# Ex.
|
50
|
+
# A.define_config_variable(:foo) { @foo || "hello" }
|
51
|
+
# a = A.new
|
52
|
+
# a.foo # returns "hello"
|
53
|
+
# a.foo "foo"
|
54
|
+
# a.foo # returns "foo"
|
55
|
+
# a.foo = "bar"
|
56
|
+
# a.foo # returns "bar"
|
57
|
+
def self.define_config_variable(name, &block)
|
58
|
+
attr_writer name
|
59
|
+
|
60
|
+
define_method(name) do |*values|
|
61
|
+
unless values.empty?
|
62
|
+
self.send("#{name}=", values.first)
|
63
|
+
else
|
64
|
+
instance_eval(&block)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
# the port the server will use, by default 4224
|
70
|
+
define_config_variable(:port) { @port ||= 4224 }
|
71
|
+
|
72
|
+
# the host of the server, by default localhost
|
73
|
+
define_config_variable(:host) { @host ||= 'localhost' }
|
74
|
+
|
75
|
+
# the whole server string - unless overwritten will be constructed from host and port,
|
76
|
+
# if you specify server, host and port will be ignored
|
77
|
+
# but you still need to specify port for starting the server
|
78
|
+
define_config_variable(:server) { @server || "http://#{host}:#{port}" }
|
79
|
+
|
80
|
+
def included_files
|
81
|
+
@includes ||= []
|
82
|
+
end
|
83
|
+
|
84
|
+
def excluded_files
|
85
|
+
@excludes ||= []
|
86
|
+
end
|
87
|
+
|
88
|
+
attr_writer :browsers
|
89
|
+
|
90
|
+
def browsers
|
91
|
+
@browsers ||= []
|
92
|
+
end
|
93
|
+
|
94
|
+
def to_s
|
95
|
+
hash = {'server' => server}
|
96
|
+
hash['load'] = included_files unless included_files.empty?
|
97
|
+
hash['exclude'] = excluded_files unless excluded_files.empty?
|
98
|
+
return hash.to_yaml
|
99
|
+
end
|
100
|
+
|
101
|
+
def self.parse(string)
|
102
|
+
config = new
|
103
|
+
config.instance_eval(string)
|
104
|
+
return config
|
105
|
+
end
|
106
|
+
|
107
|
+
private
|
108
|
+
|
109
|
+
def attributes=(values)
|
110
|
+
values.each do |attr, value|
|
111
|
+
self.send("#{attr}=", value)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
116
|
+
end
|
@@ -0,0 +1,143 @@
|
|
1
|
+
module JsTestDriver
|
2
|
+
# The Runner class is used
|
3
|
+
class Runner
|
4
|
+
|
5
|
+
def initialize(attributes = {})
|
6
|
+
self.attributes = attributes
|
7
|
+
end
|
8
|
+
|
9
|
+
# configuration, by default it's parsed from config_path
|
10
|
+
attr_writer :config
|
11
|
+
|
12
|
+
def config
|
13
|
+
@config ||= parse_config
|
14
|
+
end
|
15
|
+
|
16
|
+
# this is the path of the config file, by default its `pwd`/config/js_test_driver.rb
|
17
|
+
attr_writer :config_path
|
18
|
+
|
19
|
+
def config_path
|
20
|
+
@config_path ||= default_config_path
|
21
|
+
end
|
22
|
+
|
23
|
+
# this is the path to the js test driver jar file, by default it's stored relatively to this file
|
24
|
+
attr_writer :jar_path
|
25
|
+
|
26
|
+
def jar_path
|
27
|
+
@jar_path ||= default_jar_path
|
28
|
+
end
|
29
|
+
|
30
|
+
# this is where the config yml file will be saved, by default its /tmp/js_test_driver.(contents MD5).yml
|
31
|
+
attr_writer :tmp_path
|
32
|
+
|
33
|
+
def config_yml_path
|
34
|
+
@tmp_path ||= default_config_yml_path
|
35
|
+
end
|
36
|
+
|
37
|
+
# starts the server on the default port specified in the config file
|
38
|
+
def start_server
|
39
|
+
start_server_command.run
|
40
|
+
end
|
41
|
+
|
42
|
+
# captures the browsers
|
43
|
+
#
|
44
|
+
# by default it will capture the browsers specified in the config,
|
45
|
+
# but you can pass an argument like 'opera,chrome,firefox' to capture opera, chrome and firefox
|
46
|
+
def capture_browsers(browsers = nil)
|
47
|
+
capture_browsers_command(browsers).run
|
48
|
+
end
|
49
|
+
|
50
|
+
# runs the tests specified by the argument
|
51
|
+
#
|
52
|
+
# by default it will run all the tests, but you can pass a string like:
|
53
|
+
# 'TestCase' or 'TestCase.test'
|
54
|
+
# to run either a single test case or a single test
|
55
|
+
def run_tests(tests = nil)
|
56
|
+
run_tests_command(tests).run
|
57
|
+
end
|
58
|
+
|
59
|
+
protected
|
60
|
+
|
61
|
+
def start_server_command
|
62
|
+
execute_jar_command.option('--port', config.port)
|
63
|
+
end
|
64
|
+
|
65
|
+
def run_tests_command(tests)
|
66
|
+
run_with_config.option('--tests', tests || "all") #.option('--runnerMode', 'DEBUG')
|
67
|
+
end
|
68
|
+
|
69
|
+
def capture_browsers_command(browsers)
|
70
|
+
browsers ||= config.browsers.join(',')
|
71
|
+
raise ArgumentError.new("No browsers defined!") if browsers == ""
|
72
|
+
run_with_config.option('--browser', browsers)
|
73
|
+
end
|
74
|
+
|
75
|
+
def run_with_config
|
76
|
+
save_config_file(config_yml_path)
|
77
|
+
execute_jar_command.option('--config', config_yml_path)
|
78
|
+
end
|
79
|
+
|
80
|
+
def execute_jar_command
|
81
|
+
Command.new('java').option('-jar', jar_path)
|
82
|
+
end
|
83
|
+
|
84
|
+
def parse_config
|
85
|
+
source = ""
|
86
|
+
if File.exist?(config_path)
|
87
|
+
source = File.read(config_path)
|
88
|
+
else
|
89
|
+
warn("Could not find JS Test Driver config: '#{config_path}', assuming empty config file!")
|
90
|
+
end
|
91
|
+
JsTestDriver::Config.parse(source)
|
92
|
+
end
|
93
|
+
|
94
|
+
def default_config_path
|
95
|
+
root = defined?(RAILS_ROOT) ? RAILS_ROOT : '.'
|
96
|
+
return File.expand_path(File.join(root, 'config', 'js_test_driver.rb'))
|
97
|
+
end
|
98
|
+
|
99
|
+
def default_jar_path
|
100
|
+
current_dir = File.dirname(__FILE__)
|
101
|
+
path = File.join(current_dir, '..', '..', 'vendor', 'js_test_driver.jar')
|
102
|
+
return File.expand_path(path)
|
103
|
+
end
|
104
|
+
|
105
|
+
def default_config_yml_path
|
106
|
+
return File.expand_path("jsTestDriver.conf")
|
107
|
+
end
|
108
|
+
|
109
|
+
private
|
110
|
+
|
111
|
+
def save_config_file(path)
|
112
|
+
File.open(path, "w+") { |f| f.puts config.to_s }
|
113
|
+
end
|
114
|
+
|
115
|
+
def attributes=(values)
|
116
|
+
values.each do |attr, value|
|
117
|
+
self.send("#{attr}=", value)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
class Command
|
122
|
+
def initialize(executable)
|
123
|
+
@command = "#{executable}"
|
124
|
+
end
|
125
|
+
|
126
|
+
def option(name, value = nil)
|
127
|
+
value = "'#{value}'" if value && value =~ /\s/
|
128
|
+
@command = [@command, name, value].compact.join(' ')
|
129
|
+
self
|
130
|
+
end
|
131
|
+
|
132
|
+
def run
|
133
|
+
system(self.to_s)
|
134
|
+
end
|
135
|
+
|
136
|
+
def to_s
|
137
|
+
return @command
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
end
|
142
|
+
|
143
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'js_test_driver'))
|
2
|
+
|
3
|
+
namespace :js_test_driver do
|
4
|
+
|
5
|
+
desc "Starts the server using the provided configuration variables"
|
6
|
+
task :start_server do
|
7
|
+
JsTestDriver::Runner.new.start_server
|
8
|
+
end
|
9
|
+
|
10
|
+
desc "Runs the javascript tests"
|
11
|
+
task :run_tests do
|
12
|
+
exit(1) unless JsTestDriver::Runner.new.run_tests(ENV['TESTS'])
|
13
|
+
end
|
14
|
+
|
15
|
+
desc "Capture the browsers defined in config"
|
16
|
+
task :capture_browsers do
|
17
|
+
JsTestDriver::Runner.new.capture_browsers(ENV['BROWSERS'])
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,154 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper'))
|
2
|
+
|
3
|
+
module JsTestDriver
|
4
|
+
class ConfigTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def default_result
|
7
|
+
{'server' => 'http://localhost:4224'}
|
8
|
+
end
|
9
|
+
|
10
|
+
def assert_config_includes(config, hash)
|
11
|
+
expected = default_result.merge(hash)
|
12
|
+
assert_equal expected, YAML::load(config.to_s)
|
13
|
+
end
|
14
|
+
|
15
|
+
def given_an_empty_config
|
16
|
+
JsTestDriver::Config.new
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_empty_config
|
20
|
+
# given
|
21
|
+
config = given_an_empty_config
|
22
|
+
|
23
|
+
# then
|
24
|
+
assert_config_includes(config, default_result)
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_custom_port
|
28
|
+
# given
|
29
|
+
config = given_an_empty_config
|
30
|
+
|
31
|
+
# when
|
32
|
+
config.port 666
|
33
|
+
|
34
|
+
# then
|
35
|
+
assert_config_includes config, 'server' => 'http://localhost:666'
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_custom_host
|
39
|
+
# given
|
40
|
+
config = given_an_empty_config
|
41
|
+
|
42
|
+
# when
|
43
|
+
config.host 'example.com'
|
44
|
+
|
45
|
+
# then
|
46
|
+
assert_config_includes config, 'server' => 'http://example.com:4224'
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_custom_server
|
50
|
+
# given
|
51
|
+
config = given_an_empty_config
|
52
|
+
|
53
|
+
# when
|
54
|
+
config.server 'https://example.com:443'
|
55
|
+
|
56
|
+
# then
|
57
|
+
assert_config_includes config, 'server' => 'https://example.com:443'
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_server_should_override_host_and_port
|
61
|
+
# given
|
62
|
+
config = given_an_empty_config
|
63
|
+
|
64
|
+
# when
|
65
|
+
config.port 666
|
66
|
+
config.host 'test.com'
|
67
|
+
config.server 'https://example.com:443'
|
68
|
+
|
69
|
+
# then
|
70
|
+
assert_config_includes config, 'server' => 'https://example.com:443'
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_config_with_includes
|
74
|
+
# given
|
75
|
+
config = given_an_empty_config
|
76
|
+
|
77
|
+
# when
|
78
|
+
config.includes('src/*.js')
|
79
|
+
|
80
|
+
# then
|
81
|
+
assert_config_includes config, 'load' => ['src/*.js']
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_config_with_browsers
|
85
|
+
# given
|
86
|
+
config = given_an_empty_config
|
87
|
+
|
88
|
+
# when
|
89
|
+
config.browser('firefox')
|
90
|
+
config.browser('chrome')
|
91
|
+
|
92
|
+
# then
|
93
|
+
assert_equal ['firefox', 'chrome'], config.browsers
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_config_with_multiple_includes
|
97
|
+
# given
|
98
|
+
config = given_an_empty_config
|
99
|
+
|
100
|
+
# when
|
101
|
+
['a', 'b', 'c'].each do |name|
|
102
|
+
config.includes(name)
|
103
|
+
end
|
104
|
+
|
105
|
+
# then
|
106
|
+
assert_config_includes config, 'load' => ['a', 'b', 'c']
|
107
|
+
end
|
108
|
+
|
109
|
+
def test_config_with_excludes
|
110
|
+
# given
|
111
|
+
config = given_an_empty_config
|
112
|
+
|
113
|
+
# when
|
114
|
+
config.excludes('src/*.js')
|
115
|
+
|
116
|
+
# then
|
117
|
+
assert_config_includes config, 'exclude' => ['src/*.js']
|
118
|
+
end
|
119
|
+
|
120
|
+
def test_empty_config_file
|
121
|
+
# given
|
122
|
+
str = ""
|
123
|
+
|
124
|
+
# when
|
125
|
+
config = JsTestDriver::Config.parse(str)
|
126
|
+
|
127
|
+
# then
|
128
|
+
assert_equal [], config.included_files
|
129
|
+
assert_equal [], config.excluded_files
|
130
|
+
assert_equal "http://localhost:4224", config.server
|
131
|
+
end
|
132
|
+
|
133
|
+
def test_sample_config_file
|
134
|
+
# given
|
135
|
+
str = <<-CONFIG
|
136
|
+
includes 'a', 'b'
|
137
|
+
includes 'c'
|
138
|
+
|
139
|
+
excludes 'd'
|
140
|
+
|
141
|
+
server 'http://example.com:666'
|
142
|
+
CONFIG
|
143
|
+
|
144
|
+
# when
|
145
|
+
config = JsTestDriver::Config.parse(str)
|
146
|
+
|
147
|
+
# then
|
148
|
+
assert_equal ['a', 'b', 'c'], config.included_files
|
149
|
+
assert_equal ['d'], config.excluded_files
|
150
|
+
assert_equal 'http://example.com:666', config.server
|
151
|
+
end
|
152
|
+
|
153
|
+
end
|
154
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper'))
|
2
|
+
|
3
|
+
module JsTestDriver
|
4
|
+
class RunnerTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def given_a_runner(opts = {})
|
7
|
+
return JsTestDriver::Runner.new(opts)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_should_have_default_config_path
|
11
|
+
# given
|
12
|
+
runner = given_a_runner
|
13
|
+
|
14
|
+
# then
|
15
|
+
assert runner.config_path
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_should_have_default_jar_path
|
19
|
+
# given
|
20
|
+
runner = given_a_runner
|
21
|
+
|
22
|
+
# then
|
23
|
+
assert runner.jar_path
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_should_have_default_tmp_path
|
27
|
+
# given
|
28
|
+
runner = given_a_runner
|
29
|
+
|
30
|
+
# then
|
31
|
+
assert runner.config_yml_path
|
32
|
+
end
|
33
|
+
|
34
|
+
def expect_command_to_be_executed(cmd)
|
35
|
+
JsTestDriver::Runner::Command.any_instance.expects(:system).with(cmd)
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_should_run_server_with_given_port_number
|
39
|
+
config = JsTestDriver::Config.new(:port => 6666)
|
40
|
+
runner = given_a_runner(:config => config)
|
41
|
+
|
42
|
+
expect_command_to_be_executed("java -jar #{runner.jar_path} --port #{config.port}")
|
43
|
+
|
44
|
+
runner.start_server
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_should_run_all_tests_by_default
|
48
|
+
runner = given_a_runner(:config => JsTestDriver::Config.new)
|
49
|
+
|
50
|
+
expect_command_to_be_executed("java -jar #{runner.jar_path} --config #{runner.config_yml_path} --tests all")
|
51
|
+
|
52
|
+
runner.run_tests
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_should_run_selected_tests
|
56
|
+
runner = given_a_runner(:config => JsTestDriver::Config.new)
|
57
|
+
|
58
|
+
expect_command_to_be_executed("java -jar #{runner.jar_path} --config #{runner.config_yml_path} --tests MyTestCase.some_test")
|
59
|
+
|
60
|
+
runner.run_tests('MyTestCase.some_test')
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_should_raise_exception_if_no_browsers_defined_to_capture
|
64
|
+
runner = given_a_runner(:config => JsTestDriver::Config.new)
|
65
|
+
|
66
|
+
assert_raises(ArgumentError) do
|
67
|
+
runner.capture_browsers
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_should_capture_default_browsers
|
72
|
+
runner = given_a_runner(:config => JsTestDriver::Config.new(:browsers => ['foo', 'bar', 'baz']))
|
73
|
+
|
74
|
+
expect_command_to_be_executed("java -jar #{runner.jar_path} --config #{runner.config_yml_path} --browser foo,bar,baz")
|
75
|
+
|
76
|
+
runner.capture_browsers
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_should_capture_given_browsers
|
80
|
+
runner = given_a_runner(:config => JsTestDriver::Config.new(:browsers => ['foo', 'bar', 'baz']))
|
81
|
+
|
82
|
+
expect_command_to_be_executed("java -jar #{runner.jar_path} --config #{runner.config_yml_path} --browser aaa,bbb")
|
83
|
+
|
84
|
+
runner.capture_browsers('aaa,bbb')
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
end
|
Binary file
|
metadata
ADDED
@@ -0,0 +1,138 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: js-test-driver-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Adam Pohorecki
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-09-01 00:00:00 +02:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
prerelease: false
|
23
|
+
name: jeweler
|
24
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
requirement: *id001
|
34
|
+
type: :development
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
prerelease: false
|
37
|
+
name: mocha
|
38
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
version: "0"
|
47
|
+
requirement: *id002
|
48
|
+
type: :development
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
prerelease: false
|
51
|
+
name: jeweler
|
52
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
hash: 3
|
58
|
+
segments:
|
59
|
+
- 0
|
60
|
+
version: "0"
|
61
|
+
requirement: *id003
|
62
|
+
type: :development
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
prerelease: false
|
65
|
+
name: rake
|
66
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
hash: 3
|
72
|
+
segments:
|
73
|
+
- 0
|
74
|
+
version: "0"
|
75
|
+
requirement: *id004
|
76
|
+
type: :runtime
|
77
|
+
description: Use ruby to configure JsTestDriver, capture browsers and run tests.
|
78
|
+
email: adam@pohorecki.pl
|
79
|
+
executables: []
|
80
|
+
|
81
|
+
extensions: []
|
82
|
+
|
83
|
+
extra_rdoc_files:
|
84
|
+
- LICENSE
|
85
|
+
- README
|
86
|
+
files:
|
87
|
+
- Gemfile
|
88
|
+
- LICENSE
|
89
|
+
- README
|
90
|
+
- Rakefile
|
91
|
+
- VERSION
|
92
|
+
- lib/js_test_driver.rb
|
93
|
+
- lib/js_test_driver/config.rb
|
94
|
+
- lib/js_test_driver/runner.rb
|
95
|
+
- lib/js_test_driver/tasks.rb
|
96
|
+
- test/test_helper.rb
|
97
|
+
- test/unit/config_test.rb
|
98
|
+
- test/unit/jsTestDriver.conf
|
99
|
+
- test/unit/runner_test.rb
|
100
|
+
- vendor/js_test_driver.jar
|
101
|
+
has_rdoc: true
|
102
|
+
homepage: http://github.com/psyho/js-test-driver-rails
|
103
|
+
licenses: []
|
104
|
+
|
105
|
+
post_install_message:
|
106
|
+
rdoc_options:
|
107
|
+
- --charset=UTF-8
|
108
|
+
require_paths:
|
109
|
+
- lib
|
110
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
111
|
+
none: false
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
hash: 3
|
116
|
+
segments:
|
117
|
+
- 0
|
118
|
+
version: "0"
|
119
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
|
+
none: false
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
hash: 3
|
125
|
+
segments:
|
126
|
+
- 0
|
127
|
+
version: "0"
|
128
|
+
requirements: []
|
129
|
+
|
130
|
+
rubyforge_project: js-test-driver-rails
|
131
|
+
rubygems_version: 1.3.7
|
132
|
+
signing_key:
|
133
|
+
specification_version: 3
|
134
|
+
summary: A wrapper for JsTestDriver for use with ruby/rails projects
|
135
|
+
test_files:
|
136
|
+
- test/unit/runner_test.rb
|
137
|
+
- test/unit/config_test.rb
|
138
|
+
- test/test_helper.rb
|