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.
Files changed (216) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +19 -0
  3. data/.rspec +1 -0
  4. data/CHANGELOG.md +89 -0
  5. data/Gemfile +30 -0
  6. data/Guardfile +41 -0
  7. data/README.md +44 -0
  8. data/Rakefile +65 -0
  9. data/bin/jasmine-headless-webkit +11 -0
  10. data/config/cucumber.yml +2 -0
  11. data/ext/jasmine-webkit-specrunner/Info.plist +22 -0
  12. data/ext/jasmine-webkit-specrunner/Makefile.dummy +5 -0
  13. data/ext/jasmine-webkit-specrunner/Page.cpp +15 -0
  14. data/ext/jasmine-webkit-specrunner/Page.h +20 -0
  15. data/ext/jasmine-webkit-specrunner/Runner.cpp +208 -0
  16. data/ext/jasmine-webkit-specrunner/Runner.h +73 -0
  17. data/ext/jasmine-webkit-specrunner/common.pri +8 -0
  18. data/ext/jasmine-webkit-specrunner/extconf.rb +10 -0
  19. data/ext/jasmine-webkit-specrunner/specrunner.cpp +79 -0
  20. data/ext/jasmine-webkit-specrunner/specrunner.pro +5 -0
  21. data/features/bin/failure.feature +7 -0
  22. data/features/bin/files.feature +7 -0
  23. data/features/bin/filtered_run/both_runs.feature +18 -0
  24. data/features/bin/filtered_run/no_full_run.feature +14 -0
  25. data/features/bin/help.feature +7 -0
  26. data/features/bin/quiet_messages.feature +8 -0
  27. data/features/bin/runner_out.feature +8 -0
  28. data/features/bin/spec_files_with_same_basename.feature +7 -0
  29. data/features/bin/success.feature +20 -0
  30. data/features/bin/success_with_js_error.feature +5 -0
  31. data/features/bin/tries_to_leave_page.feature +7 -0
  32. data/features/bin/try_to_click_a_button.feature +7 -0
  33. data/features/bin/two_files_from_src_files.feature +11 -0
  34. data/features/bin/with_coffeescript_error.feature +7 -0
  35. data/features/bin/with_console_log.feature +7 -0
  36. data/features/bin/with_server.feature +7 -0
  37. data/features/bin/with_window_prompt.feature +7 -0
  38. data/features/reporters.feature +24 -0
  39. data/features/runner.feature +34 -0
  40. data/features/steps/given/i_have_test_suite.rb +2 -0
  41. data/features/steps/given/no_existing_file.rb +4 -0
  42. data/features/steps/given/options/i_have_defaults.rb +4 -0
  43. data/features/steps/given/options/i_have_reporters.rb +10 -0
  44. data/features/steps/given/options/i_have_runner_options.rb +3 -0
  45. data/features/steps/then/bin/exit_status_should_be.rb +3 -0
  46. data/features/steps/then/bin/file_should_contain_runner.rb +4 -0
  47. data/features/steps/then/bin/following_files_loaded_in_order.rb +10 -0
  48. data/features/steps/then/bin/i_should_get_help_output.rb +4 -0
  49. data/features/steps/then/bin/output_should_include.rb +3 -0
  50. data/features/steps/then/bin/output_should_not_include.rb +4 -0
  51. data/features/steps/then/reporting/report_does_not_exist.rb +4 -0
  52. data/features/steps/then/reporting/report_should_exist.rb +3 -0
  53. data/features/steps/then/reporting/report_should_have.rb +7 -0
  54. data/features/steps/then/reporting/report_should_have_seed.rb +4 -0
  55. data/features/steps/then/runner/it_should_have_exit_status.rb +3 -0
  56. data/features/steps/then/runner/it_should_include_report_file.rb +4 -0
  57. data/features/steps/then/runner/it_should_not_include_report_file.rb +3 -0
  58. data/features/steps/then/templates/it_should_use_reporter.rb +6 -0
  59. data/features/steps/when/i_delete_file.rb +3 -0
  60. data/features/steps/when/i_get_runner.rb +4 -0
  61. data/features/steps/when/i_get_template_writer.rb +4 -0
  62. data/features/steps/when/i_run_executable.rb +4 -0
  63. data/features/steps/when/i_run_runner.rb +4 -0
  64. data/features/support/env.rb +7 -0
  65. data/jasmine-headless-webkit-firstbanco.gemspec +30 -0
  66. data/lib/autotest/discover.rb +1 -0
  67. data/lib/autotest/jasmine.rb +7 -0
  68. data/lib/autotest/jasmine_mixin.rb +111 -0
  69. data/lib/autotest/jasmine_rspec2.rb +7 -0
  70. data/lib/jasmine-headless-webkit.rb +3 -0
  71. data/lib/jasmine/headless.rb +61 -0
  72. data/lib/jasmine/headless/cacheable_action.rb +85 -0
  73. data/lib/jasmine/headless/coffee_script_cache.rb +20 -0
  74. data/lib/jasmine/headless/coffee_template.rb +36 -0
  75. data/lib/jasmine/headless/command_line.rb +31 -0
  76. data/lib/jasmine/headless/css_template.rb +19 -0
  77. data/lib/jasmine/headless/errors.rb +16 -0
  78. data/lib/jasmine/headless/file_checker.rb +25 -0
  79. data/lib/jasmine/headless/files_list.rb +332 -0
  80. data/lib/jasmine/headless/js_template.rb +23 -0
  81. data/lib/jasmine/headless/jst_template.rb +15 -0
  82. data/lib/jasmine/headless/nil_template.rb +14 -0
  83. data/lib/jasmine/headless/options.rb +206 -0
  84. data/lib/jasmine/headless/railtie.rb +12 -0
  85. data/lib/jasmine/headless/report.rb +81 -0
  86. data/lib/jasmine/headless/report_message.rb +12 -0
  87. data/lib/jasmine/headless/report_message/console.rb +18 -0
  88. data/lib/jasmine/headless/report_message/error.rb +20 -0
  89. data/lib/jasmine/headless/report_message/fail.rb +5 -0
  90. data/lib/jasmine/headless/report_message/pass.rb +5 -0
  91. data/lib/jasmine/headless/report_message/seed.rb +14 -0
  92. data/lib/jasmine/headless/report_message/spec.rb +28 -0
  93. data/lib/jasmine/headless/report_message/total.rb +31 -0
  94. data/lib/jasmine/headless/runner.rb +264 -0
  95. data/lib/jasmine/headless/spec_file_analyzer.rb +44 -0
  96. data/lib/jasmine/headless/task.rb +39 -0
  97. data/lib/jasmine/headless/template_writer.rb +65 -0
  98. data/lib/jasmine/headless/unique_asset_list.rb +16 -0
  99. data/lib/jasmine/headless/version.rb +5 -0
  100. data/lib/qt/qmake.rb +155 -0
  101. data/script/gemfile +11 -0
  102. data/script/hooks/post-commit +4 -0
  103. data/script/hooks/pre-commit +15 -0
  104. data/script/initialize-environment +35 -0
  105. data/script/install-git-hooks +6 -0
  106. data/skel/template.html.erb +77 -0
  107. data/spec/files/UTF-8-test.txt +0 -0
  108. data/spec/integration/randomization_spec.rb +13 -0
  109. data/spec/integration/specify_runner_file_spec.rb +22 -0
  110. data/spec/integration/sprockets_spec.rb +23 -0
  111. data/spec/jasmine/click_button/click_button.js +5 -0
  112. data/spec/jasmine/click_button/click_button.yml +12 -0
  113. data/spec/jasmine/click_button/click_button_spec.js +11 -0
  114. data/spec/jasmine/coffeescript_error/coffeescript_error.yml +10 -0
  115. data/spec/jasmine/coffeescript_error/spec.coffee +2 -0
  116. data/spec/jasmine/coffeescript_error/src.coffee +2 -0
  117. data/spec/jasmine/console_log/console_log.js +1 -0
  118. data/spec/jasmine/console_log/console_log.yml +10 -0
  119. data/spec/jasmine/console_log/console_log_spec.js +7 -0
  120. data/spec/jasmine/failure/failure.js +1 -0
  121. data/spec/jasmine/failure/failure.yml +9 -0
  122. data/spec/jasmine/failure/failure_spec.js +6 -0
  123. data/spec/jasmine/filtered_failure/failure_spec.js +6 -0
  124. data/spec/jasmine/filtered_failure/filtered_failure.yml +10 -0
  125. data/spec/jasmine/filtered_failure/src.js +0 -0
  126. data/spec/jasmine/filtered_failure/success_spec.js +6 -0
  127. data/spec/jasmine/filtered_success/filtered_success.yml +10 -0
  128. data/spec/jasmine/filtered_success/src.js +0 -0
  129. data/spec/jasmine/filtered_success/success_one_spec.js +6 -0
  130. data/spec/jasmine/filtered_success/success_other_file.js +7 -0
  131. data/spec/jasmine/filtered_success/success_two_spec.js +6 -0
  132. data/spec/jasmine/filtered_success_with_console/filtered_success.yml +10 -0
  133. data/spec/jasmine/filtered_success_with_console/src.js +0 -0
  134. data/spec/jasmine/filtered_success_with_console/success_one_spec.js +7 -0
  135. data/spec/jasmine/filtered_success_with_console/success_two_spec.js +6 -0
  136. data/spec/jasmine/leave_page/leave_page.js +4 -0
  137. data/spec/jasmine/leave_page/leave_page.yml +9 -0
  138. data/spec/jasmine/leave_page/leave_page_spec.js +11 -0
  139. data/spec/jasmine/noisy/file.js.erb +0 -0
  140. data/spec/jasmine/noisy/noisy.yml +8 -0
  141. data/spec/jasmine/noisy/other_file.js +2 -0
  142. data/spec/jasmine/runner_out_in_jasmine_yml/jasmine.yml +11 -0
  143. data/spec/jasmine/runner_out_in_jasmine_yml/test.js +2 -0
  144. data/spec/jasmine/runner_out_in_jasmine_yml/test_spec.coffee +4 -0
  145. data/spec/jasmine/success/success.js +1 -0
  146. data/spec/jasmine/success/success.yml +9 -0
  147. data/spec/jasmine/success/success_spec.js +6 -0
  148. data/spec/jasmine/success_with_error/success_with_error.js +3 -0
  149. data/spec/jasmine/success_with_error/success_with_error.yml +9 -0
  150. data/spec/jasmine/success_with_error/success_with_error_spec.js +6 -0
  151. data/spec/jasmine/two_files_from_src_files/app/app-file.js +0 -0
  152. data/spec/jasmine/two_files_from_src_files/app/app.js +2 -0
  153. data/spec/jasmine/two_files_from_src_files/jasmine.yml +7 -0
  154. data/spec/jasmine/two_files_from_src_files/vendor/vendor-file.js +0 -0
  155. data/spec/jasmine/two_files_from_src_files/vendor/vendor.js +2 -0
  156. data/spec/jasmine/two_spec_files_same_basename/jasmine.yml +6 -0
  157. data/spec/jasmine/two_spec_files_same_basename/spec.coffee +4 -0
  158. data/spec/jasmine/two_spec_files_same_basename/spec.js +6 -0
  159. data/spec/jasmine/window_prompt/source.js +2 -0
  160. data/spec/jasmine/window_prompt/window_prompt.yml +4 -0
  161. data/spec/jasmine/with_sprockets_includes/assets/application.js.erb +2 -0
  162. data/spec/jasmine/with_sprockets_includes/assets/things/code.js +6 -0
  163. data/spec/jasmine/with_sprockets_includes/assets/things/jquery.string.js +0 -0
  164. data/spec/jasmine/with_sprockets_includes/assets/things/required.js +3 -0
  165. data/spec/jasmine/with_sprockets_includes/assets/things/subcode/more_code.js +2 -0
  166. data/spec/jasmine/with_sprockets_includes/assets/things/templates/that.jst.ejs +1 -0
  167. data/spec/jasmine/with_sprockets_includes/assets/things/templates/this.jst +2 -0
  168. data/spec/jasmine/with_sprockets_includes/spec/spec_helper.js +1 -0
  169. data/spec/jasmine/with_sprockets_includes/spec/things/code_spec.js +9 -0
  170. data/spec/jasmine/with_sprockets_includes/with_sprockets_includes.yml +12 -0
  171. data/spec/javascripts/console.log_spec.coffee +15 -0
  172. data/spec/javascripts/headless_reporter_result_spec.coffee +30 -0
  173. data/spec/javascripts/helpers/spec_helper.coffee +2 -0
  174. data/spec/javascripts/jasmine-extensions_spec.coffee +80 -0
  175. data/spec/javascripts/jasmine.HeadlessReporter.ConsoleBase_spec.coffee +35 -0
  176. data/spec/javascripts/jasmine.HeadlessReporter.Console_spec.coffee +3 -0
  177. data/spec/javascripts/jasmine.HeadlessReporter.Tap_spec.coffee +19 -0
  178. data/spec/javascripts/jasmine.HeadlessReporter_spec.coffee +27 -0
  179. data/spec/javascripts/support/jasmine.yml +9 -0
  180. data/spec/lib/jasmine/headless/cacheable_action_spec.rb +122 -0
  181. data/spec/lib/jasmine/headless/coffee_script_cache_spec.rb +21 -0
  182. data/spec/lib/jasmine/headless/coffee_template_spec.rb +55 -0
  183. data/spec/lib/jasmine/headless/css_template_spec.rb +25 -0
  184. data/spec/lib/jasmine/headless/file_checker_spec.rb +41 -0
  185. data/spec/lib/jasmine/headless/files_list_spec.rb +194 -0
  186. data/spec/lib/jasmine/headless/js_template_spec.rb +31 -0
  187. data/spec/lib/jasmine/headless/jst_template_spec.rb +21 -0
  188. data/spec/lib/jasmine/headless/nil_template_spec.rb +31 -0
  189. data/spec/lib/jasmine/headless/options_spec.rb +194 -0
  190. data/spec/lib/jasmine/headless/report_message/seed_spec.rb +18 -0
  191. data/spec/lib/jasmine/headless/report_message/spec_spec.rb +20 -0
  192. data/spec/lib/jasmine/headless/report_spec.rb +95 -0
  193. data/spec/lib/jasmine/headless/runner_spec.rb +247 -0
  194. data/spec/lib/jasmine/headless/spec_file_analyzer_spec.rb +68 -0
  195. data/spec/lib/jasmine/headless/task_spec.rb +92 -0
  196. data/spec/lib/jasmine/headless/template_writer_spec.rb +92 -0
  197. data/spec/lib/jasmine/headless/unique_asset_list_spec.rb +22 -0
  198. data/spec/lib/jasmine/headless_spec.rb +38 -0
  199. data/spec/lib/qt/qmake_spec.rb +142 -0
  200. data/spec/skel/template.html.erb_spec.rb +8 -0
  201. data/spec/spec_helper.rb +113 -0
  202. data/vendor/assets/coffeescripts/headless_reporter_result.coffee +49 -0
  203. data/vendor/assets/coffeescripts/prolog.coffee +100 -0
  204. data/vendor/assets/javascripts/beautify-html.js +463 -0
  205. data/vendor/assets/javascripts/headless_reporter_result.js +79 -0
  206. data/vendor/assets/javascripts/intense.coffee +28 -0
  207. data/vendor/assets/javascripts/jasmine-extensions.coffee +97 -0
  208. data/vendor/assets/javascripts/jasmine.HeadlessReporter.Console.coffee +8 -0
  209. data/vendor/assets/javascripts/jasmine.HeadlessReporter.ConsoleBase.coffee +92 -0
  210. data/vendor/assets/javascripts/jasmine.HeadlessReporter.File.coffee +24 -0
  211. data/vendor/assets/javascripts/jasmine.HeadlessReporter.Tap.coffee +28 -0
  212. data/vendor/assets/javascripts/jasmine.HeadlessReporter.Verbose.coffee +64 -0
  213. data/vendor/assets/javascripts/jasmine.HeadlessReporter.coffee +58 -0
  214. data/vendor/assets/javascripts/jsDump.js +209 -0
  215. data/vendor/assets/javascripts/prolog.js +108 -0
  216. metadata +347 -0
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ describe Jasmine::Headless::JSTemplate 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 == %{<script type="text/javascript" src="#{file}"></script>} }
24
+ end
25
+
26
+ context 'script as first thing' do
27
+ let(:data) { '<script type="text/javascript"' }
28
+
29
+ it { should == data }
30
+ end
31
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe Jasmine::Headless::JSTTemplate do
4
+ include FakeFS::SpecHelpers
5
+
6
+ let(:template) { described_class.new(file) }
7
+ let(:file) { 'file' }
8
+ let(:data) { 'data' }
9
+
10
+ let(:context) { stub(:logical_path => 'path') }
11
+
12
+ before do
13
+ File.open(file, 'wb') { |fh| fh.print data }
14
+ end
15
+
16
+ subject { template.render(context) }
17
+
18
+ it { should include(%{<script type="text/javascript">}) }
19
+ it { should include(data) }
20
+ end
21
+
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ describe Jasmine::Headless::NilTemplate do
4
+ include FakeFS::SpecHelpers
5
+
6
+ let(:template) { described_class.new(file) { data } }
7
+ let(:file) { 'file' }
8
+ let(: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 == '' }
24
+ end
25
+
26
+ context 'script as first thing' do
27
+ let(:data) { '' }
28
+
29
+ it { should == data }
30
+ end
31
+ end
@@ -0,0 +1,194 @@
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
+
47
+ context 'legacy reporter' do
48
+ let(:file) { 'file' }
49
+
50
+ before do
51
+ options.expects(:warn)
52
+ end
53
+
54
+ it 'should add a legacy reporter' do
55
+ options[:reporters] = []
56
+
57
+ options.process_option("--report", file)
58
+
59
+ options[:reporters].should == [ [ 'File', file ], [ 'Console' ] ]
60
+ end
61
+ end
62
+
63
+ context 'short reporter' do
64
+ let(:reporter) { 'reporter' }
65
+ let(:file) { 'file' }
66
+
67
+ it 'should add a reporter' do
68
+ options[:reporters] = []
69
+
70
+ options.process_option("--format", "#{reporter}:#{file}")
71
+
72
+ options[:reporters].should == [ [ reporter, file ] ]
73
+ end
74
+ end
75
+ end
76
+
77
+ describe '#read_defaults_files' do
78
+ include FakeFS::SpecHelpers
79
+
80
+ let(:global_test_data) { '--colors' }
81
+ let(:test_data) { '-j test' }
82
+
83
+ before do
84
+ FileUtils.mkdir_p File.split(Jasmine::Headless::Options::GLOBAL_DEFAULTS_FILE).first
85
+ FileUtils.mkdir_p File.split(Jasmine::Headless::Options::DEFAULTS_FILE).first
86
+
87
+ File.open(Jasmine::Headless::Options::GLOBAL_DEFAULTS_FILE, 'w') { |fh| fh.puts global_test_data }
88
+ File.open(Jasmine::Headless::Options::DEFAULTS_FILE, 'w') { |fh| fh.puts test_data }
89
+ end
90
+
91
+ it "should read the options" do
92
+ options[:colors].should be_true
93
+ options[:jasmine_config].should == 'test'
94
+ end
95
+ end
96
+
97
+ describe '.from_command_line' do
98
+ before do
99
+ @argv = ARGV.dup
100
+ end
101
+
102
+ let(:options) { described_class.from_command_line }
103
+
104
+ context 'no files specified' do
105
+ before do
106
+ ARGV.replace([])
107
+ end
108
+
109
+ it 'should have no files' do
110
+ options[:files].should == []
111
+ end
112
+ end
113
+
114
+ context 'files specified' do
115
+ before do
116
+ ARGV.replace([ "test" ])
117
+ end
118
+
119
+ it 'should have files' do
120
+ options[:files].should == [ "test" ]
121
+ end
122
+ end
123
+
124
+ context 'specify no seed' do
125
+ it 'should have a seed' do
126
+ options[:seed].should_not be_nil
127
+ end
128
+ end
129
+
130
+ context 'specify random order seed' do
131
+ let(:seed) { 12345 }
132
+
133
+ before do
134
+ ARGV.replace([ "--seed", seed ])
135
+ end
136
+
137
+ it 'should specify the seed' do
138
+ options[:seed].should == seed
139
+ end
140
+ end
141
+
142
+ let(:test_reporter) { 'TestReporter' }
143
+ let(:file) { 'file' }
144
+
145
+ context 'no reporters' do
146
+ it 'should have the default reporter' do
147
+ options[:reporters].should == [ [ 'Console' ] ]
148
+ end
149
+ end
150
+
151
+ context 'one reporter' do
152
+ context 'stdout' do
153
+ before do
154
+ ARGV.replace([ "--format", test_reporter ])
155
+ end
156
+
157
+ it 'should have the new reporter on stdout' do
158
+ options[:reporters].should == [ [ test_reporter ] ]
159
+
160
+ options.reporters.should == [ [ test_reporter, 'stdout' ] ]
161
+ end
162
+ end
163
+
164
+ context 'file' do
165
+ before do
166
+ ARGV.replace([ "--format", test_reporter, '--out', file ])
167
+ end
168
+
169
+ it 'should have the new reporter on stdout' do
170
+ options[:reporters].should == [ [ test_reporter, file ] ]
171
+
172
+ options.reporters.should == [ [ test_reporter, 'report:0', file ] ]
173
+ end
174
+ end
175
+ end
176
+
177
+ after do
178
+ ARGV.replace(@argv)
179
+ end
180
+ end
181
+
182
+ describe '#file_reporters' do
183
+ subject { options.file_reporters }
184
+
185
+ let(:stdout_reporter) { [ 'Console', 'stdout' ] }
186
+ let(:file_reporter) { [ 'File', 'report:0', 'file' ] }
187
+
188
+ before do
189
+ options.stubs(:reporters).returns([ stdout_reporter, file_reporter ])
190
+ end
191
+
192
+ it { should == [ file_reporter ] }
193
+ end
194
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe Jasmine::Headless::ReportMessage::Seed do
4
+ let(:seed) { described_class.new(seed_value) }
5
+ let(:seed_value) { '1' }
6
+
7
+ subject { seed }
8
+
9
+ its(:seed) { should == seed_value.to_i }
10
+
11
+ describe '.new_from_parts' do
12
+ subject { described_class.new_from_parts(parts) }
13
+
14
+ let(:parts) { [ seed_value ] }
15
+
16
+ its(:seed) { should == seed_value.to_i }
17
+ end
18
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe Jasmine::Headless::ReportMessage::Spec do
4
+ subject { spec }
5
+
6
+ context 'with filename' do
7
+ let(:filename) { 'file.js' }
8
+ let(:spec) { described_class.new("Test", "#{filename}:23") }
9
+
10
+ its(:filename) { should == filename }
11
+ end
12
+
13
+ context 'without filename' do
14
+ let(:filename) { 'file.js' }
15
+ let(:spec) { described_class.new("Test", "") }
16
+
17
+ its(:filename) { should be_nil }
18
+ end
19
+ end
20
+
@@ -0,0 +1,95 @@
1
+ require 'spec_helper'
2
+
3
+ describe Jasmine::Headless::Report do
4
+ include FakeFS::SpecHelpers
5
+
6
+ let(:report) { described_class.new(file) }
7
+ let(:file) { 'file' }
8
+
9
+ let(:file) { 'report.txt' }
10
+
11
+ describe '.load' do
12
+ let(:report) { described_class.load(file) }
13
+
14
+ context 'no file' do
15
+ it 'should raise an exception' do
16
+ expect { report }.to raise_error(Errno::ENOENT)
17
+ end
18
+ end
19
+
20
+ context 'file' do
21
+ before do
22
+ File.open(file, 'wb') { |fh| fh.puts <<-REPORT }
23
+ PASS||Statement||One||file.js:23
24
+ FAIL||Statement||Two||file2.js:23
25
+ FAIL||Statement||Three||file2.js:23
26
+ CONSOLE||Yes
27
+ ERROR||Uh oh||file3.js:23
28
+ TOTAL||1||2||3||T
29
+ REPORT
30
+ end
31
+
32
+ it 'should read the report file' do
33
+ report.length.should == 6
34
+
35
+ report[0].should == Jasmine::Headless::ReportMessage::Pass.new("Statement One", "file.js:23")
36
+ report[1].should == Jasmine::Headless::ReportMessage::Fail.new("Statement Two", "file2.js:23")
37
+ report[2].should == Jasmine::Headless::ReportMessage::Fail.new("Statement Three", "file2.js:23")
38
+ report[3].should == Jasmine::Headless::ReportMessage::Console.new("Yes")
39
+ report[4].should == Jasmine::Headless::ReportMessage::Error.new("Uh oh", "file3.js:23")
40
+ report[5].should == Jasmine::Headless::ReportMessage::Total.new(1, 2, 3, true)
41
+
42
+ report.total.should == 1
43
+ report.failed.should == 2
44
+ report.should have_used_console
45
+ report.time.should == 3.0
46
+
47
+ report.should be_valid
48
+
49
+ report.should have_failed_on("Statement Two")
50
+ report.failed_files.should == [ 'file2.js' ]
51
+ end
52
+ end
53
+
54
+ context 'nil filed file' do
55
+ before do
56
+ File.open(file, 'wb') { |fh| fh.puts <<-REPORT }
57
+ FAIL||Statement||Two||
58
+ TOTAL||1||2||3||T
59
+ REPORT
60
+ end
61
+
62
+ it 'should read the report file' do
63
+ report.failed_files.should == []
64
+ end
65
+ end
66
+
67
+ context 'multi line console' do
68
+ before do
69
+ File.open(file, 'wb') { |fh| fh.puts <<-REPORT }
70
+ CONSOLE||test
71
+ test2
72
+ TOTAL||1||2||3||T
73
+ REPORT
74
+ end
75
+
76
+ it 'should read the report file' do
77
+ report[0].should == Jasmine::Headless::ReportMessage::Console.new("test\ntest2")
78
+ end
79
+ end
80
+ end
81
+
82
+ describe '#seed' do
83
+ subject { report.seed }
84
+
85
+ let(:seed) { stub(:seed => seed_number) }
86
+ let(:seed_number) { 1 }
87
+
88
+ before do
89
+ report.stubs(:report).returns([ seed ])
90
+ end
91
+
92
+ it { should == seed_number }
93
+ end
94
+ end
95
+
@@ -0,0 +1,247 @@
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
+
17
+ it 'should have a template writer' do
18
+ runner.template_writer.should be_a_kind_of(Jasmine::Headless::TemplateWriter)
19
+ runner.template_writer.runner.should == runner
20
+ end
21
+ end
22
+
23
+ describe '#load_config' do
24
+ include FakeFS::SpecHelpers
25
+
26
+ let(:runner_filename) { 'ext/jasmine-webkit-specrunner/jasmine-webkit-specrunner' }
27
+
28
+ before do
29
+ FileUtils.mkdir_p File.split(runner_filename).first
30
+
31
+ File.open(runner_filename, 'w')
32
+ end
33
+
34
+ let(:config_filename) { 'test.yml' }
35
+ let(:opts) { { :jasmine_config => config_filename } }
36
+
37
+ context 'file exists' do
38
+ before do
39
+ File.open(config_filename, 'w') { |fh| fh.print YAML.dump('test' => 'hello', 'erb' => '<%= "erb" %>') }
40
+ end
41
+
42
+ it 'should load the jasmine config' do
43
+ runner.jasmine_config['test'].should == 'hello'
44
+ runner.jasmine_config['spec_dir'].should == 'spec/javascripts'
45
+ end
46
+
47
+ it 'should execute ERB in the config file' do
48
+ runner.jasmine_config['erb'].should == 'erb'
49
+ end
50
+ end
51
+
52
+ context 'file does not exist' do
53
+ it 'should raise an exception' do
54
+ expect { runner.jasmine_config }.to raise_error(Jasmine::Headless::JasmineConfigNotFound, /#{config_filename}/)
55
+ end
56
+ end
57
+ end
58
+
59
+ describe '#jasmine_command' do
60
+ subject { runner.jasmine_command(target) }
61
+
62
+ let(:target) { 'target' }
63
+
64
+ let(:options) { {} }
65
+ let(:reporters) { [] }
66
+
67
+ before do
68
+ runner.stubs(:options).returns(options)
69
+ options.stubs(:file_reporters).returns(reporters)
70
+ end
71
+
72
+ def self.it_should_have_basics
73
+ it { should include(target) }
74
+ end
75
+
76
+ context 'colors' do
77
+ before do
78
+ options[:colors] = true
79
+ end
80
+
81
+ it_should_have_basics
82
+ it { should include('-c') }
83
+ end
84
+
85
+ context 'reporters' do
86
+ let(:reporter) { [ 'Reporter', 'identifier', file ] }
87
+ let(:reporters) { [ reporter ] }
88
+
89
+ let(:file) { 'file' }
90
+
91
+ it_should_have_basics
92
+ it { should include("-r #{file}") }
93
+ end
94
+
95
+ context 'quiet' do
96
+ before do
97
+ options[:quiet] = true
98
+ end
99
+
100
+ it_should_have_basics
101
+ it { should include("-q") }
102
+ end
103
+ end
104
+
105
+ describe '#runner_filename' do
106
+ let(:runner_filename) { runner.runner_filename }
107
+ let(:yaml_output) { 'yaml output' }
108
+
109
+ context 'not in options' do
110
+ let(:opts) { { :runner_output_filename => false } }
111
+
112
+ context 'not in yaml file' do
113
+ before do
114
+ runner.stubs(:jasmine_config).returns('runner_output' => '')
115
+ end
116
+
117
+ it 'should reverse the remove_html_file option' do
118
+ runner_filename.should == false
119
+ end
120
+ end
121
+
122
+ context 'in yaml file' do
123
+ before do
124
+ runner.stubs(:jasmine_config).returns('runner_output' => yaml_output)
125
+ end
126
+
127
+ it 'should use the yaml file definition' do
128
+ runner_filename.should == yaml_output
129
+ end
130
+ end
131
+ end
132
+
133
+ context 'in options' do
134
+ let(:filename) { 'filename.html' }
135
+ let(:opts) { { :runner_output_filename => filename } }
136
+
137
+ context 'not in yaml file' do
138
+ before do
139
+ runner.stubs(:jasmine_config).returns('runner_output' => '')
140
+ end
141
+
142
+ it 'should reverse the remove_html_file option' do
143
+ runner.runner_filename.should == filename
144
+ end
145
+ end
146
+
147
+ context 'in yaml file' do
148
+ before do
149
+ runner.stubs(:jasmine_config).returns('runner_output' => yaml_output)
150
+ end
151
+
152
+ it 'shoulduse the command line filename' do
153
+ runner.runner_filename.should == filename
154
+ end
155
+ end
156
+ end
157
+ end
158
+
159
+ describe '#jasmine_config' do
160
+ let(:opts) { {} }
161
+
162
+ before do
163
+ runner.stubs(:jasmine_config_data).returns('spec_files' => nil)
164
+ end
165
+
166
+ it 'should not merge in things with nil values' do
167
+ runner.jasmine_config['spec_files'].should == described_class::JASMINE_DEFAULTS['spec_files']
168
+ end
169
+ end
170
+
171
+ describe '#files_list' do
172
+ subject { runner.files_list }
173
+
174
+ let(:options) { { :files => only, :seed => seed } }
175
+
176
+ let(:only) { 'only' }
177
+ let(:seed) { 12345 }
178
+ let(:jasmine_config) { 'jasmine config' }
179
+ let(:reporters) { [] }
180
+
181
+ before do
182
+ runner.stubs(:options).returns(options)
183
+ runner.stubs(:jasmine_config).returns(jasmine_config)
184
+
185
+ options.stubs(:reporters).returns(reporters)
186
+ end
187
+
188
+ it { should be_a_kind_of(Jasmine::Headless::FilesList) }
189
+
190
+ it 'should have settings' do
191
+ subject.options[:config].should == jasmine_config
192
+ subject.options[:only].should == only
193
+ subject.options[:seed].should == seed
194
+ subject.options[:reporters].should == reporters
195
+ end
196
+ end
197
+
198
+ describe '.server_port' do
199
+ before do
200
+ described_class.instance_variable_set(:@server_port, nil)
201
+ end
202
+
203
+ context 'port in use' do
204
+ require 'socket'
205
+
206
+ before do
207
+ described_class.stubs(:select_server_port).returns(5000, 5001)
208
+ end
209
+
210
+ it 'should try another port' do
211
+ server = TCPServer.new(described_class.server_interface, 5000)
212
+
213
+ described_class.server_port.should == 5001
214
+ end
215
+ end
216
+ end
217
+
218
+ describe '#absolute_run_targets' do
219
+ let(:opts) { {} }
220
+
221
+ subject { runner.absolute_run_targets(targets) }
222
+
223
+ let(:targets) { [ target ] }
224
+ let(:target) { 'target' }
225
+
226
+ before do
227
+ runner.stubs(:options).returns(:use_server => use_server)
228
+ end
229
+
230
+ context 'server' do
231
+ let(:use_server) { true }
232
+ let(:server_spec_path) { 'server spec path' }
233
+
234
+ before do
235
+ described_class.stubs(:server_spec_path).returns(server_spec_path)
236
+ end
237
+
238
+ it { should == [ server_spec_path + target ] }
239
+ end
240
+
241
+ context 'no server' do
242
+ let(:use_server) { false }
243
+
244
+ it { should == [ 'file://' + File.expand_path(target) ] }
245
+ end
246
+ end
247
+ end