js-test-driver-rails 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -3,3 +3,4 @@
3
3
  .bundle
4
4
  jsTestDriver.conf
5
5
  pkg/*
6
+ tags
data/README.markdown ADDED
@@ -0,0 +1,103 @@
1
+ JS Test Driver Rails
2
+ ====================
3
+
4
+ js-test-driver-rails is a thin wrapper for the JsTestDriver library: http://code.google.com/p/js-test-driver/
5
+
6
+ Configuration
7
+ ------------
8
+
9
+ To take advantage of js-test-driver-rails, you should create a js_test_driver.rb file in your RAILS_ROOT/config/ directory.
10
+
11
+ The file may contain following directives:
12
+
13
+ # the paths are relative to the current directory, but you can use absolute paths too
14
+ # this is different from the JsTestDriver which does not allow you to use absolute paths in the config file
15
+
16
+ # files to be included
17
+ # you can use Ruby globbing syntax (spec/js/**/*_spec.js), which will be automatically expanded
18
+ includes 'foo', 'bar', 'public/javascripts/*.js'
19
+
20
+ # files to be excluded, useful with globbing
21
+ excludes 'public/javascripts/fail.js'
22
+
23
+ # the host to which the test runner will connect, by default 'localhost'
24
+ host 'my-laptop'
25
+
26
+ # the port to which test runner will connect, and on which the test server will start, by default 4224
27
+ port 6666
28
+
29
+ # you can specify the default browsers which will be captured
30
+ browser 'firefox'
31
+
32
+ Note, that this is a ruby file, so the file/browser list can be generated dynamically - it's completely up to you.
33
+
34
+ For example in our project we examine a list of known browsers to determine the ones installed on the developer's system, and define only those that were found.
35
+
36
+ Similarly we get the list of .js files to include from our asset packaging solution.
37
+
38
+ HTML Fixtures
39
+ -------------
40
+
41
+ js-test-driver-rails also allows you to define HTML fixtures easily.
42
+
43
+ Imagine you have a directory structure like this:
44
+
45
+ RAILS_ROOT:
46
+ test/
47
+ js/
48
+ fixtures/
49
+ foo/
50
+ a.html
51
+ a.html
52
+
53
+ Then by defining the fixtures directory in your config file:
54
+
55
+ fixtures "test/js/fixtures"
56
+
57
+ At runtime, your tests will have access to the contents of the fixture files:
58
+
59
+ htmlFixtures.all["a"] // contents of the test/js/fixtures/a.html
60
+ htmlFixtures.all["foo/a"] // contents of the test/js/fixtures/foo/a.html
61
+
62
+ You can customize the namespace and fixture container name:
63
+
64
+ # the fixtures will be accessible through myApp.html["<fixture name goes here>"]
65
+ fixtures "test/js/fixtures", :name => "html", :namespace => "myApp"
66
+
67
+ Using Jasmine
68
+ -------------
69
+
70
+ By default JsTestDriver comes with a pretty simple Test::Unit like testing framework.
71
+ However it supports a couple of other frameworks, including Jasmine (http://pivotal.github.com/jasmine/), which is an RSpec-like BDD framework.
72
+
73
+ If you want to user Jasmine, simply add:
74
+
75
+ enable_jasmine
76
+
77
+ in your config file, somewhere before including your test files and you are golden:)
78
+
79
+ Rake tasks
80
+ ----------
81
+
82
+ This gem comes with some rake tasks, which you should require in your Rake file:
83
+
84
+ require "js_test_driver/tasks"
85
+
86
+ To start the js test driver server:
87
+
88
+ rake js_test_driver:start_server
89
+
90
+ To capture the default (or specified) browsers
91
+
92
+ rake js_test_driver:capture_browsers [BROWSERS=foo,bar,baz]
93
+
94
+ To run the tests (all or the specified ones)
95
+
96
+ rake js_test_driver:run_tests [TESTS=TestCase[.testMethod]]
97
+
98
+ To run the server, capture the browsers and run tests all in one command
99
+
100
+ rake js_test_driver:run [TESTS=TestCase[.testMethod]] [BROWSERS=foo,bar,baz] [OUTPUT_XML=1 | OUTPUT_PATH=/some/dir] [CAPTURE_CONSOLE=1]
101
+
102
+ This last task is mostly useful on CI, because it's much faster to run the server and capture the browsers once and then run the tests again and again in development mode.
103
+
@@ -17,18 +17,14 @@ module JsTestDriver
17
17
  #
18
18
  # JsTestDriver supports globbing
19
19
  def includes(*paths)
20
- paths.each do |path|
21
- self.included_files << File.expand_path(path)
22
- end
20
+ self.included_files.concat(expand_globs(paths))
23
21
  end
