jasmine 1.3.2 → 2.0.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +7 -0
  2. data/.travis.yml +3 -37
  3. data/Gemfile +11 -2
  4. data/HOW_TO_TEST.markdown +1 -1
  5. data/README.markdown +10 -10
  6. data/Rakefile +18 -29
  7. data/generators/jasmine/templates/jasmine-example/spec/PlayerSpec.js +2 -2
  8. data/generators/jasmine/templates/jasmine-example/spec/SpecHelper.js +14 -8
  9. data/generators/jasmine/templates/spec/javascripts/support/jasmine.yml +3 -3
  10. data/generators/jasmine/templates/spec/javascripts/support/jasmine_helper.rb +1 -0
  11. data/jasmine.gemspec +11 -41
  12. data/lib/generators/jasmine/examples/templates/spec/javascripts/helpers/SpecHelper.js +15 -9
  13. data/lib/generators/jasmine/examples/templates/spec/javascripts/jasmine_examples/PlayerSpec.js +1 -1
  14. data/lib/jasmine.rb +10 -7
  15. data/lib/jasmine/asset_bundle.rb +69 -0
  16. data/lib/jasmine/asset_expander.rb +7 -7
  17. data/lib/jasmine/command_line_tool.rb +18 -0
  18. data/lib/jasmine/config.rb +23 -15
  19. data/lib/jasmine/configuration.rb +14 -8
  20. data/lib/jasmine/core_configuration.rb +7 -4
  21. data/lib/jasmine/dependencies.rb +14 -18
  22. data/lib/jasmine/formatters/base.rb +9 -0
  23. data/lib/jasmine/formatters/console.rb +45 -0
  24. data/lib/jasmine/formatters/junit_xml.rb +47 -0
  25. data/lib/jasmine/path_expander.rb +1 -1
  26. data/lib/jasmine/railtie.rb +7 -6
  27. data/lib/jasmine/reporters/api_reporter.rb +38 -0
  28. data/lib/jasmine/results.rb +28 -9
  29. data/lib/jasmine/results_processor.rb +1 -1
  30. data/lib/jasmine/run.html.erb +1 -1
  31. data/lib/jasmine/run_specs.rb +12 -15
  32. data/lib/jasmine/runners/http.rb +11 -49
  33. data/lib/jasmine/selenium_driver.rb +17 -14
  34. data/lib/jasmine/tasks/jasmine.rake +21 -30
  35. data/lib/jasmine/tasks/{jasmine_rails3.rake → jasmine_rails.rake} +0 -0
  36. data/lib/jasmine/version.rb +1 -1
  37. data/lib/jasmine/yaml_config_parser.rb +9 -0
  38. data/release_notes/v2.0.0.rc2.md +44 -0
  39. data/spec/application_spec.rb +33 -38
  40. data/spec/asset_expander_spec.rb +4 -32
  41. data/spec/configuration_spec.rb +95 -35
  42. data/spec/jasmine_command_line_tool_spec.rb +63 -11
  43. data/spec/jasmine_rails_spec.rb +94 -0
  44. data/spec/lib/jasmine/formatters/base_spec.rb +9 -0
  45. data/spec/lib/jasmine/formatters/console_spec.rb +92 -0
  46. data/spec/lib/jasmine/formatters/junit_xml_spec.rb +55 -0
  47. data/spec/lib/jasmine/reporters/api_reporter_spec.rb +53 -0
  48. data/spec/lib/jasmine/runners/http_spec.rb +21 -0
  49. data/spec/path_expander_spec.rb +25 -0
  50. data/spec/results_spec.rb +59 -17
  51. data/spec/spec_helper.rb +36 -18
  52. data/spec/support/fake_selenium_driver.rb +35 -0
  53. data/spec/yaml_config_parser_spec.rb +37 -0
  54. metadata +65 -103
  55. data/generators/jasmine/templates/jasmine-example/SpecRunner.html +0 -54
  56. data/lib/jasmine/asset_pipeline_utility.rb +0 -19
  57. data/lib/jasmine/javascripts/boot.js +0 -28
  58. data/lib/jasmine/rspec_formatter.rb +0 -92
  59. data/spec/dependencies_spec.rb +0 -315
  60. data/spec/jasmine_rails2_spec.rb +0 -89
  61. data/spec/jasmine_rails3_spec.rb +0 -69
  62. data/spec/jasmine_self_test_spec.rb +0 -29
  63. data/spec/rspec_formatter_spec.rb +0 -88
