js-test-driver-rails 0.2.9 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -33,3 +33,5 @@ Jeweler::GemcutterTasks.new
33
33
  Jeweler::RubyforgeTasks.new do |rubyforge|
34
34
  rubyforge.doc_task = "rdoc"
35
35
  end
36
+
37
+ task :default => :test
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.9
1
+ 0.3.0
@@ -22,7 +22,7 @@ module JsTestDriver
22
22
  end
23
23
  end
24
24
 
25
- # Files specified here will not be loaded, it's useful when combined with globbing in includes
25
+ # Files specified here will not be loaded, it's useful when combined with globbing in includes
26
26
  #
27
27
  # paths should be relative to root_dir
28
28
  def excludes(*paths)
@@ -35,7 +35,7 @@ module JsTestDriver
35
35
  #
36
36
  # This should be a string with no spaces (if you need to pass parameters to the browser you will
37
37
  # need to create a shell script ans put it's name here)
38
- def browser(browsers)
38
+ def browser(*browsers)
39
39
  browsers.each do |browser|
40
40
  self.browsers << browser
41
41
  end
@@ -50,12 +50,12 @@ module JsTestDriver
50
50
  # namespace.name["file_name_without the html extension"]
51
51
  #
52
52
  # by default the namespace is called htmlFixtures
53
- # and the fixture name is called all
53
+ # and the fixture name is called all
54
54
  def fixtures(directory, opts = {})
55
55
  fixture = JsTestDriver::HtmlFixture.new(directory, opts[:name], opts[:namespace])
56
56
  if html_fixtures.detect{|f| f.name == fixture.name && f.namespace == fixture.namespace}
57
57
  raise ArgumentError.new("Fixture #{fixture.namespace}.#{fixture.name} already defined!")
58
- end
58
+ end
59
59
  html_fixtures << fixture
60
60
  end
61
61
 
@@ -186,7 +186,7 @@ module JsTestDriver
186
186
  values.each do |attr, value|
187
187
  self.send("#{attr}=", value)
188
188
  end
189
- end
189
+ end
190
190
 
191
191
  end
192
- end
192
+ end
@@ -1,3 +1,3 @@
1
- JsTestDriver: 1.2.2
2
- Jasmine: 0.11.1
3
- JasmineAdapter: http://github.com/mhevery/jasmine-jstd-adapter/commit/30249606deefc81798dd82cb0b0a34d2f14a3928
1
+ JsTestDriver: 1.3.2
2
+ Jasmine: 1.0.1
3
+ JasmineAdapter: http://github.com/mhevery/jasmine-jstd-adapter/commit/66fd298eac4364a02f80cc7d0714adcdffbe175e
@@ -0,0 +1,6 @@
1
+ server: http://localhost:9876
2
+
3
+ load:
4
+ - lib/jasmine/*.js
5
+ - src/*.js
6
+ - src-test/iit/*.js
@@ -0,0 +1,46 @@
1
+ (function() {
2
+ var specs = [];
3
+
4
+
5
+ describe('root describe', function() {
6
+ it('nested it', function() {
7
+ specs.push('nested it');
8
+ });
9
+ });
10
+
11
+
12
+ describe('root describe with iit', function() {
13
+ it('it as iit sibling', function() {
14
+ specs.push('it as iit sibling');
15
+ });
16
+
17
+ iit('nested iit', function() {
18
+ specs.push('nested iit');
19
+ });
20
+ });
21
+
22
+
23
+ describe('describe that follows iit with a nested it', function() {
24
+ it('nested it after iit', function() {
25
+ specs.push('nested it after iit');
26
+ });
27
+ });
28
+
29
+
30
+ describe('describe with iit followed by it', function() {
31
+ iit('iit that preceeds an it', function() {
32
+ specs.push('iit that preceeds an it');
33
+ });
34
+
35
+ it('it that follows an iit', function() {
36
+ specs.push('it that follows an iit');
37
+ });
38
+ });
39
+
40
+
41
+ describe('test summary', function() {
42
+ iit('should have executed all iit tests and nothing else', function() {
43
+ expect(specs).toEqual(['nested iit', 'iit that preceeds an it']);
44
+ });
45
+ });
46
+ })();
@@ -1,111 +1,186 @@
1
1
  /**
2
2
  * @fileoverview Jasmine JsTestDriver Adapter.
3
- * @author ibolmo@gmail.com (Olmo Maldonado)
4
3
  * @author misko@hevery.com (Misko Hevery)
5
4
  */
