jasmine 0.11.0.0 → 0.11.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,58 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
- require 'rubygems'
3
- require 'rake'
4
-
5
- def cwd
6
- File.expand_path(File.join(File.dirname(__FILE__), '..'))
7
- end
8
-
9
- def expand(*paths)
10
- File.expand_path(File.join(*paths))
11
- end
12
-
13
- def template_path(filepath)
14
- expand(cwd, File.join("generators/jasmine/templates", filepath))
15
- end
16
-
17
- def dest_path(filepath)
18
- expand(Dir.pwd, filepath)
19
- end
20
2
 
21
- def copy_unless_exists(relative_path, dest_path = nil)
22
- unless File.exist?(dest_path(relative_path))
23
- File.copy(template_path(relative_path), dest_path(dest_path || relative_path))
24
- end
25
- end
26
-
27
- if ARGV[0] == 'init'
28
- require 'ftools'
29
- File.makedirs('spec/javascripts')
30
- File.makedirs('spec/javascripts/support')
31
- File.makedirs('spec/javascripts/helpers')
32
-
33
- copy_unless_exists('spec/javascripts/helpers/SpecHelper.js')
34
- copy_unless_exists('spec/javascripts/ExampleSpec.js')
35
- copy_unless_exists('spec/javascripts/support/jasmine_runner.rb')
36
-
37
- rails_tasks_dir = dest_path('lib/tasks')
38
- if File.exist?(rails_tasks_dir)
39
- copy_unless_exists('lib/tasks/jasmine.rake')
40
- copy_unless_exists('spec/javascripts/support/jasmine-rails.yml', 'spec/javascripts/support/jasmine.yml')
41
- else
42
- copy_unless_exists('spec/javascripts/support/jasmine.yml')
43
- write_mode = 'w'
44
- if File.exist?(dest_path('Rakefile'))
45
- load dest_path('Rakefile')
46
- write_mode = 'a'
47
- end
48
- unless Rake::Task.task_defined?('jasmine')
49
- File.open(dest_path('Rakefile'), write_mode) do |f|
50
- f.write(File.read(template_path('lib/tasks/jasmine.rake')))
51
- end
52
- end
53
- end
54
- File.open(template_path('INSTALL'), 'r').each_line do |line|
55
- puts line
56
- end
57
- end
3
+ require 'rubygems'
4
+ require 'jasmine'
58
5
 
6
+ Jasmine::CommandLineTool.new.process ARGV
@@ -2,11 +2,15 @@ class JasmineGenerator < Rails::Generator::Base
2
2
  def manifest
3
3
  record do |m|
4
4
 
5
+ m.directory "public/javascripts"
6
+ m.file "jasmine-example/src/Player.js", "public/javascripts/Player.js"
7
+ m.file "jasmine-example/src/Song.js", "public/javascripts/Song.js"
8
+
5
9
  m.directory "spec/javascripts"
6
- m.file "spec/javascripts/ExampleSpec.js", "spec/javascripts/ExampleSpec.js"
10
+ m.file "jasmine-example/spec/PlayerSpec.js", "spec/javascripts/PlayerSpec.js"
7
11
 
8
12
  m.directory "spec/javascripts/helpers"
9
- m.file "spec/javascripts/helpers/SpecHelper.js", "spec/javascripts/helpers/SpecHelper.js"
13
+ m.file "jasmine-example/spec/SpecHelper.js", "spec/javascripts/helpers/SpecHelper.js"
10
14
 
11
15
  m.directory "spec/javascripts/support"
12
16
  m.file "spec/javascripts/support/jasmine_runner.rb", "spec/javascripts/support/jasmine_runner.rb"