@@ -1,19 +0,0 @@
1
- module Jasmine
2
- class AssetPipelineUtility
3
- def self.bundled_asset_factory(pathname, ext)
4
- context.asset_paths.asset_for(pathname, 'js')
5
- end
6
-
7
- def self.asset_path_for(filepath)
8
- context.asset_path(filepath)
9
- end
10
-
11
- def self.context
12
- return @context if @context
13
- @context = ::Rails.application.assets.context_class
14
- @context.extend(::Sprockets::Helpers::IsolatedHelper)
15
- @context.extend(::Sprockets::Helpers::RailsHelper)
16
- end
17
-
18
- end
19
- end
@@ -1,28 +0,0 @@
1
- var jsApiReporter;
2
- (function() {
3
- var jasmineEnv = jasmine.getEnv();
4
-
5
- jsApiReporter = new jasmine.JsApiReporter();
6
- var htmlReporter = new jasmine.HtmlReporter();
7
-
8
- jasmineEnv.addReporter(jsApiReporter);
9
- jasmineEnv.addReporter(htmlReporter);
10
-
11
- jasmineEnv.specFilter = function(spec) {
12
- return htmlReporter.specFilter(spec);
13
- };
14
-
15
- var currentWindowOnload = window.onload;
16
-
17
- window.onload = function() {
18
- if (currentWindowOnload) {
19
- currentWindowOnload();
20
- }
21
- execJasmine();
22
- };
23
-
24
- function execJasmine() {
25
- jasmineEnv.execute();
26
- }
27
-
28
- })();
@@ -1,92 +0,0 @@
1
- require 'enumerator'
2
-
3
- module Jasmine
4
- class RspecFormatter
5
-
6
- def format_results(results)
7
- @results = results
8
- declare_suites(@results.suites)
9
- end
10
-
11
- def declare_suites(suites)
12
- suites.each do |suite|
13
- #empty block for rspec 1
14
- group = example_group(suite["name"]) {}
15
- process_children(group, suite["children"])
16
- end
17
- end
18
-
19
- def process_children(parent, children)
20
- children.each do |suite_or_spec|
21
- type = suite_or_spec["type"]
22
- if type == "suite"
23
- process_children(parent.describe(suite_or_spec["name"]), suite_or_spec["children"])
24
- elsif type == "spec"
25
- declare_spec(parent, suite_or_spec)
26
- else
27
- raise "unknown type #{type} for #{suite_or_spec.inspect}"
28
- end
29
- end
30
- end
31
-
32
- def declare_spec(parent, spec)
33
- me = self
34
- example_name = spec["name"]
35
- backtrace = @results.example_location_for(parent.description + " " + example_name)
36
- if Jasmine::Dependencies.rspec2?
37
- parent.it example_name, {} do
38
- me.report_spec(spec["id"])
39
- end
40
- else
41
- parent.it example_name, {}, backtrace do
42
- me.report_spec(spec["id"])
43
- end
44
- end
45
- end
46
-
47
- def report_spec(spec_id)
48
- spec_results = results_for(spec_id)
49
- out = ""
50
- messages = spec_results['messages'].each do |message|
51
- case
52
- when message["type"] == "log"
53
- puts message["text"]
54
- puts "\n"
55
- else
56
- unless message["message"] =~ /^Passed.$/
57
- STDERR << message["message"]
58
- STDERR << "\n"
59
-
60
- out << message["message"]
61
- out << "\n"
62
- end
63
-
64
- if !message["passed"] && message["trace"]["stack"]
65
- stack_trace = message["trace"]["stack"].gsub(/<br \/>/, "\n").gsub(/<\/?b>/, " ")
66
- STDERR << stack_trace.gsub(/\(.*\)@http:\/\/localhost:[0-9]+\/specs\//, "/spec/")
67
- STDERR << "\n"
68
- end
69
- end
70
-
71
- end
72
- fail out unless spec_results['result'] == 'passed'
73
- puts out unless out.empty?
74
- end
75
-
76
- private
77
-
78
- def example_group(*args, &block)
79
- if Jasmine::Dependencies.rspec2?
80
- RSpec::Core::ExampleGroup.describe(*args, &block).register
81
- else
82
- Spec::Example::ExampleGroupFactory.create_example_group(*args, &block)
83
- end
84
- end
85
-
86
- def results_for(spec_id)
87
- @results.for_spec_id(spec_id.to_s)
88
- end
89
-
90
-
91
- end
92
- end
@@ -1,315 +0,0 @@
1
- require 'spec_helper'
2
-
3
- #rspec 1 fails to stub respond_to
4
- if Jasmine::Dependencies.rspec2?
5
- describe Jasmine::Dependencies do
6
- module Rails
7
- end
8
-
9
- context "with ruby_gems > 1.8" do
10
- before do
11
- Gem::Specification.should_receive(:respond_to?).with(:find_by_name).and_return(true)
12
- end
13
-
14
- describe ".rspec2?" do
15
- subject { Jasmine::Dependencies.rspec2? }
16
- context "when rspec 2 is present" do
17
- before do
18
- Gem::Specification.should_receive(:find_by_name).with("rspec", ">= 2.0").and_return(true)
19
- end
20
- it { should be_true }
21
- end
22
- context "when rspec 2 is not present" do
23
- before do
24
- Gem::Specification.should_receive(:find_by_name).with("rspec", ">= 2.0").and_raise(Gem::LoadError)
25
- end
26
- it { should be_false }
27
- end
28
- end
29
-
30
- describe ".rails2?" do
31
- subject { Jasmine::Dependencies.rails2? }
32
- context "when rails 2 is present and running" do
33
- before do
34
- Gem::Specification.should_receive(:find_by_name).with("rails", "~> 2.3").and_return(true)
35
- Rails.stub(:respond_to?).with(:version).and_return(true)
36
- Rails.stub(:version).and_return(running_rails_version)
37
- end
38
- let(:running_rails_version) { "2.3.11" }
39
- it { should be_true }
40
- end
41
- context "when rails 2 is present but not running" do
42
- before do
43
- Gem::Specification.should_receive(:find_by_name).with("rails", "~> 2.3").and_raise(Gem::LoadError)
44
- end
45
- it { should be_false }
46
- end
47
- context "when rails 2 is not present" do
48
- before do
49
- Gem::Specification.should_receive(:find_by_name).with("rails", "~> 2.3").and_raise(Gem::LoadError)
50
- end
51
- it { should be_false }
52
- end
53
- end
54
-
55
- describe ".legacy_rails?" do
56
- subject { Jasmine::Dependencies.legacy_rails? }
57
- context "when rails < 2.3.11 is present and running" do
58
- before do
59
- Gem::Specification.should_receive(:find_by_name).with("rails", "< 2.3.11").and_return(true)
60
- Rails.stub(:respond_to?).with(:version).and_return(true)
61
- Rails.stub(:version).and_return(running_rails_version)
62
- end
63
- let(:running_rails_version) { "2.3.8" }
64
- it { should be_true }
65
- end
66
- context "when rails < 2.3.11 is present but not running" do
67
- before do
68
- Gem::Specification.should_receive(:find_by_name).with("rails", "< 2.3.11").and_return(true)
69
- end
70
- it { should be_false }
71
- end
72
- context "when rails < 2.3.11 is not present" do
73
- before do
74
- Gem::Specification.should_receive(:find_by_name).with("rails", "< 2.3.11").and_raise(Gem::LoadError)
75
- end
76
- it { should be_false }
77
- end
78
- end
79
-
80
- describe ".rails3?" do
81
- subject { Jasmine::Dependencies.rails3? }
82
- context "when rails 3 is present and running" do
83
- before do
84
- Gem::Specification.should_receive(:find_by_name).with("rails", ">= 3.0").and_return(true)
85
- Rails.stub(:respond_to?).with(:version).and_return(true)
86
- Rails.stub(:version).and_return(running_rails_version)
87
- end
88
- let(:running_rails_version) { "3.2" }
89
- it { should be_true }
90
- end
91
- context "when rails 3 is present but not running" do
92
- before do
93
- Gem::Specification.should_receive(:find_by_name).with("rails", ">= 3.0").and_return(true)
94
- end
95
- it { should be_false }
96
- end
97
- context "when rails 3 is not present" do
98
- before do
99
- Gem::Specification.should_receive(:find_by_name).with("rails", ">= 3.0").and_raise(Gem::LoadError)
100
- end
101
- it { should be_false }
102
- end
103
- end
104
-
105
- describe ".rails_3_asset_pipeline?" do
106
- subject { Jasmine::Dependencies.rails_3_asset_pipeline? }
107
- let(:application) { double(:application) }
108
- let(:running_rails_version) { "3.2" }
109
- before do
110
- Rails.stub(:respond_to?).with(:application).and_return(respond_to_application)
111
- Rails.stub(:application).and_return(application)
112
- Rails.stub(:respond_to?).with(:version).and_return(true)
113
- Rails.stub(:version).and_return(running_rails_version)
114
- end
115
- context "when rails 3 is present and the application pipeline is in use" do
116
- before do
117
- Gem::Specification.should_receive(:find_by_name).with("rails", ">= 3.0").and_return(true)
118
- application.stub(:assets).and_return(rails_application_assets)
119
- end
120
- let(:rails3_present) { true }
121
- let(:respond_to_application) { true }
122
- let(:rails_application_assets) { true }
123
- it { should be_true }
124
- end
125
- context "when rails 3 is present and the application pipeline is not in use" do
126
- before do
127
- Gem::Specification.should_receive(:find_by_name).with("rails", ">= 3.0").and_return(true)
128
- application.stub(:assets).and_return(rails_application_assets)
129
- end
130
- let(:rails3_present) { true }
131
- let(:respond_to_application) { true }
132
- let(:rails_application_assets) { false }
133
- it { should be_false }
134
- end
135
- context "when rails 3 is present but not loaded" do
136
- before do
137
- Gem::Specification.should_receive(:find_by_name).with("rails", ">= 3.0").and_return(true)
138
- application.stub(:assets).and_return(rails_application_assets)
139
- end
140
- let(:rails3_present) { true }
141
- let(:respond_to_application) { false }
142
- let(:rails_application_assets) { false }
143
- it { should be_false }
144
- end
145
- context "when rails 3 is present but doesn't respond to assets" do
146
- before do
147
- Gem::Specification.should_receive(:find_by_name).with("rails", ">= 3.0").and_return(true)
148
- end
149
- let(:rails3_present) { true }
150
- let(:respond_to_application) { true }
151
- it { should be_false }
152
- end
153
- context "when rails 3 is not present" do
154
- before do
155
- Gem::Specification.should_receive(:find_by_name).with("rails", ">= 3.0").and_raise(Gem::LoadError)
156
- end
157
- let(:rails3_present) { false }
158
- let(:respond_to_application) { false }
159
- let(:rails_application_assets) { false }
160
- it { should be_false }
161
- end
162
- end
163
- end
164
-
165
- context "with ruby_gems < 1.8" do
166
- before do
167
- Gem::Specification.should_receive(:respond_to?).with(:find_by_name).and_return(false)
168
- end
169
-
170
- describe ".rspec2?" do
171
- subject { Jasmine::Dependencies.rspec2? }
172
- before do
173
- Gem.should_receive(:available?).with("rspec", ">= 2.0").and_return(rspec2_present)
174
- end
175
- context "when rspec 2 is present" do
176
- let(:rspec2_present) { true }
177
- it { should be_true }
178
- end
179
- context "when rspec 2 is not present" do
180
- let(:rspec2_present) { false }
181
- it { should be_false }
182
- end
183
- end
184
-
185
- describe ".rails2?" do
186
- subject { Jasmine::Dependencies.rails2? }
187
- before do
188
- Gem.should_receive(:available?).with("rails", "~> 2.3").and_return(rails2_present)
189
- end
190
- context "when rails 2 is present and running" do
191
- before do
192
- Rails.stub(:respond_to?).with(:version).and_return(true)
193
- Rails.stub(:version).and_return(running_rails_version)
194
- end
195
-
196
- let(:running_rails_version) { "2.3" }
197
- let(:rails2_present) { true }
198
- it { should be_true }
199
- end
200
- context "when rails 2 is present but not running" do
201
- before do
202
- Rails.stub(:respond_to?).with(:version).and_return(true)
203
- Rails.stub(:version).and_return(running_rails_version)
204
- end
205
-
206
- let(:running_rails_version) { "3.2" }
207
- let(:rails2_present) { true }
208
- it { should be_false }
209
- end
210
- context "when rails 2 is not present" do
211
- let(:rails2_present) { false }
212
- it { should be_false }
213
- end
214
- end
215
-
216
- describe ".legacy_rails?" do
217
- subject { Jasmine::Dependencies.legacy_rails? }
218
- before do
219
- Gem.should_receive(:available?).with("rails", "< 2.3.11").and_return(legacy_rails_present)
220
- end
221
- context "when rails < 2.3.11 is present and running" do
222
- before do
223
- Rails.stub(:respond_to?).with(:version).and_return(true)
224
- Rails.stub(:version).and_return(running_rails_version)
225
- end
226
- let(:running_rails_version) { "2.3.8" }
227
- let(:legacy_rails_present) { true }
228
- it { should be_true }
229
- end
230
-
231
- context "when rails < 2.3.11 is present but not running" do
232
- let(:legacy_rails_present) { true }
233
- it { should be_false }
234
- end
235
-
236
- context "when rails < 2.3.11 is not present" do
237
- let(:legacy_rails_present) { false }
238
- it { should be_false }
239
- end
240
- end
241
-
242
- describe ".rails3?" do
243
- subject { Jasmine::Dependencies.rails3? }
244
- before do
245
- Gem.should_receive(:available?).with("rails", ">= 3.0").and_return(rails3_present)
246
- end
247
- context "when rails 3 is present" do
248
- before do
249
- Rails.stub(:respond_to?).with(:version).and_return(true)
250
- Rails.stub(:version).and_return(running_rails_version)
251
- end
252
- let(:running_rails_version) { "3.2" }
253
- let(:rails3_present) { true }
254
- it { should be_true }
255
- end
256
- context "when rails 3 is not present" do
257
- let(:rails3_present) { false }
258
- it { should be_false }
259
- end
260
- end
261
-
262
- describe ".rails_3_asset_pipeline?" do
263
- subject { Jasmine::Dependencies.rails_3_asset_pipeline? }
264
- let(:application) { double(:application, :assets => rails_application_assets)}
265
- before do
266
- Gem.should_receive(:available?).with("rails", ">= 3.0").and_return(rails3_present)
267
- Rails.stub(:respond_to?).with(:application).and_return(respond_to_application)
268
- Rails.stub(:respond_to?).with(:version).and_return(true)
269
- Rails.stub(:application).and_return(application)
270
- end
271
-
272
- context "when rails 3 is present, running, and the application pipeline is in use" do
273
- before do
274
- Rails.stub(:respond_to?).with(:version).and_return(true)
275
- Rails.stub(:version).and_return(running_rails_version)
276
- end
277
- let(:rails3_present) { true }
278
- let(:running_rails_version) { "3.2" }
279
- let(:respond_to_application) { true }
280
- let(:rails_application_assets) { true }
281
- it { should be_true }
282
- end
283
- context "when rails 3 is present, running, and the application pipeline is not in use" do
284
- before do
285
- Rails.stub(:respond_to?).with(:version).and_return(true)
286
- Rails.stub(:version).and_return(running_rails_version)
287
- end
288
- let(:rails3_present) { true }
289
- let(:running_rails_version) { "3.2" }
290
- let(:respond_to_application) { true }
291
- let(:rails_application_assets) { false }
292
- it { should be_false }
293
- end
294
- context "when rails 3 is present but not loaded" do
295
- before do
296
- Rails.stub(:respond_to?).with(:version).and_return(false)
297
- end
298
- let(:rails3_present) { true }
299
- let(:respond_to_application) { false }
300
- let(:rails_application_assets) { false }
301
- it { should be_false }
302
- end
303
- context "when rails 3 is not present" do
304
- before do
305
- Rails.stub(:respond_to?).with(:version).and_return(false)
306
- end
307
- let(:rails3_present) { false }
308
- let(:respond_to_application) { false }
309
- let(:rails_application_assets) { false }
310
- it { should be_false }
311
- end
312
- end
313
- end
314
- end
315
- end