jasmine-headless-webkit 0.2.3 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +1 -0
- data/Guardfile +1 -1
- data/bin/jasmine-headless-webkit +5 -98
- data/ext/jasmine-webkit-specrunner/specrunner.cpp +39 -16
- data/jasmine/jasmine.headless-reporter.coffee +3 -3
- data/jasmine/jasmine.headless-reporter.js +4 -5
- data/lib/jasmine/files_list.rb +122 -0
- data/lib/jasmine/headless/cli.rb +17 -0
- data/lib/jasmine/headless/errors.rb +7 -0
- data/lib/jasmine/headless/options.rb +76 -0
- data/lib/jasmine/headless/railtie.rb +29 -0
- data/lib/jasmine/headless/runner.rb +75 -0
- data/lib/jasmine/headless/task.rb +9 -1
- data/lib/jasmine/template_writer.rb +50 -0
- data/lib/jasmine-headless-webkit/version.rb +1 -1
- data/spec/bin/jasmine-headless-webkit_spec.rb +40 -20
- data/spec/jasmine/coffeescript_error/coffeescript_error.yml +10 -0
- data/spec/jasmine/coffeescript_error/spec.coffee +2 -0
- data/spec/jasmine/coffeescript_error/src.coffee +2 -0
- data/spec/jasmine/filtered_failure/failure_spec.js +6 -0
- data/spec/jasmine/filtered_failure/filtered_failure.yml +10 -0
- data/spec/jasmine/filtered_failure/src.js +0 -0
- data/spec/jasmine/filtered_failure/success_spec.js +6 -0
- data/spec/jasmine/filtered_success/filtered_success.yml +10 -0
- data/spec/jasmine/filtered_success/src.js +0 -0
- data/spec/jasmine/filtered_success/success_one_spec.js +6 -0
- data/spec/jasmine/filtered_success/success_two_spec.js +6 -0
- data/spec/lib/jasmine/files_list_spec.rb +198 -0
- data/spec/lib/jasmine/headless/cli_spec.rb +1 -0
- data/spec/lib/jasmine/headless/options_spec.rb +69 -0
- data/spec/lib/jasmine/headless/runner_spec.rb +72 -0
- data/spec/lib/jasmine/template_writer_spec.rb +37 -0
- data/spec/spec_helper.rb +15 -0
- metadata +42 -7
- data/lib/jasmine/cli.rb +0 -78
- data/spec/lib/jasmine/cli_spec.rb +0 -89
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'jasmine/files_list'
|
2
|
+
|
3
|
+
module Jasmine
|
4
|
+
class TemplateWriter
|
5
|
+
class << self
|
6
|
+
def write!(files_list)
|
7
|
+
output = [
|
8
|
+
[ "specrunner.#{$$}.html", files_list.files_to_html ]
|
9
|
+
]
|
10
|
+
|
11
|
+
output.unshift([ "specrunner.#{$$}.filter.html", files_list.filtered_files_to_html ]) if files_list.filtered?
|
12
|
+
|
13
|
+
output.each do |name, files|
|
14
|
+
File.open(name, 'w') { |fh| fh.print template_for(files) }
|
15
|
+
end
|
16
|
+
|
17
|
+
output.collect(&:first)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
def template_for(files)
|
22
|
+
<<-HTML
|
23
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
24
|
+
<html>
|
25
|
+
<head>
|
26
|
+
<title>Jasmine Test Runner</title>
|
27
|
+
<script type="text/javascript">
|
28
|
+
window.console = { log: function(data) {
|
29
|
+
JHW.log(JSON.stringify(data));
|
30
|
+
}, pp: function(data) {
|
31
|
+
JHW.log(jasmine ? jasmine.pp(data) : JSON.stringify(data));
|
32
|
+
} };
|
33
|
+
</script>
|
34
|
+
#{files.join("\n")}
|
35
|
+
</head>
|
36
|
+
<body>
|
37
|
+
|
38
|
+
<script type="text/javascript">
|
39
|
+
jasmine.getEnv().addReporter(new jasmine.HeadlessReporter());
|
40
|
+
jasmine.getEnv().execute();
|
41
|
+
</script>
|
42
|
+
|
43
|
+
</body>
|
44
|
+
</html>
|
45
|
+
HTML
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
@@ -16,11 +16,7 @@ describe "jasmine-headless-webkit" do
|
|
16
16
|
system %{bin/jasmine-headless-webkit -j spec/jasmine/success/success.yml --report #{report}}
|
17
17
|
$?.exitstatus.should == 0
|
18
18
|
|
19
|
-
|
20
|
-
parts.length.should == 4
|
21
|
-
parts[0].should == "1"
|
22
|
-
parts[1].should == "0"
|
23
|
-
parts[2].should == "F"
|
19
|
+
report.should be_a_report_containing(1, 0, false)
|
24
20
|
end
|
25
21
|
end
|
26
22
|
|
@@ -30,11 +26,7 @@ describe "jasmine-headless-webkit" do
|
|
30
26
|
system %{bin/jasmine-headless-webkit -j spec/jasmine/success_with_error/success_with_error.yml --report #{report}}
|
31
27
|
$?.exitstatus.should == 1
|
32
28
|
|
33
|
-
|
34
|
-
parts.length.should == 4
|
35
|
-
parts[0].should == "1"
|
36
|
-
parts[1].should == "0"
|
37
|
-
parts[2].should == "F"
|
29
|
+
report.should be_a_report_containing(1, 0, false)
|
38
30
|
end
|
39
31
|
end
|
40
32
|
|
@@ -43,11 +35,7 @@ describe "jasmine-headless-webkit" do
|
|
43
35
|
system %{bin/jasmine-headless-webkit -j spec/jasmine/failure/failure.yml --report #{report}}
|
44
36
|
$?.exitstatus.should == 1
|
45
37
|
|
46
|
-
|
47
|
-
parts.length.should == 4
|
48
|
-
parts[0].should == "1"
|
49
|
-
parts[1].should == "1"
|
50
|
-
parts[2].should == "F"
|
38
|
+
report.should be_a_report_containing(1, 1, false)
|
51
39
|
end
|
52
40
|
end
|
53
41
|
|
@@ -56,11 +44,43 @@ describe "jasmine-headless-webkit" do
|
|
56
44
|
system %{bin/jasmine-headless-webkit -j spec/jasmine/console_log/console_log.yml --report #{report}}
|
57
45
|
$?.exitstatus.should == 2
|
58
46
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
47
|
+
report.should be_a_report_containing(1, 0, true)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe 'with coffeescript error' do
|
52
|
+
it "should fail" do
|
53
|
+
system %{bin/jasmine-headless-webkit -j spec/jasmine/coffeescript_error/coffeescript_error.yml --report #{report}}
|
54
|
+
$?.exitstatus.should == 1
|
55
|
+
|
56
|
+
File.exist?(report).should be_false
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe 'with filtered run' do
|
61
|
+
context "don't run a full run, just the filtered run" do
|
62
|
+
it "should succeed and run both" do
|
63
|
+
system %{bin/jasmine-headless-webkit -j spec/jasmine/filtered_success/filtered_success.yml --no-full-run --report #{report} ./spec/jasmine/filtered_success/success_one_spec.js}
|
64
|
+
$?.exitstatus.should == 0
|
65
|
+
|
66
|
+
report.should be_a_report_containing(1, 0, false)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
context "do both runs" do
|
71
|
+
it "should fail and not run the second" do
|
72
|
+
system %{bin/jasmine-headless-webkit -j spec/jasmine/filtered_failure/filtered_failure.yml --report #{report} ./spec/jasmine/filtered_failure/failure_spec.js}
|
73
|
+
$?.exitstatus.should == 1
|
74
|
+
|
75
|
+
report.should be_a_report_containing(1, 1, false)
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should succeed and run both" do
|
79
|
+
system %{bin/jasmine-headless-webkit -j spec/jasmine/filtered_success/filtered_success.yml --report #{report} ./spec/jasmine/filtered_success/success_one_spec.js}
|
80
|
+
$?.exitstatus.should == 0
|
81
|
+
|
82
|
+
report.should be_a_report_containing(2, 0, false)
|
83
|
+
end
|
64
84
|
end
|
65
85
|
end
|
66
86
|
end
|
File without changes
|
File without changes
|
@@ -0,0 +1,198 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'jasmine/files_list'
|
3
|
+
require 'fakefs/spec_helpers'
|
4
|
+
require 'coffee-script'
|
5
|
+
|
6
|
+
describe Jasmine::FilesList do
|
7
|
+
let(:files_list) { Jasmine::FilesList.new }
|
8
|
+
|
9
|
+
describe '#initialize' do
|
10
|
+
it "should have default files" do
|
11
|
+
files_list.files.should == [
|
12
|
+
File.join(Jasmine.root, "lib/jasmine.js"),
|
13
|
+
File.join(Jasmine.root, "lib/jasmine-html.js"),
|
14
|
+
File.expand_path('jasmine/jasmine.headless-reporter.js')
|
15
|
+
]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '#use_config' do
|
20
|
+
let(:files_list) { Jasmine::FilesList.new(:config => config) }
|
21
|
+
|
22
|
+
include FakeFS::SpecHelpers
|
23
|
+
|
24
|
+
let(:src_dir) { 'src' }
|
25
|
+
let(:spec_dir) { 'spec' }
|
26
|
+
|
27
|
+
let(:first_file) { File.join(src_dir, 'js/first_file.js') }
|
28
|
+
let(:src_file) { File.join(src_dir, 'js/src_file.js') }
|
29
|
+
let(:spec_file) { File.join(spec_dir, 'spec_file_spec.js') }
|
30
|
+
let(:helper_file) { File.join(spec_dir, 'helper/helper_file.js') }
|
31
|
+
let(:stylesheet_file) { File.join(src_dir, 'stylesheet/blah.css') }
|
32
|
+
|
33
|
+
before do
|
34
|
+
[ first_file, src_file, spec_file, helper_file, stylesheet_file ].each do |file|
|
35
|
+
File.open(file, 'w')
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
let(:config) { {
|
40
|
+
'src_dir' => src_dir,
|
41
|
+
'spec_dir' => spec_dir,
|
42
|
+
'src_files' => [ 'js/first_file.js', 'js/*.js' ],
|
43
|
+
'spec_files' => [ '*_spec.js' ],
|
44
|
+
'helpers' => [ 'helper/*.js' ],
|
45
|
+
'stylesheets' => [ 'stylesheet/*.css' ]
|
46
|
+
} }
|
47
|
+
|
48
|
+
it 'should read the data from the jasmine.yml file and add the files' do
|
49
|
+
files_list.files.should == Jasmine::FilesList::DEFAULT_FILES + [
|
50
|
+
File.expand_path(first_file),
|
51
|
+
File.expand_path(src_file),
|
52
|
+
File.expand_path(stylesheet_file),
|
53
|
+
File.expand_path(helper_file),
|
54
|
+
File.expand_path(spec_file)
|
55
|
+
]
|
56
|
+
end
|
57
|
+
end
|
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
|
+
context 'with filtered specs' do
|
86
|
+
let(:files_list) { Jasmine::FilesList.new(:only => filter, :config => config) }
|
87
|
+
let(:spec_dir) { 'spec' }
|
88
|
+
|
89
|
+
include FakeFS::SpecHelpers
|
90
|
+
|
91
|
+
let(:config) { {
|
92
|
+
'spec_files' => [ '*_spec.js' ],
|
93
|
+
'spec_dir' => spec_dir
|
94
|
+
} }
|
95
|
+
|
96
|
+
before do
|
97
|
+
%w{one_spec.js two_spec.js}.each do |file|
|
98
|
+
File.open(File.join(spec_dir, file), 'w')
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
let(:filter) { 'spec/one_spec.js' }
|
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
|
+
end
|
108
|
+
|
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
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
describe '#.*files_to_html' do
|
115
|
+
include FakeFS::SpecHelpers
|
116
|
+
|
117
|
+
context 'one coffeescript file' do
|
118
|
+
before do
|
119
|
+
files_list.instance_variable_set(:@files, [
|
120
|
+
'test.js',
|
121
|
+
'test.coffee',
|
122
|
+
'test.css'
|
123
|
+
])
|
124
|
+
|
125
|
+
files_list.instance_variable_set(:@filtered_files, [
|
126
|
+
'test.js',
|
127
|
+
'test.coffee'
|
128
|
+
])
|
129
|
+
|
130
|
+
File.open('test.coffee', 'w') { |fh| fh.print "first" }
|
131
|
+
|
132
|
+
CoffeeScript.stubs(:compile).with() { |field| field.read == "first" }.returns("i compiled")
|
133
|
+
end
|
134
|
+
|
135
|
+
context '#files_to_html' do
|
136
|
+
it "should create the right HTML" do
|
137
|
+
files_list.files_to_html.should == [
|
138
|
+
%{<script type="text/javascript" src="test.js"></script>},
|
139
|
+
%{<script type="text/javascript">i compiled</script>},
|
140
|
+
%{<link rel="stylesheet" href="test.css" type="text/css" />}
|
141
|
+
]
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
context '#filtered_files_to_html' do
|
146
|
+
it "should create the right HTML" do
|
147
|
+
files_list.filtered_files_to_html.should == [
|
148
|
+
%{<script type="text/javascript" src="test.js"></script>},
|
149
|
+
%{<script type="text/javascript">i compiled</script>}
|
150
|
+
]
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
context 'two coffeescript files' do
|
156
|
+
before do
|
157
|
+
files_list.instance_variable_set(:@files, [
|
158
|
+
'test.js',
|
159
|
+
'test.coffee',
|
160
|
+
'test2.coffee',
|
161
|
+
'test.css'
|
162
|
+
])
|
163
|
+
|
164
|
+
files_list.instance_variable_set(:@filtered_files, [
|
165
|
+
'test.js',
|
166
|
+
'test.coffee'
|
167
|
+
])
|
168
|
+
|
169
|
+
File.open('test.coffee', 'w') { |fh| fh.print "first" }
|
170
|
+
File.open('test2.coffee', 'w') { |fh| fh.print "second" }
|
171
|
+
end
|
172
|
+
|
173
|
+
context '#files_to_html' do
|
174
|
+
it "should create the right HTML" do
|
175
|
+
CoffeeScript.stubs(:compile).with() { |field| field.read == "firstsecond" }.returns("i compiled")
|
176
|
+
|
177
|
+
files_list.files_to_html.should == [
|
178
|
+
%{<script type="text/javascript" src="test.js"></script>},
|
179
|
+
%{<script type="text/javascript">i compiled</script>},
|
180
|
+
%{<link rel="stylesheet" href="test.css" type="text/css" />}
|
181
|
+
]
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
context '#filtered_files_to_html' do
|
186
|
+
it "should create the right HTML" do
|
187
|
+
CoffeeScript.stubs(:compile).with() { |field| field.read == "first" }.returns("i compiled")
|
188
|
+
|
189
|
+
files_list.filtered_files_to_html.should == [
|
190
|
+
%{<script type="text/javascript" src="test.js"></script>},
|
191
|
+
%{<script type="text/javascript">i compiled</script>}
|
192
|
+
]
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'jasmine/headless/options'
|
3
|
+
require 'fakefs/spec_helpers'
|
4
|
+
|
5
|
+
describe Jasmine::Headless::Options do
|
6
|
+
let(:options) { Jasmine::Headless::Options.new(opts) }
|
7
|
+
let(:opts) { {} }
|
8
|
+
|
9
|
+
describe '#initialize' do
|
10
|
+
let(:default_config) { 'spec/javascripts/support/jasmine.yml' }
|
11
|
+
|
12
|
+
context 'empty' do
|
13
|
+
it "should have default options" do
|
14
|
+
options[:jasmine_config].should == default_config
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'with provided' do
|
19
|
+
let(:opts) { { :jasmine_config => 'test' } }
|
20
|
+
|
21
|
+
it 'should override an option' do
|
22
|
+
options[:jasmine_config].should == 'test'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'with nil provided' do
|
27
|
+
let(:opts) { { :jasmine_config => nil } }
|
28
|
+
|
29
|
+
it 'should override an option' do
|
30
|
+
options[:jasmine_config].should == default_config
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#process_option' do
|
36
|
+
it 'should process the option and update the object in place' do
|
37
|
+
options[:colors].should be_false
|
38
|
+
options[:jasmine_config].should == 'spec/javascripts/support/jasmine.yml'
|
39
|
+
|
40
|
+
options.process_option('--colors')
|
41
|
+
options.process_option('-j', 'test')
|
42
|
+
|
43
|
+
options[:colors].should be_true
|
44
|
+
options[:jasmine_config].should == 'test'
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '#read_defaults_files' do
|
49
|
+
include FakeFS::SpecHelpers
|
50
|
+
|
51
|
+
let(:global_test_data) { '--colors' }
|
52
|
+
let(:test_data) { '-j test' }
|
53
|
+
|
54
|
+
before do
|
55
|
+
File.open(Jasmine::Headless::Options::GLOBAL_DEFAULTS_FILE, 'w') { |fh| fh.puts global_test_data }
|
56
|
+
File.open(Jasmine::Headless::Options::DEFAULTS_FILE, 'w') { |fh| fh.puts test_data }
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should read the options" do
|
60
|
+
options[:colors].should be_false
|
61
|
+
options[:jasmine_config].should == 'spec/javascripts/support/jasmine.yml'
|
62
|
+
|
63
|
+
options.read_defaults_files
|
64
|
+
|
65
|
+
options[:colors].should be_true
|
66
|
+
options[:jasmine_config].should == 'test'
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'fakefs/spec_helpers'
|
3
|
+
require 'jasmine/headless/runner'
|
4
|
+
|
5
|
+
describe Jasmine::Headless::Runner do
|
6
|
+
let(:runner) { Jasmine::Headless::Runner.new(options) }
|
7
|
+
let(:options) { Jasmine::Headless::Options.new(opts) }
|
8
|
+
|
9
|
+
describe '#initialize' do
|
10
|
+
let(:opts) { { :test => 'test', :jasmine_config => nil } }
|
11
|
+
|
12
|
+
it 'should have default options' do
|
13
|
+
runner.options[:test].should == 'test'
|
14
|
+
runner.options[:jasmine_config].should == 'spec/javascripts/support/jasmine.yml'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#load_config' do
|
19
|
+
include FakeFS::SpecHelpers
|
20
|
+
|
21
|
+
let(:opts) { { :jasmine_config => 'test.yml' } }
|
22
|
+
|
23
|
+
before do
|
24
|
+
File.open(Jasmine::Headless::Runner::RUNNER, 'w')
|
25
|
+
File.open('test.yml', 'w') { |fh| fh.print YAML.dump('test' => 'hello') }
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should load the jasmine config' do
|
29
|
+
runner.jasmine_config['test'].should == 'hello'
|
30
|
+
runner.jasmine_config['spec_dir'].should == 'spec/javascripts'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '#jasmine_command' do
|
35
|
+
let(:opts) { {
|
36
|
+
:colors => true,
|
37
|
+
:report => 'test'
|
38
|
+
} }
|
39
|
+
|
40
|
+
it 'should have the right options' do
|
41
|
+
runner.jasmine_command.should match(/jasmine-webkit-specrunner/)
|
42
|
+
runner.jasmine_command.should match(/-c/)
|
43
|
+
runner.jasmine_command.should match(/-r test/)
|
44
|
+
runner.jasmine_command('file.js').should match(/file.js/)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context 'real tests' do
|
49
|
+
let(:report) { 'spec/report.txt' }
|
50
|
+
|
51
|
+
before do
|
52
|
+
FileUtils.rm_f report
|
53
|
+
end
|
54
|
+
|
55
|
+
after do
|
56
|
+
FileUtils.rm_f report
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should succeed with error code 0' do
|
60
|
+
Jasmine::Headless::Runner.run(
|
61
|
+
:jasmine_config => 'spec/jasmine/success/success.yml',
|
62
|
+
:report => report
|
63
|
+
).should == 0
|
64
|
+
|
65
|
+
report.should be_a_report_containing(1, 0, false)
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'should succeed but with javascript error' do
|
69
|
+
Jasmine::Headless::Runner.run(:jasmine_config => 'spec/jasmine/success_with_error/success_with_error.yml').should == 1
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'jasmine/template_writer'
|
3
|
+
require 'fakefs/spec_helpers'
|
4
|
+
|
5
|
+
describe Jasmine::TemplateWriter do
|
6
|
+
describe '.write!' do
|
7
|
+
include FakeFS::SpecHelpers
|
8
|
+
|
9
|
+
let(:files_list) { Jasmine::FilesList.new }
|
10
|
+
|
11
|
+
before do
|
12
|
+
files_list.files << 'file.js'
|
13
|
+
files_list.filtered_files << 'file.js'
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'no filter' do
|
17
|
+
it 'should write one file' do
|
18
|
+
Jasmine::TemplateWriter.write!(files_list).should == [
|
19
|
+
"specrunner.#{$$}.html"
|
20
|
+
]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'filtered files' do
|
25
|
+
before do
|
26
|
+
files_list.files << 'file2.js'
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should write two files' do
|
30
|
+
Jasmine::TemplateWriter.write!(files_list).should == [
|
31
|
+
"specrunner.#{$$}.filter.html", "specrunner.#{$$}.html"
|
32
|
+
]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
RSpec.configure do |c|
|
2
|
+
c.mock_with :mocha
|
3
|
+
end
|
4
|
+
|
1
5
|
specrunner = 'ext/jasmine-webkit-specrunner/jasmine-webkit-specrunner'
|
2
6
|
|
3
7
|
if !File.file?(specrunner)
|
@@ -6,3 +10,14 @@ if !File.file?(specrunner)
|
|
6
10
|
end
|
7
11
|
end
|
8
12
|
|
13
|
+
RSpec::Matchers.define :be_a_report_containing do |total, fails, used_console|
|
14
|
+
match do |filename|
|
15
|
+
parts = File.read(filename).strip.split('/')
|
16
|
+
parts.length.should == 4
|
17
|
+
parts[0].should == total.to_s
|
18
|
+
parts[1].should == fails.to_s
|
19
|
+
parts[2].should == (used_console ? "T" : "F")
|
20
|
+
true
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|