24
22
 
25
23
  # Files specified here will not be loaded, it's useful when combined with globbing in includes
26
24
  #
27
25
  # paths should be relative to root_dir
28
26
  def excludes(*paths)
29
- paths.each do |path|
30
- self.excluded_files << File.expand_path(path)
31
- end
27
+ self.excluded_files.concat(expand_globs(paths))
32
28
  end
33
29
 
34
30
  # Defines a browser to be captured by default
@@ -154,6 +150,11 @@ module JsTestDriver
154
150
 
155
151
  private
156
152
 
153
+ def expand_globs(paths)
154
+ with_expanded_paths = paths.map{|path| File.expand_path(path)}
155
+ return with_expanded_paths.map{|path| path.include?('*') ? Dir[path] : path}.flatten
156
+ end
157
+
157
158
  def fixture_file_name(fixture)
158
159
  File.expand_path(File.join(config_dir, "fixtures", fixture.namespace, "#{fixture.name}.js"))
159
160
  end
@@ -1,3 +1,3 @@
1
1
  module JsTestDriver
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
@@ -13,7 +13,7 @@ module JsTestDriver
13
13
  end
14
14
 
15
15
  def given_an_empty_config
16
- JsTestDriver::Config.new
16
+ JsTestDriver::Config.new
17
17
  end
18
18
 
19
19
  def test_empty_config
@@ -75,10 +75,21 @@ module JsTestDriver
75
75
  config = given_an_empty_config
76
76
 
77
77
  # when
78
- config.includes('src/*.js')
78
+ config.includes('src/foo.js')
79
79
 
80
80
  # then
81
- assert_config_includes config, 'load' => ['src/*.js']
81
+ assert_config_includes config, 'load' => ['src/foo.js']
82
+ end
83
+
84
+ def test_config_with_includes_with_globbing
85
+ # given
86
+ config = given_an_empty_config
87
+
88
+ # when
89
+ config.includes('test/fixtures/foo/**/*.html')
90
+
91
+ # then
92
+ assert_config_includes config, 'load' => ['test/fixtures/foo/bar/a.html', 'test/fixtures/foo/a.html']
82
93
  end
83
94
 
84
95
  def test_config_with_browsers
@@ -111,10 +122,21 @@ module JsTestDriver
111
122
  config = given_an_empty_config
112
123
 
113
124
  # when
114
- config.excludes('src/*.js')
125
+ config.excludes('test/fixtures/foo/**/*.html')
126
+
127
+ # then
128
+ assert_config_includes config, 'exclude' => ['test/fixtures/foo/bar/a.html', 'test/fixtures/foo/a.html']
129
+ end
130
+
131
+ def test_config_with_excludes_with_globbing
132
+ # given
133
+ config = given_an_empty_config
134
+
135
+ # when
136
+ config.excludes('src/foo.js')
115
137
 
116
138
  # then
117
- assert_config_includes config, 'exclude' => ['src/*.js']
139
+ assert_config_includes config, 'exclude' => ['src/foo.js']
118
140
  end
119
141
 
120
142
  def test_empty_config_file
@@ -167,7 +189,7 @@ module JsTestDriver
167
189
  config.config_dir = File.expand_path("configs")
168
190
 
169
191
  # when
170
- config.fixtures "fixture/directory", :name => "fixture_name", :namespace => "fixture_namespace"
192
+ config.fixtures "fixture/directory", :name => "fixture_name", :namespace => "fixture_namespace"
171
193
 
172
194
  # then
173
195
  assert_config_includes config, 'load' => ["fixtures/fixture_namespace/fixture_name.js"]
@@ -224,4 +246,4 @@ module JsTestDriver
224
246
  end
225
247
 
226
248
  end
227
- end
249
+ end
metadata CHANGED
@@ -1,8 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: js-test-driver-rails
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.3.1
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 3
8
+ - 2
9
+ version: 0.3.2
6
10
  platform: ruby
7
11
  authors:
8
12
  - Adam Pohorecki
@@ -10,7 +14,8 @@ autorequire:
10
14
  bindir: bin
11
15
  cert_chain: []
12
16
 
13
- date: 2011-04-19 00:00:00 Z
17
+ date: 2011-04-20 00:00:00 +02:00
18
+ default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: json
@@ -20,6 +25,8 @@ dependencies:
20
25
  requirements:
21
26
  - - ">="
22
27
  - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
23
30
  version: "0"
24
31
  type: :runtime
25
32
  version_requirements: *id001
@@ -31,6 +38,8 @@ dependencies:
31
38
  requirements:
32
39
  - - ">="
33
40
  - !ruby/object:Gem::Version