@@ -0,0 +1,27 @@
1
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2
+ "http://www.w3.org/TR/html4/loose.dtd">
3
+ <html>
4
+ <head>
5
+ <title>Jasmine Test Runner</title>
6
+ <link rel="stylesheet" type="text/css" href="lib/jasmine-##JASMINE_VERSION##/jasmine.css">
7
+ <script type="text/javascript" src="lib/jasmine-##JASMINE_VERSION##/jasmine.js"></script>
8
+ <script type="text/javascript" src="lib/jasmine-##JASMINE_VERSION##/jasmine-html.js"></script>
9
+
10
+ <!-- include source files here... -->
11
+ <script type="text/javascript" src="src/Player.js"></script>
12
+ <script type="text/javascript" src="src/Song.js"></script>
13
+
14
+ <!-- include spec files here... -->
15
+ <script type="text/javascript" src="spec/SpecHelper.js"></script>
16
+ <script type="text/javascript" src="spec/PlayerSpec.js"></script>
17
+
18
+ </head>
19
+ <body>
20
+ <script type="text/javascript">
21
+ jasmine.getEnv().addReporter(new jasmine.TrivialReporter());
22
+ jasmine.getEnv().execute();
23
+ </script>
24
+
25
+ </body>
26
+ </html>
27
+
@@ -0,0 +1,58 @@
1
+ describe("Player", function() {
2
+ var player;
3
+ var song;
4
+
5
+ beforeEach(function() {
6
+ player = new Player();
7
+ song = new Song();
8
+ });
9
+
10
+ it("should be able to play a Song", function() {
11
+ player.play(song);
12
+ expect(player.currentlyPlayingSong).toEqual(song);
13
+
14
+ //demonstrates use of custom matcher
15
+ expect(player).toBePlaying(song);
16
+ });
17
+
18
+ describe("when song has been paused", function() {
19
+ beforeEach(function() {
20
+ player.play(song);
21
+ player.pause();
22
+ });
23
+
24
+ it("should indicate that the song is currently paused", function() {
25
+ expect(player.isPlaying).toBeFalsy();
26
+
27
+ // demonstrates use of 'not' with a custom matcher
28
+ expect(player).not.toBePlaying(song);
29
+ });
30
+
31
+ it("should be possible to resume", function() {
32
+ player.resume();
33
+ expect(player.isPlaying).toBeTruthy();
34
+ expect(player.currentlyPlayingSong).toEqual(song);
35
+ });
36
+ });
37
+
38
+ // demonstrates use of spies to intercept and test method calls
39
+ it("tells the current song if the user has made it a favorite", function() {
40
+ spyOn(song, 'persistFavoriteStatus');
41
+
42
+ player.play(song);
43
+ player.makeFavorite();
44
+
45
+ expect(song.persistFavoriteStatus).toHaveBeenCalledWith(true);
46
+ });
47
+
48
+ //demonstrates use of expected exceptions
49
+ describe("#resume", function() {
50
+ it("should throw an exception if song is already playing", function() {
51
+ player.play(song);
52
+
53
+ expect(function() {
54
+ player.resume();
55
+ }).toThrow("song is already playing");
56
+ });
57
+ });
58
+ });
@@ -0,0 +1,9 @@
1
+ beforeEach(function() {
2
+ this.addMatchers({
3
+ toBePlaying: function(expectedSong) {
4
+ var player = this.actual;
5
+ return player.currentlyPlayingSong === expectedSong
6
+ && player.isPlaying;
7
+ }
8
+ })
9
+ });
@@ -0,0 +1,22 @@
1
+ function Player() {
2
+ }
3
+ Player.prototype.play = function(song) {
4
+ this.currentlyPlayingSong = song;
5
+ this.isPlaying = true;
6
+ };
7
+
8
+ Player.prototype.pause = function() {
9
+ this.isPlaying = false;
10
+ };
11
+
12
+ Player.prototype.resume = function() {
13
+ if (this.isPlaying) {
14
+ throw new Error("song is already playing");
15
+ }
16
+
17
+ this.isPlaying = true;
18
+ };
19
+
20
+ Player.prototype.makeFavorite = function() {
21
+ this.currentlyPlayingSong.persistFavoriteStatus(true);
22
+ };
@@ -0,0 +1,7 @@
1
+ function Song() {
2
+ }
3
+
4
+ Song.prototype.persistFavoriteStatus = function(value) {
5
+ // something complicated
6
+ throw new Error("not yet implemented");
7
+ };
@@ -1,31 +1,2 @@
1
- namespace :jasmine do
2
- task :require do
3
- require 'jasmine'
4
- end
5
-
6
- desc "Run continuous integration tests"
7
- task :ci => "jasmine:require" do
8
- require "spec"
9
- require 'spec/rake/spectask'
10
-
11
- Spec::Rake::SpecTask.new(:jasmine_continuous_integration_runner) do |t|
12
- t.spec_opts = ["--color", "--format", "specdoc"]
13
- t.verbose = true
14
- t.spec_files = ['spec/javascripts/support/jasmine_runner.rb']
15
- end
16
- Rake::Task["jasmine_continuous_integration_runner"].invoke
17
- end
18
-
19
- task :server => "jasmine:require" do
20
- jasmine_config_overrides = 'spec/javascripts/support/jasmine_config.rb'
21
- require jasmine_config_overrides if File.exists?(jasmine_config_overrides)
22
-
23
- puts "your tests are here:"
24
- puts " http://localhost:8888/"
25
-
26
- Jasmine::Config.new.start_server
27
- end
28
- end
29
-
30
- desc "Run specs via server"
31
- task :jasmine => ['jasmine:server']
1
+ require 'jasmine'
2
+ load 'jasmine/tasks/jasmine.rake'
@@ -16,6 +16,7 @@ src_files:
16
16
  - public/javascripts/controls.js
17
17
  - public/javascripts/dragdrop.js
18
18
  - public/javascripts/application.js
19
+ - public/javascripts/**/*.js
19
20
 
20
21
  # stylesheets
21
22
  #
@@ -11,6 +11,7 @@
11
11
  # - dist/**/*.js
12
12
  #
13
13
  src_files:
14
+ - public/javascripts/**/*.js
14
15
 
15
16
  # stylesheets
16
17
  #
@@ -1,3 +1,5 @@
1
+ $:.unshift(ENV['JASMINE_GEM_PATH']) if ENV['JASMINE_GEM_PATH'] # for gem testing purposes
2
+
1
3
  require 'rubygems'
2
4
  require 'jasmine'
3
5
  jasmine_config_overrides = File.expand_path(File.join(File.dirname(__FILE__), 'jasmine_config.rb'))
