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,68 @@
1
+ require 'spec_helper'
2
+
3
+ describe Jasmine::Headless::SpecFileAnalyzer do
4
+
5
+ let(:file) { 'file' }
6
+ let(:analyzer) { described_class.new(file) }
7
+
8
+ describe '#action' do
9
+ let(:line_numbers) do
10
+ analyzer.action
11
+ end
12
+
13
+ context 'fake files' do
14
+ include FakeFS::SpecHelpers
15
+
16
+ before do
17
+ File.open(file, 'wb') { |fh| fh.print file_data }
18
+ end
19
+
20
+ context 'coffeescript' do
21
+ let(:file_data) do
22
+ <<-SPEC
23
+ describe 'test', ->
24
+ context 'yes', ->
25
+ it 'should do something', ->
26
+ "yes"
27
+ SPEC
28
+ end
29
+
30
+ it 'should get the line numbers' do
31
+ line_numbers['test'].should == [ 1 ]
32
+ line_numbers['yes'].should == [ 2 ]
33
+ line_numbers['should do something'].should == [ 3 ]
34
+ end
35
+ end
36
+
37
+ context 'javascript' do
38
+ let(:file_data) do
39
+ <<-SPEC
40
+ describe('test', function() {
41
+ context('yes', function() {
42
+ it('should do something', function() {
43
+
44
+ });
45
+ });
46
+ });
47
+ SPEC
48
+ end
49
+
50
+ it 'should get the line numbers' do
51
+ line_numbers['test'].should == [ 1 ]
52
+ line_numbers['yes'].should == [ 2 ]
53
+ line_numbers['should do something'].should == [ 3 ]
54
+ end
55
+ end
56
+ end
57
+
58
+ context 'utf 8' do
59
+ let(:analyzer) { described_class.new('spec/files/UTF-8-test.txt') }
60
+ let(:file_data) { '' }
61
+
62
+ it 'should not explode' do
63
+ line_numbers
64
+ end
65
+ end
66
+ end
67
+ end
68
+
@@ -0,0 +1,92 @@
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
+ context 'without version' do
25
+ before do
26
+ module Rails
27
+ def self.version
28
+ return "0"
29
+ end
30
+ end
31
+ end
32
+
33
+ it 'should be OK if rails is defined' do
34
+ Jasmine::Headless::Task.new('jasmine:headless')
35
+ end
36
+ end
37
+
38
+ context 'with version' do
39
+ before do
40
+ module Rails
41
+ def self.version
42
+ return "0"
43
+ end
44
+ end
45
+ end
46
+
47
+ it 'should be OK if rails is defined' do
48
+ Jasmine::Headless::Task.new('jasmine:headless')
49
+ end
50
+ end
51
+ end
52
+ end
53
+
54
+ describe 'jasmine:headless integration test' do
55
+ context 'with successful test' do
56
+ let(:test) do
57
+ described_class.new do |t|
58
+ t.jasmine_config = "spec/jasmine/success/success.yml"
59
+ end
60
+ end
61
+
62
+ it 'should do nothing on success' do
63
+ expect { test.send(:run_rake_task) }.to_not raise_error
64
+ end
65
+ end
66
+
67
+ context 'with failing test' do
68
+ let(:test) do
69
+ described_class.new do |t|
70
+ t.jasmine_config = "spec/jasmine/failure/failure.yml"
71
+ end
72
+ end
73
+
74
+ it 'should raise an exception on failure' do
75
+ expect { test.send(:run_rake_task) }.to raise_error(Jasmine::Headless::TestFailure)
76
+ end
77
+ end
78
+
79
+ context 'with console.log using test' do
80
+ let(:test) do
81
+ described_class.new do |t|
82
+ t.jasmine_config = "spec/jasmine/console_log/console_log.yml"
83
+ end
84
+ end
85
+
86
+ it 'should raise an exception on console.log usage' do
87
+ expect { test.send(:run_rake_task) }.to raise_error(Jasmine::Headless::ConsoleLogUsage)
88
+ end
89
+ end
90
+ end
91
+ end
92
+
@@ -0,0 +1,92 @@
1
+ require 'spec_helper'
2
+ require 'fakefs/spec_helpers'
3
+
4
+ describe Jasmine::Headless::TemplateWriter do
5
+ let(:runner) { stub }
6
+ let(:template_writer) { described_class.new(runner) }
7
+
8
+ describe '#all_tests_filename' do
9
+ let(:all_tests_filename) { template_writer.all_tests_filename }
10
+
11
+ context 'runner does not care about filename' do
12
+ before do
13
+ runner.stubs(:runner_filename).returns(false)
14
+ end
15
+
16
+ it 'should use a specrunner.html file' do
17
+ all_tests_filename.should_not include('tmp')
18
+ all_tests_filename.should include('jhw')
19
+ all_tests_filename.should include('.html')
20
+ end
21
+ end
22
+
23
+ context 'runner cares about filename' do
24
+ let(:filename) { 'filename.html' }
25
+
26
+ before do
27
+ runner.stubs(:runner_filename).returns(filename)
28
+ end
29
+
30
+ it 'should use a specrunner.html file' do
31
+ all_tests_filename.should == filename
32
+ end
33
+ end
34
+ end
35
+
36
+ describe '#filtered_tests_filename' do
37
+ before do
38
+ template_writer.stubs(:all_tests_filename).returns("test.html")
39
+ end
40
+
41
+ it 'should filter the filename for all tests' do
42
+ template_writer.filtered_tests_filename.should == 'test.filter.html'
43
+ end
44
+ end
45
+
46
+ describe '#render' do
47
+ subject { template_writer.render }
48
+
49
+ let(:all_files) { 'all files' }
50
+ let(:template) { 'template' }
51
+
52
+ before do
53
+ template_writer.stubs(:all_files).returns(all_files)
54
+
55
+ template_writer.expects(:template_for).with(all_files).returns(template)
56
+ end
57
+
58
+ it { should == template }
59
+ end
60
+
61
+ describe '#all_files' do
62
+ subject { template_writer.all_files }
63
+
64
+ let(:files_list) { stub }
65
+ let(:files) { 'files' }
66
+
67
+ before do
68
+ template_writer.stubs(:files_list).returns(files_list)
69
+
70
+ files_list.stubs(:files_to_html).returns(files)
71
+ end
72
+
73
+ it { should == files }
74
+ end
75
+
76
+ describe '#jhw_reporters' do
77
+ subject { template_writer.jhw_reporters }
78
+
79
+ let(:reporter) { 'reporter' }
80
+ let(:output) { 'output' }
81
+
82
+ before do
83
+ template_writer.stubs(:reporters).returns([
84
+ [ reporter, output ]
85
+ ])
86
+ end
87
+
88
+ it { should include(reporter) }
89
+ it { should include(output) }
90
+ end
91
+ end
92
+
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe Jasmine::Headless::UniqueAssetList do
4
+ let(:list) { described_class.new }
5
+
6
+ let(:first) { stub(:logical_path => 'one', :pathname => 'one') }
7
+ let(:second) { stub(:logical_path => 'two', :pathname => 'two') }
8
+ let(:third) { stub(:logical_path => 'two', :pathname => 'two') }
9
+
10
+ it 'should raise an exception on a non-asset' do
11
+ expect { list << "whatever" }.to raise_error(StandardError)
12
+ end
13
+
14
+ it 'should not add the same asset with the same logical path twice' do
15
+ list << first
16
+ list << second
17
+ list << third
18
+
19
+ list.to_a.should == [ first, second ]
20
+ end
21
+ end
22
+
@@ -0,0 +1,38 @@
1
+ require 'spec_helper'
2
+
3
+ describe Jasmine::Headless do
4
+ describe '.warn' do
5
+ let(:output) { StringIO.new }
6
+
7
+ before do
8
+ described_class.stubs(:output).returns(output)
9
+ end
10
+
11
+ context 'warnings enabled' do
12
+ before do
13
+ described_class.stubs(:show_warnings?).returns(true)
14
+ end
15
+
16
+ it 'should work' do
17
+ described_class.warn("warning")
18
+
19
+ output.rewind
20
+ output.read.should == "warning\n"
21
+ end
22
+ end
23
+
24
+ context 'warnings disabled' do
25
+ before do
26
+ described_class.stubs(:show_warnings?).returns(false)
27
+ end
28
+
29
+ it 'should work' do
30
+ described_class.warn("warning")
31
+
32
+ output.rewind
33
+ output.read.should == ""
34
+ end
35
+ end
36
+ end
37
+ end
38
+
@@ -0,0 +1,142 @@
1
+ require 'spec_helper'
2
+ require 'qt/qmake'
3
+ require 'rbconfig'
4
+ require 'rubygems/version'
5
+
6
+ describe Qt::Qmake do
7
+ describe '.make_installed?' do
8
+ subject { described_class }
9
+
10
+ before do
11
+ Qt::Qmake.stubs(:make_path).returns(path)
12
+ end
13
+
14
+ context 'not installed' do
15
+ let(:path) { nil }
16
+
17
+ it { should_not be_make_installed }
18
+ end
19
+
20
+ context 'installed' do
21
+ let(:path) { '/here/there/make' }
22
+
23
+ it { should be_make_installed }
24
+ end
25
+ end
26
+
27
+ describe '.installed?' do
28
+ subject { described_class }
29
+
30
+ before do
31
+ Qt::Qmake.stubs(:path).returns(path)
32
+ end
33
+
34
+ context 'not installed' do
35
+ let(:path) { nil }
36
+
37
+ it { should_not be_installed }
38
+ end
39
+
40
+ context 'installed' do
41
+ let(:path) { '/here/there/qmake' }
42
+
43
+ it { should be_installed }
44
+ end
45
+ end
46
+
47
+ describe '.command' do
48
+ subject { described_class.command }
49
+
50
+ before do
51
+ Qt::Qmake.stubs(:platform).returns(platform)
52
+ Qt::Qmake.stubs(:path).returns("qmake")
53
+ end
54
+
55
+ context 'linux' do
56
+ let(:platform) { :linux }
57
+
58
+ it { should =~ /^qmake/ }
59
+ it { should =~ /-spec linux-g\+\+$/ }
60
+ end
61
+
62
+ context 'mac os x' do
63
+ let(:platform) { :mac_os_x }
64
+
65
+ it { should =~ /^qmake/ }
66
+ it { should =~ /-spec macx-g\+\+$/ }
67
+ end
68
+ end
69
+
70
+ describe '.best_qmake' do
71
+ before do
72
+ Qt::Qmake.stubs(:get_exe_path).with('qmake-qt4').returns(path_one)
73
+ Qt::Qmake.stubs(:get_exe_path).with('qmake').returns(path_two)
74
+
75
+ Qt::Qmake.stubs(:qt_version_of).with(path_one).returns(Gem::Version.create(version_one))
76
+ Qt::Qmake.stubs(:qt_version_of).with(path_two).returns(Gem::Version.create(version_two))
77
+ end
78
+
79
+ subject { described_class.best_qmake }
80
+
81
+ let(:path_one) { nil }
82
+ let(:path_two) { nil }
83
+ let(:version_one) { nil }
84
+ let(:version_two) { nil }
85
+
86
+ context 'nothing found' do
87
+ it { should be_nil }
88
+ end
89
+
90
+ context 'one found' do
91
+ let(:path_one) { 'one' }
92
+
93
+ context 'not good' do
94
+ let(:version_one) { '4.5' }
95
+
96
+ it { should be_nil }
97
+ end
98
+
99
+ context 'good' do
100
+ let(:version_one) { '4.7' }
101
+
102
+ it { should == path_one }
103
+ end
104
+ end
105
+
106
+ context 'two found' do
107
+ let(:path_one) { 'one' }
108
+ let(:path_two) { 'two' }
109
+
110
+ context 'neither good' do
111
+ let(:version_one) { '4.5' }
112
+ let(:version_two) { '4.5' }
113
+
114
+ it { should be_nil }
115
+ end
116
+
117
+ context 'one good' do
118
+ let(:version_one) { '4.7' }
119
+ let(:version_two) { '4.5' }
120
+
121
+ it { should == path_one }
122
+ end
123
+
124
+ context 'both good' do
125
+ context 'one better' do
126
+ let(:version_one) { '4.7' }
127
+ let(:version_two) { '4.8' }
128
+
129
+ it { should == path_two }
130
+ end
131
+
132
+ context 'both same' do
133
+ let(:version_one) { '4.7' }
134
+ let(:version_two) { '4.7' }
135
+
136
+ it { should == path_one }
137
+ end
138
+ end
139
+ end
140
+ end
141
+ end
142
+