jasmine-headless-webkit-firstbanco 0.9.0.rc.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/.rspec +1 -0
- data/CHANGELOG.md +89 -0
- data/Gemfile +30 -0
- data/Guardfile +41 -0
- data/README.md +44 -0
- data/Rakefile +65 -0
- data/bin/jasmine-headless-webkit +11 -0
- data/config/cucumber.yml +2 -0
- data/ext/jasmine-webkit-specrunner/Info.plist +22 -0
- data/ext/jasmine-webkit-specrunner/Makefile.dummy +5 -0
- data/ext/jasmine-webkit-specrunner/Page.cpp +15 -0
- data/ext/jasmine-webkit-specrunner/Page.h +20 -0
- data/ext/jasmine-webkit-specrunner/Runner.cpp +208 -0
- data/ext/jasmine-webkit-specrunner/Runner.h +73 -0
- data/ext/jasmine-webkit-specrunner/common.pri +8 -0
- data/ext/jasmine-webkit-specrunner/extconf.rb +10 -0
- data/ext/jasmine-webkit-specrunner/specrunner.cpp +79 -0
- data/ext/jasmine-webkit-specrunner/specrunner.pro +5 -0
- data/features/bin/failure.feature +7 -0
- data/features/bin/files.feature +7 -0
- data/features/bin/filtered_run/both_runs.feature +18 -0
- data/features/bin/filtered_run/no_full_run.feature +14 -0
- data/features/bin/help.feature +7 -0
- data/features/bin/quiet_messages.feature +8 -0
- data/features/bin/runner_out.feature +8 -0
- data/features/bin/spec_files_with_same_basename.feature +7 -0
- data/features/bin/success.feature +20 -0
- data/features/bin/success_with_js_error.feature +5 -0
- data/features/bin/tries_to_leave_page.feature +7 -0
- data/features/bin/try_to_click_a_button.feature +7 -0
- data/features/bin/two_files_from_src_files.feature +11 -0
- data/features/bin/with_coffeescript_error.feature +7 -0
- data/features/bin/with_console_log.feature +7 -0
- data/features/bin/with_server.feature +7 -0
- data/features/bin/with_window_prompt.feature +7 -0
- data/features/reporters.feature +24 -0
- data/features/runner.feature +34 -0
- data/features/steps/given/i_have_test_suite.rb +2 -0
- data/features/steps/given/no_existing_file.rb +4 -0
- data/features/steps/given/options/i_have_defaults.rb +4 -0
- data/features/steps/given/options/i_have_reporters.rb +10 -0
- data/features/steps/given/options/i_have_runner_options.rb +3 -0
- data/features/steps/then/bin/exit_status_should_be.rb +3 -0
- data/features/steps/then/bin/file_should_contain_runner.rb +4 -0
- data/features/steps/then/bin/following_files_loaded_in_order.rb +10 -0
- data/features/steps/then/bin/i_should_get_help_output.rb +4 -0
- data/features/steps/then/bin/output_should_include.rb +3 -0
- data/features/steps/then/bin/output_should_not_include.rb +4 -0
- data/features/steps/then/reporting/report_does_not_exist.rb +4 -0
- data/features/steps/then/reporting/report_should_exist.rb +3 -0
- data/features/steps/then/reporting/report_should_have.rb +7 -0
- data/features/steps/then/reporting/report_should_have_seed.rb +4 -0
- data/features/steps/then/runner/it_should_have_exit_status.rb +3 -0
- data/features/steps/then/runner/it_should_include_report_file.rb +4 -0
- data/features/steps/then/runner/it_should_not_include_report_file.rb +3 -0
- data/features/steps/then/templates/it_should_use_reporter.rb +6 -0
- data/features/steps/when/i_delete_file.rb +3 -0
- data/features/steps/when/i_get_runner.rb +4 -0
- data/features/steps/when/i_get_template_writer.rb +4 -0
- data/features/steps/when/i_run_executable.rb +4 -0
- data/features/steps/when/i_run_runner.rb +4 -0
- data/features/support/env.rb +7 -0
- data/jasmine-headless-webkit-firstbanco.gemspec +30 -0
- data/lib/autotest/discover.rb +1 -0
- data/lib/autotest/jasmine.rb +7 -0
- data/lib/autotest/jasmine_mixin.rb +111 -0
- data/lib/autotest/jasmine_rspec2.rb +7 -0
- data/lib/jasmine-headless-webkit.rb +3 -0
- data/lib/jasmine/headless.rb +61 -0
- data/lib/jasmine/headless/cacheable_action.rb +85 -0
- data/lib/jasmine/headless/coffee_script_cache.rb +20 -0
- data/lib/jasmine/headless/coffee_template.rb +36 -0
- data/lib/jasmine/headless/command_line.rb +31 -0
- data/lib/jasmine/headless/css_template.rb +19 -0
- data/lib/jasmine/headless/errors.rb +16 -0
- data/lib/jasmine/headless/file_checker.rb +25 -0
- data/lib/jasmine/headless/files_list.rb +332 -0
- data/lib/jasmine/headless/js_template.rb +23 -0
- data/lib/jasmine/headless/jst_template.rb +15 -0
- data/lib/jasmine/headless/nil_template.rb +14 -0
- data/lib/jasmine/headless/options.rb +206 -0
- data/lib/jasmine/headless/railtie.rb +12 -0
- data/lib/jasmine/headless/report.rb +81 -0
- data/lib/jasmine/headless/report_message.rb +12 -0
- data/lib/jasmine/headless/report_message/console.rb +18 -0
- data/lib/jasmine/headless/report_message/error.rb +20 -0
- data/lib/jasmine/headless/report_message/fail.rb +5 -0
- data/lib/jasmine/headless/report_message/pass.rb +5 -0
- data/lib/jasmine/headless/report_message/seed.rb +14 -0
- data/lib/jasmine/headless/report_message/spec.rb +28 -0
- data/lib/jasmine/headless/report_message/total.rb +31 -0
- data/lib/jasmine/headless/runner.rb +264 -0
- data/lib/jasmine/headless/spec_file_analyzer.rb +44 -0
- data/lib/jasmine/headless/task.rb +39 -0
- data/lib/jasmine/headless/template_writer.rb +65 -0
- data/lib/jasmine/headless/unique_asset_list.rb +16 -0
- data/lib/jasmine/headless/version.rb +5 -0
- data/lib/qt/qmake.rb +155 -0
- data/script/gemfile +11 -0
- data/script/hooks/post-commit +4 -0
- data/script/hooks/pre-commit +15 -0
- data/script/initialize-environment +35 -0
- data/script/install-git-hooks +6 -0
- data/skel/template.html.erb +77 -0
- data/spec/files/UTF-8-test.txt +0 -0
- data/spec/integration/randomization_spec.rb +13 -0
- data/spec/integration/specify_runner_file_spec.rb +22 -0
- data/spec/integration/sprockets_spec.rb +23 -0
- data/spec/jasmine/click_button/click_button.js +5 -0
- data/spec/jasmine/click_button/click_button.yml +12 -0
- data/spec/jasmine/click_button/click_button_spec.js +11 -0
- 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/console_log/console_log.js +1 -0
- data/spec/jasmine/console_log/console_log.yml +10 -0
- data/spec/jasmine/console_log/console_log_spec.js +7 -0
- data/spec/jasmine/failure/failure.js +1 -0
- data/spec/jasmine/failure/failure.yml +9 -0
- data/spec/jasmine/failure/failure_spec.js +6 -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_other_file.js +7 -0
- data/spec/jasmine/filtered_success/success_two_spec.js +6 -0
- data/spec/jasmine/filtered_success_with_console/filtered_success.yml +10 -0
- data/spec/jasmine/filtered_success_with_console/src.js +0 -0
- data/spec/jasmine/filtered_success_with_console/success_one_spec.js +7 -0
- data/spec/jasmine/filtered_success_with_console/success_two_spec.js +6 -0
- data/spec/jasmine/leave_page/leave_page.js +4 -0
- data/spec/jasmine/leave_page/leave_page.yml +9 -0
- data/spec/jasmine/leave_page/leave_page_spec.js +11 -0
- data/spec/jasmine/noisy/file.js.erb +0 -0
- data/spec/jasmine/noisy/noisy.yml +8 -0
- data/spec/jasmine/noisy/other_file.js +2 -0
- data/spec/jasmine/runner_out_in_jasmine_yml/jasmine.yml +11 -0
- data/spec/jasmine/runner_out_in_jasmine_yml/test.js +2 -0
- data/spec/jasmine/runner_out_in_jasmine_yml/test_spec.coffee +4 -0
- data/spec/jasmine/success/success.js +1 -0
- data/spec/jasmine/success/success.yml +9 -0
- data/spec/jasmine/success/success_spec.js +6 -0
- data/spec/jasmine/success_with_error/success_with_error.js +3 -0
- data/spec/jasmine/success_with_error/success_with_error.yml +9 -0
- data/spec/jasmine/success_with_error/success_with_error_spec.js +6 -0
- data/spec/jasmine/two_files_from_src_files/app/app-file.js +0 -0
- data/spec/jasmine/two_files_from_src_files/app/app.js +2 -0
- data/spec/jasmine/two_files_from_src_files/jasmine.yml +7 -0
- data/spec/jasmine/two_files_from_src_files/vendor/vendor-file.js +0 -0
- data/spec/jasmine/two_files_from_src_files/vendor/vendor.js +2 -0
- data/spec/jasmine/two_spec_files_same_basename/jasmine.yml +6 -0
- data/spec/jasmine/two_spec_files_same_basename/spec.coffee +4 -0
- data/spec/jasmine/two_spec_files_same_basename/spec.js +6 -0
- data/spec/jasmine/window_prompt/source.js +2 -0
- data/spec/jasmine/window_prompt/window_prompt.yml +4 -0
- data/spec/jasmine/with_sprockets_includes/assets/application.js.erb +2 -0
- data/spec/jasmine/with_sprockets_includes/assets/things/code.js +6 -0
- data/spec/jasmine/with_sprockets_includes/assets/things/jquery.string.js +0 -0
- data/spec/jasmine/with_sprockets_includes/assets/things/required.js +3 -0
- data/spec/jasmine/with_sprockets_includes/assets/things/subcode/more_code.js +2 -0
- data/spec/jasmine/with_sprockets_includes/assets/things/templates/that.jst.ejs +1 -0
- data/spec/jasmine/with_sprockets_includes/assets/things/templates/this.jst +2 -0
- data/spec/jasmine/with_sprockets_includes/spec/spec_helper.js +1 -0
- data/spec/jasmine/with_sprockets_includes/spec/things/code_spec.js +9 -0
- data/spec/jasmine/with_sprockets_includes/with_sprockets_includes.yml +12 -0
- data/spec/javascripts/console.log_spec.coffee +15 -0
- data/spec/javascripts/headless_reporter_result_spec.coffee +30 -0
- data/spec/javascripts/helpers/spec_helper.coffee +2 -0
- data/spec/javascripts/jasmine-extensions_spec.coffee +80 -0
- data/spec/javascripts/jasmine.HeadlessReporter.ConsoleBase_spec.coffee +35 -0
- data/spec/javascripts/jasmine.HeadlessReporter.Console_spec.coffee +3 -0
- data/spec/javascripts/jasmine.HeadlessReporter.Tap_spec.coffee +19 -0
- data/spec/javascripts/jasmine.HeadlessReporter_spec.coffee +27 -0
- data/spec/javascripts/support/jasmine.yml +9 -0
- data/spec/lib/jasmine/headless/cacheable_action_spec.rb +122 -0
- data/spec/lib/jasmine/headless/coffee_script_cache_spec.rb +21 -0
- data/spec/lib/jasmine/headless/coffee_template_spec.rb +55 -0
- data/spec/lib/jasmine/headless/css_template_spec.rb +25 -0
- data/spec/lib/jasmine/headless/file_checker_spec.rb +41 -0
- data/spec/lib/jasmine/headless/files_list_spec.rb +194 -0
- data/spec/lib/jasmine/headless/js_template_spec.rb +31 -0
- data/spec/lib/jasmine/headless/jst_template_spec.rb +21 -0
- data/spec/lib/jasmine/headless/nil_template_spec.rb +31 -0
- data/spec/lib/jasmine/headless/options_spec.rb +194 -0
- data/spec/lib/jasmine/headless/report_message/seed_spec.rb +18 -0
- data/spec/lib/jasmine/headless/report_message/spec_spec.rb +20 -0
- data/spec/lib/jasmine/headless/report_spec.rb +95 -0
- data/spec/lib/jasmine/headless/runner_spec.rb +247 -0
- data/spec/lib/jasmine/headless/spec_file_analyzer_spec.rb +68 -0
- data/spec/lib/jasmine/headless/task_spec.rb +92 -0
- data/spec/lib/jasmine/headless/template_writer_spec.rb +92 -0
- data/spec/lib/jasmine/headless/unique_asset_list_spec.rb +22 -0
- data/spec/lib/jasmine/headless_spec.rb +38 -0
- data/spec/lib/qt/qmake_spec.rb +142 -0
- data/spec/skel/template.html.erb_spec.rb +8 -0
- data/spec/spec_helper.rb +113 -0
- data/vendor/assets/coffeescripts/headless_reporter_result.coffee +49 -0
- data/vendor/assets/coffeescripts/prolog.coffee +100 -0
- data/vendor/assets/javascripts/beautify-html.js +463 -0
- data/vendor/assets/javascripts/headless_reporter_result.js +79 -0
- data/vendor/assets/javascripts/intense.coffee +28 -0
- data/vendor/assets/javascripts/jasmine-extensions.coffee +97 -0
- data/vendor/assets/javascripts/jasmine.HeadlessReporter.Console.coffee +8 -0
- data/vendor/assets/javascripts/jasmine.HeadlessReporter.ConsoleBase.coffee +92 -0
- data/vendor/assets/javascripts/jasmine.HeadlessReporter.File.coffee +24 -0
- data/vendor/assets/javascripts/jasmine.HeadlessReporter.Tap.coffee +28 -0
- data/vendor/assets/javascripts/jasmine.HeadlessReporter.Verbose.coffee +64 -0
- data/vendor/assets/javascripts/jasmine.HeadlessReporter.coffee +58 -0
- data/vendor/assets/javascripts/jsDump.js +209 -0
- data/vendor/assets/javascripts/prolog.js +108 -0
- metadata +347 -0
@@ -0,0 +1,35 @@
|
|
1
|
+
describe 'jasmine.HeadlessReporter.ConsoleBase', ->
|
2
|
+
reporter = null
|
3
|
+
|
4
|
+
beforeEach ->
|
5
|
+
reporter = new jasmine.HeadlessReporter.ConsoleBase()
|
6
|
+
|
7
|
+
describe '#formatResultLine', ->
|
8
|
+
context 'length = 1', ->
|
9
|
+
it 'should format', ->
|
10
|
+
reporter.length = 1
|
11
|
+
expect(reporter.formatResultLine(0)).toMatch(/test,/)
|
12
|
+
|
13
|
+
context 'length != 1', ->
|
14
|
+
it 'should format', ->
|
15
|
+
reporter.length = 2
|
16
|
+
expect(reporter.formatResultLine(0)).toMatch(/tests,/)
|
17
|
+
|
18
|
+
context 'failedCount = 1', ->
|
19
|
+
it 'should format', ->
|
20
|
+
reporter.failedCount = 1
|
21
|
+
expect(reporter.formatResultLine(0)).toMatch(/failure,/)
|
22
|
+
|
23
|
+
context 'failedCount != 1', ->
|
24
|
+
it 'should format', ->
|
25
|
+
reporter.failedCount = 0
|
26
|
+
expect(reporter.formatResultLine(0)).toMatch(/failures,/)
|
27
|
+
|
28
|
+
context 'runtime = 1', ->
|
29
|
+
it 'should format', ->
|
30
|
+
expect(reporter.formatResultLine(1)).toMatch(/sec./)
|
31
|
+
|
32
|
+
context 'runtime != 1', ->
|
33
|
+
it 'should format', ->
|
34
|
+
expect(reporter.formatResultLine(0)).toMatch(/secs./)
|
35
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
describe 'jasmine.HeadlessReporter.Tap', ->
|
2
|
+
beforeEach ->
|
3
|
+
@reporter = new jasmine.HeadlessReporter.Tap()
|
4
|
+
|
5
|
+
describe '#reportRunnerResults', ->
|
6
|
+
it 'should write nothing for nothing', ->
|
7
|
+
@reporter.output = []
|
8
|
+
|
9
|
+
@reporter.reportRunnerResults(null)
|
10
|
+
|
11
|
+
expect(@reporter.output[0]).not.toBeDefined()
|
12
|
+
|
13
|
+
it 'should report the length right', ->
|
14
|
+
@reporter.output = [ 'test' ]
|
15
|
+
|
16
|
+
@reporter.reportRunnerResults(null)
|
17
|
+
|
18
|
+
expect(@reporter.output[0]).toEqual('1..1')
|
19
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
describe 'jasmine.HeadlessReporter', ->
|
2
|
+
reporter = null
|
3
|
+
|
4
|
+
beforeEach ->
|
5
|
+
reporter = new jasmine.HeadlessReporter()
|
6
|
+
|
7
|
+
it 'should stop running specs if there are errors reported', ->
|
8
|
+
# otherwise it gets really confusing!
|
9
|
+
|
10
|
+
suite = { finish: -> null }
|
11
|
+
spec = new jasmine.Spec("env", suite, "test")
|
12
|
+
|
13
|
+
spyOn(reporter, 'hasError').andReturn(true)
|
14
|
+
spyOn(spec, 'finish')
|
15
|
+
spyOn(suite, 'finish')
|
16
|
+
|
17
|
+
reporter.reportSpecStarting(spec)
|
18
|
+
|
19
|
+
expect(spec.finish).toHaveBeenCalled()
|
20
|
+
expect(suite.finish).toHaveBeenCalled()
|
21
|
+
|
22
|
+
describe '#reportRunnerStarting', ->
|
23
|
+
it 'should start getting time', ->
|
24
|
+
expect(reporter.startTime).not.toBeDefined()
|
25
|
+
reporter.reportRunnerStarting("runner")
|
26
|
+
expect(reporter.startTime).toBeDefined()
|
27
|
+
|
@@ -0,0 +1,122 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Jasmine::Headless::CacheableAction do
|
4
|
+
include FakeFS::SpecHelpers
|
5
|
+
|
6
|
+
let(:file) { 'dir/file.whatever' }
|
7
|
+
let(:data) { 'data' }
|
8
|
+
let(:compiled) { 'compiled' }
|
9
|
+
|
10
|
+
before do
|
11
|
+
FileUtils.mkdir_p File.dirname(file)
|
12
|
+
|
13
|
+
File.open(file, 'wb') { |fh| fh.print(data) }
|
14
|
+
|
15
|
+
described_class.cache_dir = cache_dir
|
16
|
+
described_class.cache_type = cache_type
|
17
|
+
end
|
18
|
+
|
19
|
+
let(:action_runs!) do
|
20
|
+
described_class.any_instance.expects(:action).returns(compiled)
|
21
|
+
end
|
22
|
+
|
23
|
+
let(:cache_type) { 'action' }
|
24
|
+
let(:cache_dir) { 'cache' }
|
25
|
+
let(:cache_file) { File.join(cache_dir, cache_type, file) + '.js' }
|
26
|
+
let(:cache_file_data) { YAML.load(File.read(cache_file)) }
|
27
|
+
|
28
|
+
let(:cache_object) { described_class.new(file) }
|
29
|
+
|
30
|
+
describe '.for' do
|
31
|
+
context 'cache disabled' do
|
32
|
+
before do
|
33
|
+
described_class.enabled = false
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should compile' do
|
37
|
+
action_runs!
|
38
|
+
described_class.for(file).should == compiled
|
39
|
+
cache_file.should_not be_a_file
|
40
|
+
|
41
|
+
cache_object.should_not be_cached
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'cache enabled' do
|
46
|
+
before do
|
47
|
+
described_class.enabled = true
|
48
|
+
FileUtils.mkdir_p(cache_dir)
|
49
|
+
|
50
|
+
File.stubs(:mtime).with(file).returns(Time.at(10))
|
51
|
+
File.stubs(:mtime).with(File.expand_path(cache_file)).returns(Time.at(cache_file_mtime))
|
52
|
+
end
|
53
|
+
|
54
|
+
context 'cache empty' do
|
55
|
+
let(:cache_file_mtime) { 0 }
|
56
|
+
|
57
|
+
it 'should compile' do
|
58
|
+
action_runs!
|
59
|
+
described_class.for(file).should == compiled
|
60
|
+
|
61
|
+
cache_file_data.should == compiled
|
62
|
+
cache_object.should be_cached
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context 'cache fresh' do
|
67
|
+
let(:cache_file_mtime) { 15 }
|
68
|
+
|
69
|
+
before do
|
70
|
+
FileUtils.mkdir_p File.split(cache_file).first
|
71
|
+
File.open(cache_file, 'wb') { |fh| fh.print compiled }
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'should not compile' do
|
75
|
+
action_runs!.never
|
76
|
+
|
77
|
+
described_class.for(file).should == compiled
|
78
|
+
|
79
|
+
cache_file_data.should == compiled
|
80
|
+
cache_object.should be_cached
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
context 'cache stale' do
|
85
|
+
let(:cache_file_mtime) { 5 }
|
86
|
+
|
87
|
+
it 'should compile' do
|
88
|
+
action_runs!
|
89
|
+
|
90
|
+
described_class.for(file).should == compiled
|
91
|
+
|
92
|
+
cache_file_data.should == compiled
|
93
|
+
cache_object.should be_cached
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
describe '#relative_cache_file' do
|
100
|
+
context 'file is an absolute windows file' do
|
101
|
+
let(:current_path) { 'C:/path' }
|
102
|
+
let(:filename) { "file.coffee" }
|
103
|
+
let(:windows_path) { File.join(current_path, filename) }
|
104
|
+
let(:cache_dir) { 'cache dir' }
|
105
|
+
let(:cache_type) { 'cache type' }
|
106
|
+
|
107
|
+
before do
|
108
|
+
cache_object.stubs(:file).returns(windows_path)
|
109
|
+
|
110
|
+
described_class.stubs(:cache_dir).returns(cache_dir)
|
111
|
+
described_class.stubs(:cache_type).returns(cache_type)
|
112
|
+
|
113
|
+
Dir.stubs(:pwd).returns(current_path)
|
114
|
+
end
|
115
|
+
|
116
|
+
subject { cache_object.relative_cache_file }
|
117
|
+
|
118
|
+
it { should == File.join(cache_dir, cache_type, filename) }
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Jasmine::Headless::CoffeeScriptCache do
|
4
|
+
include FakeFS::SpecHelpers
|
5
|
+
|
6
|
+
describe '#action' do
|
7
|
+
let(:file) { 'file' }
|
8
|
+
let(:data) { 'data' }
|
9
|
+
let(:compiled) { 'compiled' }
|
10
|
+
|
11
|
+
before do
|
12
|
+
CoffeeScript.expects(:compile).with(data).returns(compiled)
|
13
|
+
File.open(file, 'wb') { |fh| fh.print(data) }
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should compile coffeescript' do
|
17
|
+
described_class.new(file).action.should == compiled
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Jasmine::Headless::CoffeeTemplate do
|
4
|
+
let(:data) { 'data' }
|
5
|
+
let(:path) { 'path.coffee' }
|
6
|
+
|
7
|
+
let(:template) { described_class.new(path) { data } }
|
8
|
+
|
9
|
+
subject { template.render }
|
10
|
+
|
11
|
+
let(:handle_expectation) { Jasmine::Headless::CoffeeScriptCache.any_instance.stubs(:handle) }
|
12
|
+
|
13
|
+
context 'compilation error' do
|
14
|
+
let(:error) { CoffeeScript::CompilationError.new("fail") }
|
15
|
+
|
16
|
+
before do
|
17
|
+
handle_expectation.raises(error)
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should pass along the error' do
|
21
|
+
expect { subject }.to raise_error(CoffeeScript::CompilationError)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'compiles fine' do
|
26
|
+
let(:source) { 'source' }
|
27
|
+
|
28
|
+
before do
|
29
|
+
Jasmine::Headless::CoffeeScriptCache.any_instance.stubs(:cached?).returns(cache_return)
|
30
|
+
handle_expectation.returns(source)
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'cached' do
|
34
|
+
let(:file_path) { 'dir/file.js' }
|
35
|
+
let(:cache_return) { true }
|
36
|
+
|
37
|
+
before do
|
38
|
+
Jasmine::Headless::CoffeeScriptCache.any_instance.stubs(:cache_file).returns(file_path)
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should return the cached file' do
|
42
|
+
subject.should include(%{<script type="text/javascript" src="#{file_path}"></script>})
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'not cached' do
|
47
|
+
let(:cache_return) { false }
|
48
|
+
|
49
|
+
it 'should return the generated js' do
|
50
|
+
subject.should include(%{<script type="text/javascript">#{source}</script>})
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Jasmine::Headless::CSSTemplate do
|
4
|
+
include FakeFS::SpecHelpers
|
5
|
+
|
6
|
+
let(:template) { described_class.new(file) { data } }
|
7
|
+
let(:file) { 'file' }
|
8
|
+
let(:data) { 'data' }
|
9
|
+
|
10
|
+
subject { template.render }
|
11
|
+
|
12
|
+
before do
|
13
|
+
File.open(file, 'wb') if file
|
14
|
+
end
|
15
|
+
|
16
|
+
context "no file'" do
|
17
|
+
let(:file) { nil }
|
18
|
+
|
19
|
+
it { should == data }
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'file' do
|
23
|
+
it { should == %{<link rel="stylesheet" href="#{file}" type="text/css" />} }
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Jasmine::Headless::FileChecker do
|
4
|
+
let(:test_class) do
|
5
|
+
object = Object.new
|
6
|
+
object.class.send(:include, Jasmine::Headless::FileChecker)
|
7
|
+
object
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#bad_format?" do
|
11
|
+
subject { test_class.bad_format?(file) }
|
12
|
+
|
13
|
+
before do
|
14
|
+
test_class.stubs(:excluded_formats).returns(%w{erb string})
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'nil' do
|
18
|
+
let(:file) { nil }
|
19
|
+
|
20
|
+
it { should be_nil }
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'allowed format' do
|
24
|
+
let(:file) { 'foobar.js' }
|
25
|
+
|
26
|
+
it { should be_false }
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'unallowed format' do
|
30
|
+
let(:file) { 'foobar.erb' }
|
31
|
+
|
32
|
+
it { should be_true }
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'check whole extension' do
|
36
|
+
let(:file) { 'foobar.string.js' }
|
37
|
+
|
38
|
+
it { should be_true }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,194 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'fakefs/spec_helpers'
|
3
|
+
require 'coffee-script'
|
4
|
+
|
5
|
+
describe Jasmine::Headless::FilesList do
|
6
|
+
let(:files_list) { described_class.new }
|
7
|
+
|
8
|
+
describe '#initialize' do
|
9
|
+
before do
|
10
|
+
described_class.any_instance.stubs(:load_initial_assets)
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '#spec_file_line_numbers' do
|
14
|
+
include FakeFS::SpecHelpers
|
15
|
+
|
16
|
+
before do
|
17
|
+
files_list.stubs(:spec_files).returns(['test.coffee', 'test2.coffee'])
|
18
|
+
|
19
|
+
File.open('test.coffee', 'w') { |fh| fh.print "describe('cat')\ndescribe('cat')" }
|
20
|
+
File.open('test2.coffee', 'w') { |fh| fh.print "no matches" }
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should generate filenames and line number info' do
|
24
|
+
files_list.spec_file_line_numbers.should == {
|
25
|
+
'test.coffee' => { 'cat' => [ 1, 2 ] }
|
26
|
+
}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#search_paths' do
|
31
|
+
let(:files_list) { described_class.new(:config => config) }
|
32
|
+
|
33
|
+
let(:config) { {
|
34
|
+
'src_dir' => src_dir,
|
35
|
+
'spec_dir' => spec_dir,
|
36
|
+
'asset_paths' => asset_paths
|
37
|
+
} }
|
38
|
+
|
39
|
+
let(:src_dir) { 'src dir' }
|
40
|
+
let(:spec_dir) { 'spec dir' }
|
41
|
+
let(:asset_paths) { [] }
|
42
|
+
let(:path) { 'path' }
|
43
|
+
|
44
|
+
before do
|
45
|
+
Jasmine::Headless::FilesList.stubs(:asset_paths).returns([])
|
46
|
+
end
|
47
|
+
|
48
|
+
let(:vendor_path) { Jasmine::Headless.root.join('vendor/assets/javascripts').to_s }
|
49
|
+
|
50
|
+
context 'no vendored gem paths' do
|
51
|
+
it 'should take the src dir and spec dirs' do
|
52
|
+
files_list.search_paths.should == [ Jasmine::Core.path, vendor_path, File.expand_path(src_dir), File.expand_path(spec_dir) ]
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'vendored gem paths' do
|
57
|
+
before do
|
58
|
+
Jasmine::Headless::FilesList.stubs(:asset_paths).returns([ path ])
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'should add the vendor gem paths to the list' do
|
62
|
+
files_list.search_paths.should == [ Jasmine::Core.path, vendor_path, path, File.expand_path(src_dir), File.expand_path(spec_dir) ]
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context 'multiple dirs' do
|
67
|
+
let(:dir_1) { 'dir 1' }
|
68
|
+
let(:dir_2) { 'dir 2' }
|
69
|
+
|
70
|
+
context 'src_dir is an array' do
|
71
|
+
let(:src_dir) { [ dir_1, dir_2 ] }
|
72
|
+
|
73
|
+
it 'should take the src dir and spec dirs' do
|
74
|
+
files_list.search_paths.should == [ Jasmine::Core.path, vendor_path, File.expand_path(dir_1), File.expand_path(dir_2), File.expand_path(spec_dir) ]
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
context 'asset_paths has entries' do
|
79
|
+
let(:src_dir) { dir_1 }
|
80
|
+
let(:asset_paths) { [ dir_2 ] }
|
81
|
+
|
82
|
+
it 'should take the src dir and spec dirs' do
|
83
|
+
files_list.search_paths.should == [ Jasmine::Core.path, vendor_path, File.expand_path(dir_1), File.expand_path(dir_2), File.expand_path(spec_dir) ]
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe '#files' do
|
90
|
+
let(:path_one) { 'one' }
|
91
|
+
let(:path_two) { 'two' }
|
92
|
+
let(:path_three) { 'three' }
|
93
|
+
|
94
|
+
let(:file_one) { stub(:to_a => [ asset_one, asset_two ] ) }
|
95
|
+
let(:file_two) { stub(:to_a => [ asset_two, asset_three ] ) }
|
96
|
+
|
97
|
+
let(:asset_one) { stub(:pathname => Pathname(path_one), :to_ary => nil) }
|
98
|
+
let(:asset_two) { stub(:pathname => Pathname(path_two), :to_ary => nil) }
|
99
|
+
let(:asset_three) { stub(:pathname => Pathname(path_three), :to_ary => nil) }
|
100
|
+
|
101
|
+
before do
|
102
|
+
files_list.stubs(:required_files).returns(Jasmine::Headless::UniqueAssetList.new([ file_one, file_two ]))
|
103
|
+
end
|
104
|
+
|
105
|
+
subject { files_list.files }
|
106
|
+
|
107
|
+
it { should == [ path_one, path_two, path_three ] }
|
108
|
+
end
|
109
|
+
|
110
|
+
describe '#filtered_files' do
|
111
|
+
let(:spec_dir) { 'spec' }
|
112
|
+
|
113
|
+
let(:file_one) { "#{spec_dir}/one" }
|
114
|
+
let(:file_two) { "#{spec_dir}/two" }
|
115
|
+
let(:file_three) { "#{spec_dir}/three" }
|
116
|
+
let(:file_four) { 'other/four' }
|
117
|
+
|
118
|
+
before do
|
119
|
+
files_list.stubs(:files).returns([
|
120
|
+
file_one,
|
121
|
+
file_two,
|
122
|
+
file_three,
|
123
|
+
file_four
|
124
|
+
])
|
125
|
+
|
126
|
+
files_list.stubs(:potential_files_to_filter).returns([ file_one, file_two, file_three ])
|
127
|
+
end
|
128
|
+
|
129
|
+
subject { files_list.filtered_files }
|
130
|
+
|
131
|
+
context 'empty filter' do
|
132
|
+
before do
|
133
|
+
files_list.stubs(:spec_filter).returns([])
|
134
|
+
end
|
135
|
+
|
136
|
+
it { should == [ file_one, file_two, file_three, file_four ] }
|
137
|
+
end
|
138
|
+
|
139
|
+
context 'with filter' do
|
140
|
+
before do
|
141
|
+
files_list.stubs(:spec_filter).returns([ "#{spec_dir}/one", '**/tw*' ])
|
142
|
+
end
|
143
|
+
|
144
|
+
it { should == [ file_one, file_two, file_four ] }
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
describe '#add_files' do
|
149
|
+
let(:files_list) { described_class.new(:seed => 100) }
|
150
|
+
|
151
|
+
let(:dir) { 'tmp' }
|
152
|
+
|
153
|
+
before do
|
154
|
+
FileUtils.mkdir_p dir
|
155
|
+
|
156
|
+
10.times do |index|
|
157
|
+
File.open(File.join(dir, "file-#{index}.js"), 'wb')
|
158
|
+
end
|
159
|
+
|
160
|
+
File.open(File.join(dir, 'file.js.erb'), 'wb')
|
161
|
+
end
|
162
|
+
|
163
|
+
before do
|
164
|
+
files_list.send(:add_files, [ '*' ], 'spec_files', [ dir ])
|
165
|
+
end
|
166
|
+
|
167
|
+
it 'should load spec files in a random order' do
|
168
|
+
files_list.files.collect { |name| name[%r{\d+}] }.should == %w{6 7 1 0 5 3 4 8 2 9}
|
169
|
+
|
170
|
+
FileUtils.rm_rf dir
|
171
|
+
end
|
172
|
+
|
173
|
+
it 'should not load an excluded format' do
|
174
|
+
files_list.files.any? { |file| file['.erb'] }.should be_false
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
describe "#register_engine!" do
|
179
|
+
|
180
|
+
before(:each) do
|
181
|
+
Jasmine::Headless::FilesList.reset!
|
182
|
+
end
|
183
|
+
|
184
|
+
it "should register code added via configure blocks" do
|
185
|
+
template_class = mock()
|
186
|
+
described_class.register_engine ".foo", template_class
|
187
|
+
Sprockets.expects(:register_engine).with(".foo", template_class)
|
188
|
+
described_class.new
|
189
|
+
end
|
190
|
+
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|