@@ -0,0 +1,27 @@
1
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2
+ "http://www.w3.org/TR/html4/loose.dtd">
3
+ <html>
4
+ <head>
5
+ <title>Jasmine Test Runner</title>
6
+ <link rel="stylesheet" type="text/css" href="lib/jasmine-##JASMINE_VERSION##/jasmine.css">
7
+ <script type="text/javascript" src="lib/jasmine-##JASMINE_VERSION##/jasmine.js"></script>
8
+ <script type="text/javascript" src="lib/jasmine-##JASMINE_VERSION##/jasmine-html.js"></script>
9
+
10
+ <!-- include source files here... -->
11
+ <script type="text/javascript" src="src/Player.js"></script>
12
+ <script type="text/javascript" src="src/Song.js"></script>
13
+
14
+ <!-- include spec files here... -->
15
+ <script type="text/javascript" src="spec/SpecHelper.js"></script>
16
+ <script type="text/javascript" src="spec/PlayerSpec.js"></script>
17
+
18
+ </head>
19
+ <body>
20
+ <script type="text/javascript">
21
+ jasmine.getEnv().addReporter(new jasmine.TrivialReporter());
22
+ jasmine.getEnv().execute();
23
+ </script>
24
+
25
+ </body>
26
+ </html>
27
+
@@ -1,6 +1,7 @@
1
1
  jasmine.TrivialReporter = function(doc) {
2
2
  this.document = doc || document;
3
3
  this.suiteDivs = {};
4
+ this.logRunningSpecs = false;
4
5
  };
5
6
 
6
7
  jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarArgs) {
@@ -115,6 +116,12 @@ jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) {
115
116
  this.suiteDivs[suite.id].className += " " + status;
116
117
  };
117
118
 