6
-
7
- (function() {
8
-
9
- function bind(_this, _function){
10
- return function(){
11
- return _function.call(_this);
12
- };
13
- }
14
-
15
- var currentFrame = frame(null, null);
16
-
17
- function frame(parent, name){
18
- var caseName = (parent && parent.caseName ? parent.caseName + " " : '') + (name ? name : '');
19
- var frame = {
20
- name: name,
21
- caseName: caseName,
22
- parent: parent,
23
- testCase: TestCase(caseName),
24
- before: [],
25
- after: [],
26
- runBefore: function(){
27
- if (parent) parent.runBefore.apply(this);
28
- for ( var i = 0; i < frame.before.length; i++) {
29
- frame.before[i].apply(this);
30
- }
5
+ (function(window) {
6
+ var rootDescribes = new Describes(window);
7
+ var describePath = [];
8
+ rootDescribes.collectMode();
9
+
10
+ var jasmineTest = TestCase('Jasmine Adapter Tests', null, 'jasmine test case');
11
+
12
+ var jasminePlugin = {
13
+ name:'jasmine',
14
+ runTestConfiguration: function(testRunConfiguration, onTestDone, onTestRunConfigurationComplete){
15
+ if (testRunConfiguration.testCaseInfo_.template_ !== jasmineTest) return;
16
+
17
+ var jasmineEnv = jasmine.currentEnv_ = new jasmine.Env();
18
+ rootDescribes.playback();
19
+ var specLog = jstestdriver.console.log_ = [];
20
+ var start;
21
+ jasmineEnv.specFilter = function(spec) {
22
+ return rootDescribes.isExclusive(spec);
23
+ };
24
+ jasmineEnv.reporter = {
25
+ log: function(str){
26
+ specLog.push(str);
27
+ },
28
+
29
+ reportRunnerStarting: function(runner) { },
30
+
31
+ reportSpecStarting: function(spec) {
32
+ specLog = jstestdriver.console.log_ = [];
33
+ start = new Date().getTime();
34
+ },
35
+
36
+ reportSpecResults: function(spec) {
37
+ var suite = spec.suite;
38
+ var results = spec.results();
39
+ if (results.skipped) return;
40
+ var end = new Date().getTime();
41
+ var messages = [];
42
+ var resultItems = results.getItems();
43
+ var state = 'passed';
44
+ for ( var i = 0; i < resultItems.length; i++) {
45
+ if (!resultItems[i].passed()) {
46
+ state = resultItems[i].message.match(/AssertionError:/) ? 'error' : 'failed';
47
+ messages.push({
48
+ message: resultItems[i].toString(),
49
+ name: resultItems[i].trace.name,
50
+ stack: formatStack(resultItems[i].trace.stack)
51
+ });
52
+ }
53
+ }
54
+ onTestDone(
55
+ new jstestdriver.TestResult(
56
+ suite.getFullName(),
57
+ spec.description,
58
+ state,
59
+ jstestdriver.angular.toJson(messages),
60
+ specLog.join('\n'),
61
+ end - start));
62
+ },
63
+
64
+ reportSuiteResults: function(suite) {},
65
+
66
+ reportRunnerResults: function(runner) {
67
+ onTestRunConfigurationComplete();
68
+ }
69
+ };
70
+ jasmineEnv.execute();
71
+ return true;
31
72
  },
32
- runAfter: function(){
33
- for ( var i = 0; i < frame.after.length; i++) {
34
- frame.after[i].apply(this);
35
- }
36
- if (parent) parent.runAfter.apply(this);
73
+ onTestsFinish: function(){
74
+ jasmine.currentEnv_ = null;
75
+ rootDescribes.collectMode();
37
76
  }
38
- };
39
- return frame;
40
77
  };
78
+ jstestdriver.pluginRegistrar.register(jasminePlugin);
79
+
80
+ function formatStack(stack) {
81
+ var lines = (stack||'').split(/\r?\n/);
82
+ var frames = [];
83
+ for (i = 0; i < lines.length; i++) {
84
+ if (!lines[i].match(/\/jasmine[\.-]/)) {
85
+ frames.push(lines[i].replace(/https?:\/\/\w+(:\d+)?\/test\//, '').replace(/^\s*/, ' '));
86
+ }
87
+ }
88
+ return frames.join('\n');
89
+ }
41
90
 
42
- jasmine.Env.prototype.describe = (function(describe){
43
- return function(description){
44
- currentFrame = frame(currentFrame, description);
45
- var val = describe.apply(this, arguments);
46
- currentFrame = currentFrame.parent;
47
- return val;
48
- };
49
-
50
- })(jasmine.Env.prototype.describe);
51
-
52
- var id = 0;
53
-
54
- jasmine.Env.prototype.it = (function(it){
55
- return function(desc, itFn){
56
- var self = this;
57
- var spec = it.apply(this, arguments);
58
- var currentSpec = this.currentSpec;
59
- if (!currentSpec.$id) {
60
- currentSpec.$id = id++;
91
+ function noop(){}
92
+ function Describes(window){
93
+ var describes = {};
94
+ var beforeEachs = {};
95
+ var afterEachs = {};
96
+ // Here we store:
97
+ // 0: everyone runs
98
+ // 1: run everything under ddescribe
99
+ // 2: run only iits (ignore ddescribe)
100
+ var exclusive = 0;
101
+ var collectMode = true;
102
+ intercept('describe', describes);
103
+ intercept('xdescribe', describes);
104
+ intercept('beforeEach', beforeEachs);
105
+ intercept('afterEach', afterEachs);
106
+
107
+ function intercept(functionName, collection){
108
+ window[functionName] = function(desc, fn){
109
+ if (collectMode) {
110
+ collection[desc] = function(){
111
+ jasmine.getEnv()[functionName](desc, fn);
112
+ };
113
+ } else {
114
+ jasmine.getEnv()[functionName](desc, fn);
115
+ }
116
+ };
117
+ }
118
+ window.ddescribe = function(name, fn){
119
+ if (exclusive < 1) {
120
+ exclusive = 1; // run ddescribe only
61
121
  }
62
- var frame = this.jstdFrame = currentFrame;
63
- var name = 'test that it ' + desc;
64
- if (this.jstdFrame.testCase.prototype[name])
65
- throw "Spec with name '" + desc + "' already exists.";
66
- this.jstdFrame.testCase.prototype[name] = function(){
67
- jasmine.getEnv().currentSpec = currentSpec;
68
- frame.runBefore.apply(currentSpec);
122
+ window.describe(name, function(){
123
+ var oldIt = window.it;
124
+ window.it = function(name, fn){
125
+ fn.exclusive = 1; // run anything under ddescribe
126
+ jasmine.getEnv().it(name, fn);
127
+ };
69
128
  try {
70
- currentSpec.queue.start();
129
+ fn.call(this);
71
130
  } finally {
72
- frame.runAfter.apply(currentSpec);
73
- }
74
- };
75
- return spec;
131
+ window.it = oldIt;
132
+ };
133
+ });
76
134
  };
77
-
78
- })(jasmine.Env.prototype.it);
79
-
80
-
81
- jasmine.Env.prototype.beforeEach = (function(beforeEach){
82
- return function(beforeEachFunction) {
83
- beforeEach.apply(this, arguments);
84
- currentFrame.before.push(beforeEachFunction);
135
+ window.iit = function(name, fn){
136
+ exclusive = fn.exclusive = 2; // run only iits
137
+ jasmine.getEnv().it(name, fn);
85
138
  };
86
139
 
87
- })(jasmine.Env.prototype.beforeEach);
88
-
89
140
 
90
- jasmine.Env.prototype.afterEach = (function(afterEach){
91
- return function(afterEachFunction) {
92
- afterEach.apply(this, arguments);
93
- currentFrame.after.push(afterEachFunction);
141
+ this.collectMode = function() {
142
+ collectMode = true;
143
+ exclusive = 0; // run everything
94
144
  };
95
-
96
- })(jasmine.Env.prototype.afterEach);
97
-
98
-
99
- jasmine.NestedResults.prototype.addResult = (function(addResult){
100
- return function(result) {
101
- addResult.call(this, result);
102
- if (result.type != 'MessageResult' && !result.passed()) fail(result.message);
145
+ this.playback = function(){
146
+ collectMode = false;
147
+ playback(beforeEachs);
148
+ playback(afterEachs);
149
+ playback(describes);
150
+
151
+ function playback(set) {
152
+ for ( var name in set) {
153
+ set[name]();
154
+ }
155
+ }
103
156
  };
104
157
 
105
- })(jasmine.NestedResults.prototype.addResult);
158
+ this.isExclusive = function(spec) {
159
+ if (exclusive) {
160
+ var blocks = spec.queue.blocks;
161
+ for ( var i = 0; i < blocks.length; i++) {
162
+ if (blocks[i].func.exclusive >= exclusive) {
163
+ return true;
164
+ }
165
+ }
166
+ return false;
167
+ }
168
+ return true;
169
+ };
170
+ }
106
171
 
107
- // Reset environment with overriden methods.
108
- jasmine.currentEnv_ = null;
109
- jasmine.getEnv();
172
+ })(window);
173
+
174
+ // Patch Jasmine for proper stack traces
175
+ jasmine.Spec.prototype.fail = function (e) {
176
+ var expectationResult = new jasmine.ExpectationResult({
177
+ passed: false,
178
+ message: e ? jasmine.util.formatException(e) : 'Exception'
179
+ });
180
+ // PATCH
181
+ if (e) {
182
+ expectationResult.trace = e;
183
+ }
184
+ this.results_.addResult(expectationResult);
185
+ };
110
186
 
111
- })();
@@ -0,0 +1 @@
1
+ java -jar lib/jstestdriver/JsTestDriver.jar --config jsTestDriverIit.conf --tests "all" --reset
@@ -0,0 +1,2 @@
1
+ java -jar lib/jstestdriver/JsTestDriver.jar --tests 'all' --reset
2
+ java -jar lib/jstestdriver/JsTestDriver.jar --tests 'all'
@@ -1 +1,2 @@
1
- java -jar lib/jstestdriver/JsTestDriver.jar --tests all --reset
1
+ source test-regular.sh
2
+ source test-iit.sh
@@ -91,8 +91,9 @@ jasmine.version_= {
91
91
  FileUtils.cp("src/html/jasmine.css", "lib/jasmine.css")
92
92
  end
93
93
 
94
+ downloads_file = 'pages/download.html.md'
94
95
  task :need_pages_submodule do
95
- unless File.exists?('pages/index.html')
96
+ unless File.exists?(downloads_file)
96
97
  raise "Jasmine pages submodule isn't present. Run git submodule update --init"
97
98
  end
98
99
  end
@@ -109,6 +110,8 @@ jasmine.version_= {
109
110
  t[:files] = jasmine_sources << jasmine_html_sources
110
111
  t[:options] = "-a"
111
112
  t[:out] = "pages/jsdoc"
113
+ # JsdocHelper bug: template must be relative to the JsdocHelper gem, ick
114
+ t[:template] = File.join("../".*(100), Dir::getwd, "jsdoc-template")
112
115
  end
113
116
  Rake::Task[:lambda_jsdoc].invoke
114
117
  end
@@ -131,7 +134,8 @@ jasmine.version_= {
131
134
  {
132
135
  "lib/jasmine.js" => "jasmine.js",
133
136
  "lib/jasmine-html.js" => "jasmine-html.js",
134
- "src/html/jasmine.css" => "jasmine.css"
137
+ "src/html/jasmine.css" => "jasmine.css",
138
+ "MIT.LICENSE" => "MIT.LICENSE"
135
139
  }.each_pair do |src, dest|
136
140
  FileUtils.cp(File.join(root, src), File.join(lib_dir, dest))
137
141
  end
@@ -151,26 +155,26 @@ jasmine.version_= {
151
155
  require 'digest/sha1'
152
156
 
153
157
  download_html = "<!-- START_DOWNLOADS -->\n"
154
- download_html += "<table>\n<tr><th></th><th>Version</th><th>Size</th><th>Date</th><th>SHA1</th></tr>\n"
155
158
  Dir.glob('pages/downloads/*.zip').sort.reverse.each do |f|
156
159
  sha1 = Digest::SHA1.hexdigest File.read(f)
157
160
 
158
161
  fn = f.sub(/^pages\//, '')
159
162
  version = /jasmine-standalone-(.*).zip/.match(f)[1]
160
- download_html += "<tr>\n"
161
- download_html += "<td class=\"link\"><a href='#{fn}'>#{fn.sub(/downloads\//, '')}</a></td>\n"
162
- download_html += "<td class=\"version\">#{version}</td>\n"
163
- download_html += "<td class=\"size\">#{File.size(f) / 1024}k</td>\n"
164
- download_html += "<td class=\"date\">#{File.mtime(f).strftime("%Y/%m/%d %H:%M:%S %Z")}</td>\n"
165
- download_html += "<td class=\"sha\">#{sha1}</td>\n"
163
+ prerelease = /\.rc/.match(f)
164
+ download_html += prerelease ? "<tr class=\"rc\">\n" : "<tr>\n"
165
+ download_html += " <td class=\"link\"><a href=\"#{fn}\">#{fn.sub(/downloads\//, '')}</a></td>\n"
166
+ download_html += " <td class=\"version\">#{version}</td>\n"
167
+ download_html += " <td class=\"size\">#{File.size(f) / 1024}k</td>\n"
168
+ download_html += " <td class=\"date\">#{File.mtime(f).strftime("%Y/%m/%d %H:%M:%S %Z")}</td>\n"
169
+ download_html += " <td class=\"sha\">#{sha1}</td>\n"
166
170
  download_html += "</tr>\n"
167
171
  end
168
- download_html += "</table>\n<!-- END_DOWNLOADS -->"
172
+ download_html += "<!-- END_DOWNLOADS -->"
169
173
 
170
- index_page = File.read('pages/index.html')
174
+ downloads_page = File.read(downloads_file)
171
175
  matcher = /<!-- START_DOWNLOADS -->.*<!-- END_DOWNLOADS -->/m
172
- index_page = index_page.sub(matcher, download_html)
173
- File.open('pages/index.html', 'w') {|f| f.write(index_page)}
176
+ downloads_page = downloads_page.sub(matcher, download_html)
177
+ File.open(downloads_file, 'w') {|f| f.write(downloads_page)}
174
178
  puts "rewrote that file"
175
179
  end
176
180
  end