jasmine-headless-webkit 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,2 +1,8 @@
1
- system %{qmake -spec macx-g++}
1
+ case RUBY_PLATFORM
2
+ when /linux/
3
+ system %{qmake -spec linux-g++}
4
+ else
5
+ system %{qmake -spec macx-g++}
6
+ end
7
+
2
8
  system %{make}
@@ -1,7 +1,7 @@
1
1
  module Jasmine
2
2
  module Headless
3
3
  module Webkit
4
- VERSION = "0.4.1"
4
+ VERSION = "0.4.2"
5
5
  end
6
6
  end
7
7
  end
@@ -11,7 +11,7 @@ end
11
11
 
12
12
  module Jasmine
13
13
  class FilesList
14
- attr_reader :files, :filtered_files
14
+ attr_reader :files, :filtered_files, :spec_outside_scope
15
15
 
16
16
  DEFAULT_FILES = [
17
17
  File.join(Jasmine.root, "lib/jasmine.js"),
@@ -23,13 +23,14 @@ module Jasmine
23
23
  @options = options
24
24
  @files = DEFAULT_FILES.dup
25
25
  @filtered_files = @files.dup
26
+ @spec_outside_scope = false
26
27
  use_config! if config?
27
28
 
28
29
  @code_for_file = {}
29
30
  end
30
31
 
31
- def use_spec?(file)
32
- spec_filter.empty? || spec_filter.include?(file)
32
+ def has_spec_outside_scope?
33
+ @spec_outside_scope
33
34
  end
34
35
 
35
36
  def filtered?
@@ -114,10 +115,12 @@ module Jasmine
114
115
 
115
116
  @files += found_files
116
117
 
117
- if searches == 'spec_files'
118
- found_files = found_files.find_all { |file| use_spec?(file) }
119
- end
120
- @filtered_files += found_files
118
+ @filtered_files += (if searches == 'spec_files'
119
+ @spec_outside_scope = ((spec_filter | found_files).sort != found_files.sort)
120
+ spec_filter || found_files
121
+ else
122
+ found_files
123
+ end)
121
124
  end
122
125
  end
123
126
  end
@@ -1,25 +1,5 @@
1
1
  require 'jasmine/headless/task'
2
2
 
3
- module Digest
4
- class JasmineTest
5
- def self.file(file)
6
- new
7
- end
8
-
9
- def file(file)
10
- self
11
- end
12
-
13
- def hexdigest
14
- 'test'
15
- end
16
-
17
- def update(prefix)
18
- self
19
- end
20
- end
21
- end
22
-
23
3
  module Jasmine
24
4
  module Headless
25
5
  class Railtie < Rails::Railtie
@@ -27,15 +7,6 @@ module Jasmine
27
7
  Jasmine::Headless::Task.new do |t|
28
8
  t.colors = true
29
9
  end
30
-
31
- if Rails.version >= "3.1.0"
32
- desc 'Force generate static assets without an MD5 hash, all assets end with -test.<ext>'
33
- task 'assets:precompile:for_testing' => :environment do
34
- Rails.application.assets.digest_class = Digest::JasmineTest
35
-
36
- Rake::Task['assets:precompile'].invoke
37
- end
38
- end
39
10
  end
40
11
  end
41
12
  end
@@ -58,7 +58,7 @@ module Jasmine
58
58
 
59
59
  targets = Jasmine::TemplateWriter.write!(files_list)
60
60
  run_targets = targets.dup
61
- run_targets.pop if !@options[:full_run] && files_list.filtered?
61
+ run_targets.pop if (!@options[:full_run] && files_list.filtered?) || files_list.has_spec_outside_scope?
62
62
 
63
63
  system jasmine_command(run_targets)
64
64
  status = $?.exitstatus
@@ -1,5 +1,25 @@
1
1
  require 'jasmine/headless/runner'
2
2
 
3
+ module Digest
4
+ class JasmineTest
5
+ def self.file(file)
6
+ new
7
+ end
8
+
9
+ def file(file)
10
+ self
11
+ end
12
+
13
+ def hexdigest
14
+ 'test'
15
+ end
16
+
17
+ def update(prefix)
18
+ self
19
+ end
20
+ end
21
+ end
22
+
3
23
  module Jasmine
4
24
  module Headless
5
25
  class Task
@@ -22,6 +42,15 @@ module Jasmine
22
42
  :jasmine_config => @jasmine_config
23
43
  )
24
44
  end
45
+
46
+ if Rails.version >= "3.1.0"
47
+ desc 'Force generate static assets without an MD5 hash, all assets end with -test.<ext>'
48
+ task 'assets:precompile:for_testing' => :environment do
49
+ Rails.application.assets.digest_class = Digest::JasmineTest
50
+
51
+ Rake::Task['assets:precompile'].invoke
52
+ end
53
+ end
25
54
  end
26
55
  end
27
56
  end
@@ -26,7 +26,7 @@ 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(1, 0, false)
29
+ report.should be_a_report_containing(0, 0, false)
30
30
  end
31
31
  end
32
32
 
@@ -65,6 +65,13 @@ describe "jasmine-headless-webkit" do
65
65
 
66
66
  report.should be_a_report_containing(1, 0, false)
67
67
  end
