jasmine-headless-webkit 0.4.2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -319,11 +319,21 @@ void HeadlessSpecRunner::timerEvent(QTimerEvent *event)
319
319
  }
320
320
  }
321
321
 
322
- if ((exitCode == 0 && runnerFiles.count() == 0) || (exitCode != 0)) {
323
- QApplication::instance()->exit(exitCode);
322
+ bool runAgain = true;
323
+
324
+ if (runnerFiles.count() == 0) {
325
+ runAgain = false;
324
326
  } else {
327
+ if (exitCode == 1) {
328
+ runAgain = false;
329
+ }
330
+ }
331
+
332
+ if (runAgain) {
325
333
  isFinished = false;
326
334
  loadSpec();
335
+ } else {
336
+ QApplication::instance()->exit(exitCode);
327
337
  }
328
338
  }
329
339
 
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
20
20
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
21
  s.require_paths = ["lib"]
22
22
 
23
- s.add_dependency 'jasmine'
23
+ s.add_dependency 'jasmine', '~>1.1.beta'
24
24
  s.add_dependency 'coffee-script', '>= 2.2'
25
25
  s.add_dependency 'rainbow'
26
26
  end
@@ -14,8 +14,8 @@ module Jasmine
14
14
  attr_reader :files, :filtered_files, :spec_outside_scope
15
15
 
16
16
  DEFAULT_FILES = [
17
- File.join(Jasmine.root, "lib/jasmine.js"),
18
- File.join(Jasmine.root, "lib/jasmine-html.js"),
17
+ File.join(Jasmine::Core.path, "jasmine.js"),
18
+ File.join(Jasmine::Core.path, "jasmine-html.js"),
19
19
  File.expand_path('../../../jasmine/jasmine.headless-reporter.js', __FILE__)
20
20
  ]
21
21
 
@@ -99,7 +99,7 @@ module Jasmine
99
99
  end
100
100
 
101
101
  def spec_filter
102
- @options[:only] || []
102
+ @spec_filter ||= (@options[:only] ? @options[:only].collect { |path| Dir[path] }.flatten : [])
103
103
  end
104
104
 
105
105
  def use_config!
@@ -117,7 +117,7 @@ module Jasmine
117
117
 
118
118
  @filtered_files += (if searches == 'spec_files'
119
119
  @spec_outside_scope = ((spec_filter | found_files).sort != found_files.sort)
120
- spec_filter || found_files
120
+ spec_filter.empty? ? found_files : (spec_filter || found_files)
121
121
  else
122
122
  found_files
123
123
  end)
@@ -5,6 +5,9 @@ module Jasmine
5
5
  "The jasmine-headless-webkit specrunner (jasmine-webkit-specrunner) could not be found! Try reinstalling the gem."
6
6
  end
7
7
  end
8
+
9
+ class TestFailure < StandardError; end
10
+ class ConsoleLogUsage < StandardError ; end
8
11
  end
9
12
  end
10
13
 
@@ -9,7 +9,7 @@ module Digest
9
9
  def file(file)
10
10
  self
11
11
  end
12
-
12
+
13
13
  def hexdigest
14
14
  'test'
15
15
  end
@@ -35,14 +35,13 @@ module Jasmine
35
35
  yield self if block_given?
36
36
 
37
37
  desc 'Run Jasmine specs headlessly'
38
- task name do
39
- Jasmine::Headless::Runner.run(
40
- :colors => colors,
41
- :remove_html_file => !@keep_on_error,
42
- :jasmine_config => @jasmine_config
43
- )
44
- end
38
+ task(name) { run_rake_task }
39
+
40
+ create_rails_compliant_task if defined?(Rails)
41
+ end
45
42
 
43
+ private
44
+ def create_rails_compliant_task
46
45
  if Rails.version >= "3.1.0"
47
46
  desc 'Force generate static assets without an MD5 hash, all assets end with -test.<ext>'
48
47
  task 'assets:precompile:for_testing' => :environment do