119
+ jasmine.TrivialReporter.prototype.reportSpecStarting = function(spec) {
120
+ if (this.logRunningSpecs) {
121
+ this.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...');
122
+ }
123
+ };
124
+
118
125
  jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) {
119
126
  var results = spec.results();
120
127
  var status = results.passed() ? 'passed' : 'failed';
@@ -172,7 +172,7 @@ jasmine.isDomNode = function(obj) {
172
172
  *
173
173
  * @example
174
174
  * // don't care about which function is passed in, as long as it's a function
175
- * expect(mySpy).wasCalledWith(jasmine.any(Function));
175
+ * expect(mySpy).toHaveBeenCalledWith(jasmine.any(Function));
176
176
  *
177
177
  * @param {Class} clazz
178
178
  * @returns matchable object of the type clazz
@@ -187,7 +187,8 @@ jasmine.any = function(clazz) {
187
187
  * Spies should be created in test setup, before expectations. They can then be checked, using the standard Jasmine
188
188
  * expectation syntax. Spies can be checked if they were called or not and what the calling params were.
189
189
  *
190
- * A Spy has the following mehtod: wasCalled, callCount, mostRecentCall, and argsForCall (see docs)
190
+ * A Spy has the following fields: wasCalled, callCount, mostRecentCall, and argsForCall (see docs).
191
+ *
191
192
  * Spies are torn down at the end of every spec.
192
193
  *
193
194
  * Note: Do <b>not</b> call new jasmine.Spy() directly - a spy must be created using spyOn, jasmine.createSpy or jasmine.createSpyObj.
@@ -217,8 +218,8 @@ jasmine.any = function(clazz) {
217
218
  *
218
219
  * // mock example
219
220
  * foo.not(7 == 7);
220
- * expect(foo.not).wasCalled();
221
- * expect(foo.not).wasCalledWith(true);
221
+ * expect(foo.not).toHaveBeenCalled();
222
+ * expect(foo.not).toHaveBeenCalledWith(true);
222
223
  *
223
224
  * @constructor
224
225
  * @see spyOn, jasmine.createSpy, jasmine.createSpyObj
@@ -928,6 +929,10 @@ jasmine.Reporter.prototype.reportRunnerResults = function(runner) {
928
929
  jasmine.Reporter.prototype.reportSuiteResults = function(suite) {
929
930
  };
930
931
 
932
+ //noinspection JSUnusedLocalSymbols
933
+ jasmine.Reporter.prototype.reportSpecStarting = function(spec) {
934
+ };
935
+
931
936
  //noinspection JSUnusedLocalSymbols
932
937
  jasmine.Reporter.prototype.reportSpecResults = function(spec) {
933
938
  };
@@ -1224,12 +1229,18 @@ jasmine.Matchers.prototype.toBeFalsy = function() {
1224
1229
  return !this.actual;
1225
1230
  };
1226
1231
 
1232
+
1233
+ /** @deprecated Use expect(xxx).toHaveBeenCalled() instead */
1234
+ jasmine.Matchers.prototype.wasCalled = function() {
1235
+ return this.toHaveBeenCalled();
1236
+ };
1237
+
1227
1238
  /**
1228
1239
  * Matcher that checks to see if the actual, a Jasmine spy, was called.
1229
1240
  */
1230
- jasmine.Matchers.prototype.wasCalled = function() {
1241
+ jasmine.Matchers.prototype.toHaveBeenCalled = function() {
1231
1242
  if (arguments.length > 0) {
1232
- throw new Error('wasCalled does not take arguments, use wasCalledWith');
1243
+ throw new Error('toHaveBeenCalled does not take arguments, use toHaveBeenCalledWith');
1233
1244
  }
1234
1245
 
1235
1246
  if (!jasmine.isSpy(this.actual)) {
@@ -1245,6 +1256,8 @@ jasmine.Matchers.prototype.wasCalled = function() {
1245
1256
 
1246
1257
  /**
1247
1258
  * Matcher that checks to see if the actual, a Jasmine spy, was not called.
1259
+ *
1260
+ * @deprecated Use expect(xxx).not.toHaveBeenCalled() instead
1248
1261
  */
1249
1262
  jasmine.Matchers.prototype.wasNotCalled = function() {
1250
1263
  if (arguments.length > 0) {
@@ -1262,13 +1275,18 @@ jasmine.Matchers.prototype.wasNotCalled = function() {
1262
1275
  return !this.actual.wasCalled;
1263
1276
  };
1264
1277
 
1278
+ /** @deprecated Use expect(xxx).toHaveBeenCalledWith() instead */
1279
+ jasmine.Matchers.prototype.wasCalledWith = function() {
1280
+ return this.toHaveBeenCalledWith.apply(this, arguments);
1281
+ };
1282
+
1265
1283
  /**
1266
1284
  * Matcher that checks to see if the actual, a Jasmine spy, was called with a set of parameters.
1267
1285
  *
1268
1286
  * @example
1269
1287
  *
1270
1288
  */
1271
- jasmine.Matchers.prototype.wasCalledWith = function() {
1289
+ jasmine.Matchers.prototype.toHaveBeenCalledWith = function() {
1272
1290
  var expectedArgs = jasmine.util.argsToArray(arguments);
1273
1291
  if (!jasmine.isSpy(this.actual)) {
1274
1292
  throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');
@@ -1284,6 +1302,7 @@ jasmine.Matchers.prototype.wasCalledWith = function() {
1284
1302
  return this.env.contains_(this.actual.argsForCall, expectedArgs);
1285
1303
  };
1286
1304
 
1305
+ /** @deprecated Use expect(xxx).not.toHaveBeenCalledWith() instead */
1287
1306
  jasmine.Matchers.prototype.wasNotCalledWith = function() {
1288
1307
  var expectedArgs = jasmine.util.argsToArray(arguments);
1289
1308
  if (!jasmine.isSpy(this.actual)) {
@@ -1395,7 +1414,14 @@ jasmine.MultiReporter.prototype.addReporter = function(reporter) {
1395
1414
  };
1396
1415
 
1397
1416
  (function() {
1398
- var functionNames = ["reportRunnerStarting", "reportRunnerResults", "reportSuiteResults", "reportSpecResults", "log"];
1417
+ var functionNames = [
1418
+ "reportRunnerStarting",
1419
+ "reportRunnerResults",
1420
+ "reportSuiteResults",
1421
+ "reportSpecStarting",
1422
+ "reportSpecResults",
1423
+ "log"
1424
+ ];
1399
1425
  for (var i = 0; i < functionNames.length; i++) {
1400
1426
  var functionName = functionNames[i];
1401
1427
  jasmine.MultiReporter.prototype[functionName] = (function(functionName) {
@@ -1919,7 +1945,8 @@ jasmine.Spec.prototype.execute = function(onComplete) {
1919
1945
  spec.finish(onComplete);
1920
1946
  return;
1921
1947
  }
1922
- this.env.reporter.log('>> Jasmine Running ' + this.suite.description + ' ' + this.description + '...');
1948
+
1949
+ this.env.reporter.reportSpecStarting(this);
1923
1950
 
1924
1951
  spec.env.currentSpec = spec;
1925
1952
 
@@ -2249,7 +2276,6 @@ jasmine.Clock = {
2249
2276
  },
2250
2277
 
2251
2278
  uninstallMock: function() {
2252
- jasmine.log("uninstall")
2253
2279
  jasmine.Clock.assertInstalled();
2254
2280
  jasmine.Clock.installed = jasmine.Clock.real;
2255
2281
  },
@@ -2312,6 +2338,6 @@ jasmine.getGlobal().clearInterval = function(timeoutKey) {
2312
2338
  jasmine.version_= {
2313
2339
  "major": 0,
2314
2340
  "minor": 11,
2315
- "build": 0,
2316
- "revision": 1277317833
2317
- };
2341
+ "build": 1,
2342
+ "revision": 1277514571
2343
+ };
@@ -3,4 +3,6 @@ require 'jasmine/config'
3
3
  require 'jasmine/server'
4
4
  require 'jasmine/selenium_driver'
5
5
 
6
- require 'jasmine/spec_builder'
6
+ require 'jasmine/spec_builder'
7
+
8
+ require 'jasmine/command_line_tool'
@@ -0,0 +1,67 @@
1
+ module Jasmine
2
+ class CommandLineTool
3
+ def cwd
4
+ File.expand_path(File.join(File.dirname(__FILE__), '../..'))
5
+ end
6
+
7
+ def expand(*paths)
8
+ File.expand_path(File.join(*paths))
9
+ end
10
+
11
+ def template_path(filepath)
12
+ expand(cwd, File.join("generators/jasmine/templates", filepath))
13
+ end
14
+
15
+ def dest_path(filepath)
16
+ expand(Dir.pwd, filepath)
17
+ end
18
+
19
+ def copy_unless_exists(relative_path, dest_path = nil)
20
+ unless File.exist?(dest_path(relative_path))
21
+ File.copy(template_path(relative_path), dest_path(dest_path || relative_path))
22
+ end
23
+ end
24
+
25
+ def process(argv)
26
+ if argv[0] == 'init'
27
+ require 'ftools'
28
+ File.makedirs('public/javascripts')
29
+ File.makedirs('spec/javascripts')
30
+ File.makedirs('spec/javascripts/support')
31
+ File.makedirs('spec/javascripts/helpers')
32
+
33
+ copy_unless_exists('jasmine-example/src/Player.js', 'public/javascripts/Player.js')
34
+ copy_unless_exists('jasmine-example/src/Song.js', 'public/javascripts/Song.js')
35
+ copy_unless_exists('jasmine-example/spec/PlayerSpec.js', 'spec/javascripts/PlayerSpec.js')
36
+ copy_unless_exists('jasmine-example/spec/SpecHelper.js', 'spec/javascripts/helpers/SpecHelper.js')
37
+ copy_unless_exists('spec/javascripts/support/jasmine_runner.rb')
38
+
39
+ rails_tasks_dir = dest_path('lib/tasks')
40
+ if File.exist?(rails_tasks_dir)
41
+ copy_unless_exists('lib/tasks/jasmine.rake')
42
+ copy_unless_exists('spec/javascripts/support/jasmine-rails.yml', 'spec/javascripts/support/jasmine.yml')
43
+ else
44
+ copy_unless_exists('spec/javascripts/support/jasmine.yml')
45
+ write_mode = 'w'
46
+ if File.exist?(dest_path('Rakefile'))
47
+ load dest_path('Rakefile')
48
+ write_mode = 'a'
49
+ end
50
+
51
+ require 'rake'
52
+ unless Rake::Task.task_defined?('jasmine')
53
+ File.open(dest_path('Rakefile'), write_mode) do |f|
54
+ f.write(File.read(template_path('lib/tasks/jasmine.rake')))
55
+ end
56
+ end
57
+ end
58
+ File.open(template_path('INSTALL'), 'r').each_line do |line|
59
+ puts line
60
+ end
61
+ else
62
+ puts "unknown command #{argv}"
63
+ puts "Usage: jasmine init"
64
+ end
65
+ end
66
+ end
67
+ end
@@ -95,7 +95,8 @@ module Jasmine
95
95
  def match_files(dir, patterns)
96
96
  dir = File.expand_path(dir)
97
97
  patterns.collect do |pattern|
98
- Dir.glob(File.join(dir, pattern)).collect {|f| f.sub("#{dir}/", "")}.sort
98
+ matches = Dir.glob(File.join(dir, pattern))
99
+ matches.collect {|f| f.sub("#{dir}/", "")}.sort
99
100
  end.flatten.uniq
100
101
  end
101
102
 
@@ -114,7 +115,7 @@ module Jasmine
114
115
  end
115
116
 
116
117
  def js_files(spec_filter = nil)
117
- spec_files_to_include = spec_filter.nil? ? spec_files : match_files(spec_dir, spec_filter)
118
+ spec_files_to_include = spec_filter.nil? ? spec_files : match_files(spec_dir, [spec_filter])
118
119
  src_files.collect {|f| "/" + f } + helpers.collect {|f| File.join(spec_path, f) } + spec_files_to_include.collect {|f| File.join(spec_path, f) }
119
120
  end
120
121
 
@@ -151,35 +152,35 @@ module Jasmine
151
152
  end
152
153
 
153
154
  def helpers
154
- files = match_files(spec_dir, "helpers/**/*.js")
155
155
  if simple_config['helpers']
156
- files = match_files(spec_dir, simple_config['helpers'])
156
+ match_files(spec_dir, simple_config['helpers'])
157
+ else
158
+ match_files(spec_dir, ["helpers/**/*.js"])
157
159
  end
158
- files
159
160
  end
160
161
 
161
162
  def src_files
162
- files = []
163
163
  if simple_config['src_files']
164
- files = match_files(src_dir, simple_config['src_files'])
164
+ match_files(src_dir, simple_config['src_files'])
165
+ else
166
+ []
165
167
  end
166
- files
167
168
  end
168
169
 
169
170
  def spec_files
170
- files = match_files(spec_dir, "**/*[sS]pec.js")
171
171
  if simple_config['spec_files']
172
- files = match_files(spec_dir, simple_config['spec_files'])
172
+ match_files(spec_dir, simple_config['spec_files'])
173
+ else
174
+ match_files(spec_dir, ["**/*[sS]pec.js"])
173
175
  end
174
- files
175
176
  end
176
177
 
177
178
  def stylesheets
178
- files = []
179
179
  if simple_config['stylesheets']
180
- files = match_files(src_dir, simple_config['stylesheets'])
180
+ match_files(src_dir, simple_config['stylesheets'])
181
+ else
182
+ []
181
183
  end
182
- files
183
184
  end
184
185
 
185
186
  end
@@ -29,8 +29,8 @@ module Jasmine
29
29
  def initialize(config)
30
30
  @config = config
31
31
  @jasmine_files = [
32
- "/__JASMINE_ROOT__/lib/" + File.basename(Dir.glob("#{Jasmine.root}/lib/jasmine*.js").first),
33
- "/__JASMINE_ROOT__/lib/TrivialReporter.js",
32
+ "/__JASMINE_ROOT__/lib/jasmine.js",
33
+ "/__JASMINE_ROOT__/lib/jasmine-html.js",
34
34
  "/__JASMINE_ROOT__/lib/json2.js",
35
35
  "/__JASMINE_ROOT__/lib/consolex.js",
36
36
  ]
@@ -0,0 +1,31 @@
1
+ namespace :jasmine do
2
+ task :require do
3
+ require 'jasmine'
4
+ end
5
+
6
+ desc "Run continuous integration tests"
7
+ task :ci => "jasmine:require" do
8
+ require "spec"
9
+ require 'spec/rake/spectask'
10
+
11
+ Spec::Rake::SpecTask.new(:jasmine_continuous_integration_runner) do |t|
12
+ t.spec_opts = ["--color", "--format", "specdoc"]
13
+ t.verbose = true
14
+ t.spec_files = ['spec/javascripts/support/jasmine_runner.rb']
15
+ end
16
+ Rake::Task["jasmine_continuous_integration_runner"].invoke
17
+ end
18
+
19
+ task :server => "jasmine:require" do
20
+ jasmine_config_overrides = 'spec/javascripts/support/jasmine_config.rb'
21
+ require jasmine_config_overrides if File.exists?(jasmine_config_overrides)
22
+
23
+ puts "your tests are here:"
24
+ puts " http://localhost:8888/"
25
+
26
+ Jasmine::Config.new.start_server
27
+ end
28
+ end
29
+
30
+ desc "Run specs via server"
31
+ task :jasmine => ['jasmine:server']
@@ -4,6 +4,26 @@ describe Jasmine::Config do
4
4
 
5
5
  describe "configuration" do
6
6
 
7
+ before(:all) do
8
+ temp_dir_before
9
+
10
+ Dir::chdir @tmp
11
+ system 'rails rails-project'
12
+ Dir::chdir 'rails-project'
13
+
14
+ FileUtils.cp_r(File.join(@root, 'generators'), 'vendor')
15
+
16
+ system "./script/generate jasmine"
17
+
18
+ Dir::chdir @old_dir
19
+
20
+ @rails_dir = "#{@tmp}/rails-project"
21
+ end
22
+
23
+ after(:all) do
24
+ temp_dir_after
25
+ end
26
+
7
27
  before(:each) do
8
28
  @template_dir = File.expand_path(File.join(File.dirname(__FILE__), "../generators/jasmine/templates"))
9
29
  @config = Jasmine::Config.new
@@ -28,25 +48,25 @@ describe Jasmine::Config do
28
48
 
29
49
  describe "simple_config" do
30
50
  before(:each) do
31
- @config.stub!(:src_dir).and_return(File.join(@template_dir))
32
- @config.stub!(:spec_dir).and_return(File.join(@template_dir, "spec/javascripts"))
51
+ @config.stub!(:src_dir).and_return(File.join(@rails_dir, "."))
52
+ @config.stub!(:spec_dir).and_return(File.join(@rails_dir, "spec/javascripts"))
33
53
  end
34
54
 
35
55
  shared_examples_for "simple_config defaults" do
36
56
  it "should return the correct files and mappings" do
37
57
  @config.src_files.should == []
38
58
  @config.stylesheets.should == []
39
- @config.spec_files.should == ['ExampleSpec.js']
59
+ @config.spec_files.should == ['PlayerSpec.js']
40
60
  @config.helpers.should == ['helpers/SpecHelper.js']
41
61
  @config.js_files.should == [
42
62
  '/__spec__/helpers/SpecHelper.js',
43
- '/__spec__/ExampleSpec.js',
63
+ '/__spec__/PlayerSpec.js',
44
64
  ]
45
- @config.js_files("ExampleSpec.js").should ==
65
+ @config.js_files("PlayerSpec.js").should ==
46
66
  ['/__spec__/helpers/SpecHelper.js',
47
- '/__spec__/ExampleSpec.js']
67
+ '/__spec__/PlayerSpec.js']
48
68
  @config.spec_files_full_paths.should == [
49
- File.join(@template_dir, 'spec/javascripts/ExampleSpec.js'),
69
+ File.join(@rails_dir, 'spec/javascripts/PlayerSpec.js'),
50
70
  ]
51
71
  end
52
72
  end
@@ -80,13 +100,13 @@ describe Jasmine::Config do
80
100
 
81
101
  end
82
102
 
83
- describe "using default jasmine.yml" do
84
- before(:each) do
85
- @config.stub!(:simple_config_file).and_return(File.join(@template_dir, 'spec/javascripts/support/jasmine.yml'))
86
- end
87
- it_should_behave_like "simple_config defaults"
88
-
89
- end
103
+ # describe "using default jasmine.yml" do
104
+ # before(:each) do
105
+ # @config.stub!(:simple_config_file).and_return(File.join(@template_dir, 'spec/javascripts/support/jasmine.yml'))
106
+ # end
107
+ # it_should_behave_like "simple_config defaults"
108
+ #
109
+ # end
90
110
 
91
111
  describe "should use the first appearance of duplicate filenames" do
92
112
  before(:each) do
@@ -123,8 +143,10 @@ describe Jasmine::Config do
123
143
  end
124
144
 
125
145
  it "spec_files_full_paths" do
126
- @config.spec_files_full_paths.should == [File.expand_path("../../generators/jasmine/templates/spec/javascripts/file1.ext", __FILE__),
127
- File.expand_path("../../generators/jasmine/templates/spec/javascripts/file2.ext", __FILE__)]
146
+ @config.spec_files_full_paths.should == [
147
+ File.expand_path("spec/javascripts/file1.ext", @rails_dir),
148
+ File.expand_path("spec/javascripts/file2.ext", @rails_dir)
149
+ ]
128
150
  end
129
151
 
130
152
  end
@@ -140,40 +162,37 @@ describe Jasmine::Config do
140
162
 
141
163
 
142
164
  it "using rails jasmine.yml" do
143
-
144
- original_glob = Dir.method(:glob)
145
- Dir.stub!(:glob).and_return do |glob_string|
146
- if glob_string =~ /public/
147
- glob_string
148
- else
149
- original_glob.call(glob_string)
150
- end
151
- end
152
165
  @config.stub!(:simple_config_file).and_return(File.join(@template_dir, 'spec/javascripts/support/jasmine-rails.yml'))
153
- @config.spec_files.should == ['ExampleSpec.js']
166
+ @config.spec_files.should == ['PlayerSpec.js']
154
167
  @config.helpers.should == ['helpers/SpecHelper.js']
155
168
  @config.src_files.should == ['public/javascripts/prototype.js',
156
169
  'public/javascripts/effects.js',
157
170
  'public/javascripts/controls.js',
158
171
  'public/javascripts/dragdrop.js',
159
- 'public/javascripts/application.js']
172
+ 'public/javascripts/application.js',
173
+ 'public/javascripts/Player.js',
174
+ 'public/javascripts/Song.js']
160
175
  @config.js_files.should == [
161
176
  '/public/javascripts/prototype.js',
162
177
  '/public/javascripts/effects.js',
163
178
  '/public/javascripts/controls.js',
164
179
  '/public/javascripts/dragdrop.js',
165
180
  '/public/javascripts/application.js',
181
+ '/public/javascripts/Player.js',
182
+ '/public/javascripts/Song.js',
166
183
  '/__spec__/helpers/SpecHelper.js',
167
- '/__spec__/ExampleSpec.js',
184
+ '/__spec__/PlayerSpec.js',
168
185
  ]
169
- @config.js_files("ExampleSpec.js").should == [
186
+ @config.js_files("PlayerSpec.js").should == [
170
187
  '/public/javascripts/prototype.js',
171
188
  '/public/javascripts/effects.js',
172
189
  '/public/javascripts/controls.js',
173
190
  '/public/javascripts/dragdrop.js',
174
191
  '/public/javascripts/application.js',
192
+ '/public/javascripts/Player.js',
193
+ '/public/javascripts/Song.js',
175
194
  '/__spec__/helpers/SpecHelper.js',
176
- '/__spec__/ExampleSpec.js'
195
+ '/__spec__/PlayerSpec.js'
177
196
  ]
178
197
 
179
198
  end
@@ -0,0 +1,23 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
2
+
3
+ describe "Jasmine command line tool" do
4
+ before :each do
5
+ temp_dir_before
6
+ Dir::chdir @tmp
7
+ end
8
+
9
+ after :each do
10
+ temp_dir_after
11
+ end
12
+
13
+ it "should create files on init" do
14
+ Jasmine::CommandLineTool.new.process ["init"]
15
+
16
+ my_jasmine_lib = File.expand_path(File.join(@root, "lib"))
17
+ bootstrap = "$:.unshift('#{my_jasmine_lib}')"
18
+
19
+ ENV['JASMINE_GEM_PATH'] = "#{@root}/lib"
20
+ ci_output = `rake -E \"#{bootstrap}\" --trace jasmine:ci`
21
+ ci_output.should =~ (/[1-9][0-9]* examples, 0 failures/)
22
+ end
23
+ end
@@ -0,0 +1,26 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
2
+
3
+ describe "Jasmine rails generator" do
4
+ before :each do
5
+ temp_dir_before
6
+ Dir::chdir @tmp
7
+ end
8
+
9
+ after :each do
10
+ temp_dir_after
11
+ end
12
+
13
+ it "should create files on init" do
14
+ system 'rails rails-project'
15
+ Dir::chdir 'rails-project'
16
+
17
+ FileUtils.cp_r(File.join(@root, 'generators'), 'vendor')
18
+
19
+ system "./script/generate jasmine"
20
+
21
+ bootstrap = "$:.unshift('#{@root}/lib')"
22
+ ENV['JASMINE_GEM_PATH'] = "#{@root}/lib"
23
+ ci_output = `rake -E \"#{bootstrap}\" --trace jasmine:ci`
24
+ ci_output.should =~ (/[1-9][0-9]* examples, 0 failures/)
25
+ end
26
+ end
@@ -5,4 +5,24 @@ Bundler.setup(:default, :test)
5
5
 
6
6
  require 'spec'
7
7
 
8
- require File.expand_path(File.join(File.dirname(__FILE__), "../lib/jasmine"))
8
+ $:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "../lib")))
9
+
10
+ require "jasmine"
11
+
12
+ def create_temp_dir
13
+ tmp = File.join(Dir.tmpdir, 'jasmine-gem-test')
14
+ FileUtils.rm_r(tmp, :force => true)
15
+ FileUtils.mkdir(tmp)
16
+ tmp
17
+ end
18
+
19
+ def temp_dir_before
20
+ @root = File.expand_path(File.join(File.dirname(__FILE__), ".."))
21
+ @old_dir = Dir::pwd
22
+ @tmp = create_temp_dir
23
+ end
24
+
25
+ def temp_dir_after
26
+ Dir::chdir @old_dir
27
+ FileUtils.rm_r @tmp
28
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jasmine
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 11
9
+ - 1
9
10
  - 0
10
- - 0
11
- version: 0.11.0.0
11
+ version: 0.11.1.0
12
12
  platform: ruby
13
13
  authors:
14
14
  - Rajan Agaskar
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2010-06-23 00:00:00 -07:00
20
+ date: 2010-06-25 00:00:00 -07:00
21
21
  default_executable: jasmine
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
@@ -95,28 +95,36 @@ extra_rdoc_files:
95
95
  files:
96
96
  - generators/jasmine/jasmine_generator.rb
97
97
  - generators/jasmine/templates/INSTALL
98
+ - generators/jasmine/templates/jasmine-example/SpecRunner.html
99
+ - generators/jasmine/templates/jasmine-example/spec/PlayerSpec.js
100
+ - generators/jasmine/templates/jasmine-example/spec/SpecHelper.js
101
+ - generators/jasmine/templates/jasmine-example/src/Player.js
102
+ - generators/jasmine/templates/jasmine-example/src/Song.js
98
103
  - generators/jasmine/templates/lib/tasks/jasmine.rake
99
- - generators/jasmine/templates/spec/javascripts/ExampleSpec.js
100
- - generators/jasmine/templates/spec/javascripts/helpers/SpecHelper.js
101
104
  - generators/jasmine/templates/spec/javascripts/support/jasmine-rails.yml
102
105
  - generators/jasmine/templates/spec/javascripts/support/jasmine.yml
103
106
  - generators/jasmine/templates/spec/javascripts/support/jasmine_runner.rb
104
- - jasmine/lib/TrivialReporter.js
107
+ - jasmine/example/SpecRunner.html
105
108
  - jasmine/lib/consolex.js
109
+ - jasmine/lib/jasmine-html.js
106
110
  - jasmine/lib/jasmine.css
107
111
  - jasmine/lib/jasmine.js
108
112
  - jasmine/lib/json2.js
109
113
  - lib/jasmine.rb
110
114
  - lib/jasmine/base.rb
115
+ - lib/jasmine/command_line_tool.rb
111
116
  - lib/jasmine/config.rb
112
117
  - lib/jasmine/run.html.erb
113
118
  - lib/jasmine/selenium_driver.rb
114
119
  - lib/jasmine/server.rb
115
120
  - lib/jasmine/spec_builder.rb
121
+ - lib/jasmine/tasks/jasmine.rake
116
122
  - README.markdown
117
123
  - spec/config_spec.rb
124
+ - spec/jasmine_command_line_tool_spec.rb
118
125
  - spec/jasmine_self_test_config.rb
119
126
  - spec/jasmine_self_test_spec.rb
127
+ - spec/rails_generator_spec.rb
120
128
  - spec/server_spec.rb
121
129
  - spec/spec_helper.rb
122
130
  - bin/jasmine
@@ -156,7 +164,9 @@ specification_version: 3
156
164
  summary: Jasmine Ruby Runner
157
165
  test_files:
158
166
  - spec/config_spec.rb
167
+ - spec/jasmine_command_line_tool_spec.rb
159
168
  - spec/jasmine_self_test_config.rb
160
169
  - spec/jasmine_self_test_spec.rb
170
+ - spec/rails_generator_spec.rb
161
171
  - spec/server_spec.rb
162
172
  - spec/spec_helper.rb
@@ -1,11 +0,0 @@
1
- describe('Example', function () {
2
- it('should have a passing test', function() {
3
- expect(true).toEqual(true);
4
- });
5
-
6
- describe('nested describe', function () {
7
- it('should also have a passing test', function () {
8
- expect(true).toEqual(true);
9
- });
10
- });
11
- });
@@ -1 +0,0 @@
1
- //You may load required files here, or create test-runner-wide environment settings.