68
+
69
+ it "should use a file outside the normal test run and only run one" do
70
+ system %{bin/jasmine-headless-webkit -j spec/jasmine/filtered_success/filtered_success.yml --report #{report} ./spec/jasmine/filtered_success/success_other_file.js}
71
+ $?.exitstatus.should == 0
72
+
73
+ report.should be_a_report_containing(1, 0, false)
74
+ end
68
75
  end
69
76
 
70
77
  context "do both runs" do
@@ -0,0 +1,7 @@
1
+ describe('outside success', function() {
2
+ it('should succeed', function() {
3
+ expect(true).toEqual(true);
4
+ });
5
+ });
6
+
7
+
@@ -56,32 +56,6 @@ describe Jasmine::FilesList do
56
56
  end
57
57
  end
58
58
 
59
- describe '#use_spec?' do
60
- let(:spec_file) { 'my/spec.js' }
61
-
62
- let(:files_list) { Jasmine::FilesList.new(:only => filter) }
63
-
64
- context 'no filter provided' do
65
- let(:filter) { [] }
66
-
67
- it "should allow the spec" do
68
- files_list.use_spec?(spec_file).should be_true
69
- end
70
- end
71
-
72
- context 'filter provided' do
73
- let(:filter) { [ spec_file ] }
74
-
75
- it "should use the spec" do
76
- files_list.use_spec?(spec_file).should be_true
77
- end
78
-
79
- it "should not use the spec" do
80
- files_list.use_spec?('other/file').should be_false
81
- end
82
- end
83
- end
84
-
85
59
  context 'with filtered specs' do
86
60
  let(:files_list) { Jasmine::FilesList.new(:only => filter, :config => config) }
87
61
  let(:spec_dir) { 'spec' }
@@ -99,15 +73,28 @@ describe Jasmine::FilesList do
99
73
  end
100
74
  end
101
75
 
102
- let(:filter) { 'spec/one_spec.js' }
76
+ context 'filter with a file that is matchable' do
77
+ let(:filter) { [ File.expand_path('spec/one_spec.js') ] }
103
78
 
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
79
+ it 'should return all files for files' do
80
+ files_list.files.any? { |file| file['two_spec.js'] }.should be_true
81
+ files_list.filtered?.should be_true
82
+ files_list.should_not have_spec_outside_scope
83
+ end
84
+
85
+ it 'should return only filtered files for filtered_files' do
86
+ files_list.filtered_files.any? { |file| file['two_spec.js'] }.should be_false
87
+ files_list.should_not have_spec_outside_scope
88
+ end
107
89
  end
108
90
 
109
- it 'should return only filtered files for filtered_files' do
110
- files_list.filtered_files.any? { |file| file['two_spec.js'] }.should be_false
91
+ context 'filter with a file that is not even there' do
92
+ let(:filter) { [ File.expand_path('spec/whatever.js') ] }
93
+
94
+ it 'should use the provided file' do
95
+ files_list.filtered_files.any? { |file| file['whatever.js'] }.should be_true
96
+ files_list.should have_spec_outside_scope
97
+ end
111
98
  end
112
99
  end
113
100
 
data/spec/spec_helper.rb CHANGED
@@ -12,12 +12,20 @@ end
12
12
 
13
13
  RSpec::Matchers.define :be_a_report_containing do |total, fails, used_console|
14
14
  match do |filename|
15
- parts = File.read(filename).strip.split('/')
16
- parts.length.should == 4
15
+ parts(filename).length.should == 4
17
16
  parts[0].should == total.to_s
18
17
  parts[1].should == fails.to_s
19
18
  parts[2].should == (used_console ? "T" : "F")
20
19
  true
21
20
  end
21
+
22
+ failure_message_for_should do |filename|
23
+ parts(filename)
24
+ "expected #{filename} to be a report containing (#{total}, #{fails}, #{used_console.inspect}), instead it contained (#{parts[0]}, #{parts[1]}, #{(parts[2] == "T").inspect})"
25
+ end
26
+
27
+ def parts(filename = nil)
28
+ @parts ||= File.read(filename).strip.split('/')
29
+ end
22
30
  end
23
31
 
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.1
5
+ version: 0.4.2
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-19 00:00:00 -04:00
15
+ date: 2011-06-23 00:00:00 -04:00
16
16
  default_executable:
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
@@ -58,7 +58,6 @@ extensions:
58
58
  extra_rdoc_files: []
59
59
 
60
60
  files:
61
- - .autotest
62
61
  - .gitignore
63
62
  - .rspec
64
63
  - CHANGELOG.md
@@ -104,6 +103,7 @@ files:
104
103
  - spec/jasmine/filtered_success/filtered_success.yml
105
104
  - spec/jasmine/filtered_success/src.js
106
105
  - spec/jasmine/filtered_success/success_one_spec.js
106
+ - spec/jasmine/filtered_success/success_other_file.js
107
107
  - spec/jasmine/filtered_success/success_two_spec.js
108
108
  - spec/jasmine/success/success.js
109
109
  - spec/jasmine/success/success.yml
@@ -162,6 +162,7 @@ test_files:
162
162
  - spec/jasmine/filtered_success/filtered_success.yml
163
163
  - spec/jasmine/filtered_success/src.js
164
164
  - spec/jasmine/filtered_success/success_one_spec.js
165
+ - spec/jasmine/filtered_success/success_other_file.js
165
166
  - spec/jasmine/filtered_success/success_two_spec.js
166
167
  - spec/jasmine/success/success.js
167
168
  - spec/jasmine/success/success.yml
data/.autotest DELETED
@@ -1,9 +0,0 @@
1
- Autotest.add_hook(:initialize) do |at|
2
- at.add_mapping(%r{bin/.*}, true) do |filename|
3
- at.files_matching(%r{spec/bin/.*})
4
- end
5
-
6
- at.add_mapping(%r{spec/jasmine/.*}, true) do |filename|
7
- at.files_matching(%r{spec/bin/.*})
8
- end
9
- end