@@ -52,6 +51,19 @@ module Jasmine
52
51
  end
53
52
  end
54
53
  end
54
+
55
+ def run_rake_task
56
+ case Jasmine::Headless::Runner.run(
57
+ :colors => colors,
58
+ :remove_html_file => !@keep_on_error,
59
+ :jasmine_config => @jasmine_config
60
+ )
61
+ when 1
62
+ raise Jasmine::Headless::TestFailure
63
+ when 2
64
+ raise Jasmine::Headless::ConsoleLogUsage
65
+ end
66
+ end
55
67
  end
56
68
  end
57
69
  end
@@ -1,7 +1,7 @@
1
1
  module Jasmine
2
2
  module Headless
3
3
  module Webkit
4
- VERSION = "0.4.2"
4
+ VERSION = "0.5.0"
5
5
  end
6
6
  end
7
7
  end
@@ -26,7 +26,10 @@ describe "jasmine-headless-webkit" do
26
26
  system %{bin/jasmine-headless-webkit -j spec/jasmine/success_with_error/success_with_error.yml --report #{report}}
27
27
  $?.exitstatus.should == 1
28
28
 
29
- report.should be_a_report_containing(0, 0, false)
29
+ # returns are unpredictable due to changes in jasmine! >.<
30
+ # all we can do is ensure that we've actually failed
31
+ #
32
+ # report.should be_a_report_containing(0, 0, false)
30
33
  end
31
34
  end
32
35
 
@@ -88,6 +91,13 @@ describe "jasmine-headless-webkit" do
88
91
 
89
92
  report.should be_a_report_containing(2, 0, false)
90
93
  end
94
+
95
+ it "should succeed and run both, with the first having a console.log call" do
96
+ system %{bin/jasmine-headless-webkit -j spec/jasmine/filtered_success_with_console/filtered_success.yml --report #{report} ./spec/jasmine/filtered_success_with_console/success_one_spec.js}
97
+ $?.exitstatus.should == 2
98
+
99
+ report.should be_a_report_containing(2, 0, true)
100
+ end
91
101
  end
92
102
  end
93
103
  end
@@ -0,0 +1,10 @@
1
+ src_files:
2
+ - spec/jasmine/filtered_success_with_console/src.js
3
+
4
+ spec_files:
5
+ - spec/jasmine/filtered_success_with_console/*_spec.js
6
+
7
+ src_dir: .
8
+ spec_dir: .
9
+
10
+
File without changes
@@ -0,0 +1,7 @@
1
+ describe('success', function() {
2
+ it('should succeed', function() {
3
+ console.log("made it");
4
+ expect(true).toEqual(true);
5
+ });
6
+ });
7
+
@@ -0,0 +1,6 @@
1
+ describe('also success', function() {
2
+ it('should succeed', function() {
3
+ expect(true).toEqual(true);
4
+ });
5
+ });
6
+
@@ -9,8 +9,8 @@ describe Jasmine::FilesList do
9
9
  describe '#initialize' do
10
10
  it "should have default files" do
11
11
  files_list.files.should == [
12
- File.join(Jasmine.root, "lib/jasmine.js"),
13
- File.join(Jasmine.root, "lib/jasmine-html.js"),
12
+ File.join(Jasmine::Core.path, "jasmine.js"),
13
+ File.join(Jasmine::Core.path, "jasmine-html.js"),
14
14
  File.expand_path('jasmine/jasmine.headless-reporter.js')
15
15
  ]
16
16
  end
@@ -68,11 +68,21 @@ describe Jasmine::FilesList do
68
68
  } }
69
69
 
70
70
  before do
71
- %w{one_spec.js two_spec.js}.each do |file|
71
+ %w{one_spec.js two_spec.js whatever.js}.each do |file|
72
72
  File.open(File.join(spec_dir, file), 'w')
73
73
  end
74
74
  end
75
75
 
76
+ context 'empty filter' do
77
+ let(:filter) { [] }
78
+
79
+ it 'should return all files for filtered and all files' do
80
+ files_list.files.any? { |file| file['two_spec.js'] }.should be_true
81
+ files_list.filtered?.should be_false
82
+ files_list.should_not have_spec_outside_scope
83
+ end
84
+ end
85
+
76
86
  context 'filter with a file that is matchable' do
77
87
  let(:filter) { [ File.expand_path('spec/one_spec.js') ] }
78
88
 
@@ -88,6 +98,21 @@ describe Jasmine::FilesList do
88
98
  end
89
99
  end
90
100
 
101
+ context 'filter with a glob' do
102
+ let(:filter) { [ File.expand_path('spec/one*') ] }
103
+
104
+ it 'should return all files for files' do
105
+ files_list.files.any? { |file| file['two_spec.js'] }.should be_true
106
+ files_list.filtered?.should be_true
107
+ files_list.should_not have_spec_outside_scope
108
+ end
109
+
110
+ it 'should return only filtered files for filtered_files' do
111
+ files_list.filtered_files.any? { |file| file['two_spec.js'] }.should be_false
112
+ files_list.should_not have_spec_outside_scope
113
+ end
114
+ end
115
+
91
116
  context 'filter with a file that is not even there' do
92
117
  let(:filter) { [ File.expand_path('spec/whatever.js') ] }
93
118
 
@@ -66,4 +66,36 @@ describe Jasmine::Headless::Options do
66
66
  options[:jasmine_config].should == 'test'
67
67
  end
68
68
  end
69
+
70
+ describe '.from_command_line' do
71
+ before do
72
+ @argv = ARGV.dup
73
+ end
74
+
75
+ let(:options) { described_class.from_command_line }
76
+
77
+ context 'no files specified' do
78
+ before do
79
+ ARGV.replace([])
80
+ end
81
+
82
+ it 'should have no files' do
83
+ options[:files].should == []
84
+ end
85
+ end
86
+
87
+ context 'files specified' do
88
+ before do
89
+ ARGV.replace([ "test" ])
90
+ end
91
+
92
+ it 'should have files' do
93
+ options[:files].should == [ "test" ]
94
+ end
95
+ end
96
+
97
+ after do
98
+ ARGV.replace(@argv)
99
+ end
100
+ end
69
101
  end
@@ -0,0 +1,76 @@
1
+ require 'spec_helper'
2
+ require 'fakefs/spec_helpers'
3
+ require 'jasmine/headless/task'
4
+ require 'mocha'
5
+
6
+ describe Jasmine::Headless::Task do
7
+ before do
8
+ Jasmine::Headless::Task.any_instance.stubs(:desc)
9
+ Jasmine::Headless::Task.any_instance.stubs(:task)
10
+ end
11
+
12
+ after do
13
+ Object.send(:remove_const, :Rails) if defined?(Rails)
14
+ end
15
+
16
+ describe 'define task' do
17
+ context 'without Rails' do
18
+ it 'should not explode when Rails is undefined' do
19
+ Jasmine::Headless::Task.new('jasmine:headless')
20
+ end
21
+ end
22
+
23
+ context 'with Rails' do
24
+ before do
25
+ module Rails
26
+ def self.version
27
+ return "0"
28
+ end
29
+ end
30
+ end
31
+
32
+ it 'should be OK if rails is defined' do
33
+ Jasmine::Headless::Task.new('jasmine:headless')
34
+ end
35
+ end
36
+ end
37
+
38
+ describe 'jasmine:headless integration test' do
39
+ context 'with successful test' do
40
+ let(:test) do
41
+ described_class.new do |t|
42
+ t.jasmine_config = "spec/jasmine/success/success.yml"
43
+ end
44
+ end
45
+
46
+ it 'should do nothing on success' do
47
+ expect { test.send(:run_rake_task) }.to_not raise_error
48
+ end
49
+ end
50
+
51
+ context 'with failing test' do
52
+ let(:test) do
53
+ described_class.new do |t|
54
+ t.jasmine_config = "spec/jasmine/failure/failure.yml"
55
+ end
56
+ end
57
+
58
+ it 'should raise an exception on failure' do
59
+ expect { test.send(:run_rake_task) }.to raise_error(Jasmine::Headless::TestFailure)
60
+ end
61
+ end
62
+
63
+ context 'with console.log using test' do
64
+ let(:test) do
65
+ described_class.new do |t|
66
+ t.jasmine_config = "spec/jasmine/console_log/console_log.yml"
67
+ end
68
+ end
69
+
70
+ it 'should raise an exception on console.log usage' do
71
+ expect { test.send(:run_rake_task) }.to raise_error(Jasmine::Headless::ConsoleLogUsage)
72
+ end
73
+ end
74
+ end
75
+ end
76
+
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: jasmine-headless-webkit
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.4.2
5
+ version: 0.5.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - John Bintz
@@ -12,7 +12,7 @@ autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
14
 
15
- date: 2011-06-23 00:00:00 -04:00
15
+ date: 2011-07-12 00:00:00 -04:00
16
16
  default_executable:
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
@@ -21,9 +21,9 @@ dependencies:
21
21
  requirement: &id001 !ruby/object:Gem::Requirement
22
22
  none: false
23
23
  requirements:
24
- - - ">="
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: "0"
26
+ version: 1.1.beta
27
27
  type: :runtime
28
28
  version_requirements: *id001
29
29
  - !ruby/object:Gem::Dependency
@@ -105,6 +105,10 @@ files:
105
105
  - spec/jasmine/filtered_success/success_one_spec.js
106
106
  - spec/jasmine/filtered_success/success_other_file.js
107
107
  - spec/jasmine/filtered_success/success_two_spec.js
108
+ - spec/jasmine/filtered_success_with_console/filtered_success.yml
109
+ - spec/jasmine/filtered_success_with_console/src.js
110
+ - spec/jasmine/filtered_success_with_console/success_one_spec.js
111
+ - spec/jasmine/filtered_success_with_console/success_two_spec.js
108
112
  - spec/jasmine/success/success.js
109
113
  - spec/jasmine/success/success.yml
110
114
  - spec/jasmine/success/success_spec.js
@@ -114,6 +118,7 @@ files:
114
118
  - spec/lib/jasmine/files_list_spec.rb
115
119
  - spec/lib/jasmine/headless/options_spec.rb
116
120
  - spec/lib/jasmine/headless/runner_spec.rb
121
+ - spec/lib/jasmine/headless/task_spec.rb
117
122
  - spec/lib/jasmine/template_writer_spec.rb
118
123
  - spec/spec_helper.rb
119
124
  has_rdoc: true
@@ -164,6 +169,10 @@ test_files:
164
169
  - spec/jasmine/filtered_success/success_one_spec.js
165
170
  - spec/jasmine/filtered_success/success_other_file.js
166
171
  - spec/jasmine/filtered_success/success_two_spec.js
172
+ - spec/jasmine/filtered_success_with_console/filtered_success.yml
173
+ - spec/jasmine/filtered_success_with_console/src.js
174
+ - spec/jasmine/filtered_success_with_console/success_one_spec.js
175
+ - spec/jasmine/filtered_success_with_console/success_two_spec.js
167
176
  - spec/jasmine/success/success.js
168
177
  - spec/jasmine/success/success.yml
169
178
  - spec/jasmine/success/success_spec.js
@@ -173,5 +182,6 @@ test_files:
173
182
  - spec/lib/jasmine/files_list_spec.rb
174
183
  - spec/lib/jasmine/headless/options_spec.rb
175
184
  - spec/lib/jasmine/headless/runner_spec.rb
185
+ - spec/lib/jasmine/headless/task_spec.rb
176
186
  - spec/lib/jasmine/template_writer_spec.rb
177
187
  - spec/spec_helper.rb