41
+ segments:
42
+ - 0
34
43
  version: "0"
35
44
  type: :runtime
36
45
  version_requirements: *id002
@@ -42,6 +51,8 @@ dependencies:
42
51
  requirements:
43
52
  - - ">="
44
53
  - !ruby/object:Gem::Version
54
+ segments:
55
+ - 0
45
56
  version: "0"
46
57
  type: :development
47
58
  version_requirements: *id003
@@ -60,7 +71,7 @@ files:
60
71
  - Gemfile
61
72
  - Gemfile.lock
62
73
  - LICENSE
63
- - README
74
+ - README.markdown
64
75
  - Rakefile
65
76
  - js-test-driver-rails.gemspec
66
77
  - lib/js_test_driver.rb
@@ -82,6 +93,7 @@ files:
82
93
  - test/unit/runner_test.rb
83
94
  - vendor/VERSIONS
84
95
  - vendor/js_test_driver.jar
96
+ has_rdoc: true
85
97
  homepage: http://github.com/psyho/js-test-driver-rails
86
98
  licenses: []
87
99
 
@@ -95,17 +107,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
95
107
  requirements:
96
108
  - - ">="
97
109
  - !ruby/object:Gem::Version
110
+ segments:
111
+ - 0
98
112
  version: "0"
99
113
  required_rubygems_version: !ruby/object:Gem::Requirement
100
114
  none: false
101
115
  requirements:
102
116
  - - ">="
103
117
  - !ruby/object:Gem::Version
118
+ segments:
119
+ - 0
104
120
  version: "0"
105
121
  requirements: []
106
122
 
107
123
  rubyforge_project: js-test-driver-rails
108
- rubygems_version: 1.7.2
124
+ rubygems_version: 1.3.7
109
125
  signing_key:
110
126
  specification_version: 3
111
127
  summary: A wrapper for JsTestDriver for use with ruby/rails projects
data/README DELETED
@@ -1,73 +0,0 @@
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
- # the paths are relative to the current directory, but you can use absolute paths too
8
- # this is different from the JsTestDriver which does not allow you to use absolute paths in the config file
9
- includes 'foo', 'bar', 'public/javascripts/*.js' # files to be included
10
- excludes 'public/javascripts/fail.js' # files to be excluded, useful with globbing
11
-
12
- host 'my-laptop' # the host to which the test runner will connect, by default 'localhost'
13
- port 6666 # the port to which test runner will connect, and on which the test server will start, by default 4224
14
-
15
- browser 'firefox' # you can specify the default browsers which will be captured
16
-
17
- Note, that this is a ruby file, so the file/browser list can be generated dynamically - it's completely up to you.
18
-
19
- For example in our project we examine a list of known browsers to determine the ones installed on the developer's system,
20
- and define only those that were found.
21
-
22
- Similarly we get the list of .js files to include from our asset packaging solution.
23
-
24
- js-test-driver-rails also allows you to define HTML fixtures easily.
25
-
26
- Imagine you have a directory structure like this:
27
-
28
- RAILS_ROOT:
29
- test/
30
- js/
31
- fixtures/
32
- foo/
33
- a.html
34
- a.html
35
-
36
- Then by defining the fixtures directory in your config file:
37
- fixtures "test/js/fixtures"
38
-
39
- At runtime, your tests will have access to the contents of the fixture files:
40
- htmlFixtures.all["a"] // contents of the test/js/fixtures/a.html
41
- htmlFixtures.all["foo/a"] // contents of the test/js/fixtures/foo/a.html
42
-
43
- You can customize the namespace and fixture container name:
44
- fixtures "test/js/fixtures", :name => "html", :namespace => "myApp"
45
-
46
- By default JsTestDriver comes with a pretty simple Test::Unit like testing framework.
47
- However it supports a couple of other frameworks, including Jasmine (http://pivotal.github.com/jasmine/), which
48
- is an RSpec-like BDD framework.
49
-
50
- If you want to user Jasmine, simply add:
51
- enable_jasmine
52
-
53
- in your config file, somewhere before including your test files and you are golden:)
54
-
55
- # the fixtures will be accessible through myApp.html["<fixture name goes here>"]
56
-
57
- This gem comes with some rake tasks:
58
-
59
- # start the js test driver server
60
- rake js_test_driver:start_server
61
-
62
- # capture the default (or specified) browsers
63
- rake js_test_driver:capture_browsers [BROWSERS=foo,bar,baz]
64
-
65
- # run the tests (all or the specified ones)
66
- rake js_test_driver:run_tests [TESTS=TestCase[.testMethod]]
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
-
73
- You can add these tasks by requiring "js_test_driver/tasks"