jasmine-headless-webkit 0.8.4 → 0.9.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. data/Gemfile +16 -8
  2. data/Guardfile +6 -1
  3. data/Rakefile +2 -1
  4. data/config/cucumber.yml +2 -0
  5. data/ext/jasmine-webkit-specrunner/Page.cpp +2 -3
  6. data/ext/jasmine-webkit-specrunner/Page.h +1 -0
  7. data/ext/jasmine-webkit-specrunner/Runner.cpp +37 -16
  8. data/ext/jasmine-webkit-specrunner/Runner.h +15 -5
  9. data/ext/jasmine-webkit-specrunner/specrunner.cpp +17 -7
  10. data/features/bin/failure.feature +7 -0
  11. data/features/bin/files.feature +7 -0
  12. data/features/bin/filtered_run/both_runs.feature +18 -0
  13. data/features/bin/filtered_run/no_full_run.feature +14 -0
  14. data/features/bin/help.feature +7 -0
  15. data/features/bin/quiet_messages.feature +8 -0
  16. data/features/bin/runner_out.feature +8 -0
  17. data/features/bin/spec_files_with_same_basename.feature +7 -0
  18. data/features/bin/success.feature +20 -0
  19. data/features/bin/success_with_js_error.feature +5 -0
  20. data/features/bin/tries_to_leave_page.feature +7 -0
  21. data/features/bin/try_to_click_a_button.feature +7 -0
  22. data/features/bin/two_files_from_src_files.feature +11 -0
  23. data/features/bin/with_coffeescript_error.feature +7 -0
  24. data/features/bin/with_console_log.feature +7 -0
  25. data/features/bin/with_server.feature +7 -0
  26. data/features/bin/with_window_prompt.feature +7 -0
  27. data/features/reporters.feature +24 -0
  28. data/features/runner.feature +34 -0
  29. data/features/steps/given/i_have_test_suite.rb +2 -0
  30. data/features/steps/given/no_existing_file.rb +4 -0
  31. data/features/steps/given/options/i_have_defaults.rb +4 -0
  32. data/features/steps/given/options/i_have_reporters.rb +10 -0
  33. data/features/steps/given/options/i_have_runner_options.rb +3 -0
  34. data/features/steps/then/bin/exit_status_should_be.rb +3 -0
  35. data/features/steps/then/bin/file_should_contain_runner.rb +4 -0
  36. data/features/steps/then/bin/following_files_loaded_in_order.rb +10 -0
  37. data/features/steps/then/bin/i_should_get_help_output.rb +4 -0
  38. data/features/steps/then/bin/output_should_include.rb +3 -0
  39. data/features/steps/then/bin/output_should_not_include.rb +4 -0
  40. data/features/steps/then/reporting/report_does_not_exist.rb +4 -0
  41. data/features/steps/then/reporting/report_should_exist.rb +3 -0
  42. data/features/steps/then/reporting/report_should_have.rb +7 -0
  43. data/features/steps/then/reporting/report_should_have_seed.rb +4 -0
  44. data/features/steps/then/runner/it_should_have_exit_status.rb +3 -0
  45. data/features/steps/then/runner/it_should_include_report_file.rb +4 -0
  46. data/features/steps/then/runner/it_should_not_include_report_file.rb +3 -0
  47. data/features/steps/then/templates/it_should_use_reporter.rb +6 -0
  48. data/features/steps/when/i_delete_file.rb +3 -0
  49. data/features/steps/when/i_get_runner.rb +4 -0
  50. data/features/steps/when/i_get_template_writer.rb +4 -0
  51. data/features/steps/when/i_run_executable.rb +4 -0
  52. data/features/steps/when/i_run_runner.rb +4 -0
  53. data/features/support/env.rb +7 -0
  54. data/lib/jasmine/headless/file_checker.rb +7 -3
  55. data/lib/jasmine/headless/files_list.rb +46 -19
  56. data/lib/jasmine/headless/options.rb +113 -5
  57. data/lib/jasmine/headless/report.rb +6 -1
  58. data/lib/jasmine/headless/report_message/console.rb +2 -4
  59. data/lib/jasmine/headless/report_message/seed.rb +14 -0
  60. data/lib/jasmine/headless/report_message/spec.rb +3 -5
  61. data/lib/jasmine/headless/report_message.rb +1 -0
  62. data/lib/jasmine/headless/runner.rb +169 -28
  63. data/lib/jasmine/headless/task.rb +0 -14
  64. data/lib/jasmine/headless/template_writer.rb +28 -4
  65. data/lib/jasmine/headless/unique_asset_list.rb +1 -1
  66. data/lib/jasmine/headless/version.rb +1 -1
  67. data/lib/jasmine/headless.rb +18 -0
  68. data/lib/jasmine-headless-webkit.rb +0 -4
  69. data/script/hooks/post-commit +4 -0
  70. data/script/hooks/pre-commit +2 -2
  71. data/script/initialize-environment +1 -1
  72. data/skel/template.html.erb +31 -2
  73. data/spec/jasmine/noisy/file.js.erb +0 -0
  74. data/spec/jasmine/noisy/noisy.yml +8 -0
  75. data/spec/jasmine/noisy/other_file.js +2 -0
  76. data/spec/jasmine/two_files_from_src_files/app/app-file.js +0 -0
  77. data/spec/jasmine/two_files_from_src_files/app/app.js +2 -0
  78. data/spec/jasmine/two_files_from_src_files/jasmine.yml +7 -0
  79. data/spec/jasmine/two_files_from_src_files/vendor/vendor-file.js +0 -0
  80. data/spec/jasmine/two_files_from_src_files/vendor/vendor.js +2 -0
  81. data/spec/jasmine/two_spec_files_same_basename/jasmine.yml +6 -0
  82. data/spec/jasmine/two_spec_files_same_basename/spec.coffee +4 -0
  83. data/spec/jasmine/two_spec_files_same_basename/spec.js +6 -0
  84. data/spec/jasmine/window_prompt/source.js +2 -0
  85. data/spec/jasmine/window_prompt/window_prompt.yml +4 -0
  86. data/spec/javascripts/headless_reporter_result_spec.coffee +22 -6
  87. data/spec/javascripts/helpers/spec_helper.coffee +2 -0
  88. data/spec/javascripts/{jasmine.HeadlessConsoleReporter_spec.coffee → jasmine-extensions_spec.coffee} +0 -35
  89. data/spec/javascripts/jasmine.HeadlessReporter.ConsoleBase_spec.coffee +35 -0
  90. data/spec/javascripts/jasmine.HeadlessReporter.Console_spec.coffee +3 -0
  91. data/spec/javascripts/jasmine.HeadlessReporter.Tap_spec.coffee +19 -0
  92. data/spec/javascripts/jasmine.HeadlessReporter_spec.coffee +27 -0
  93. data/spec/javascripts/support/jasmine.yml +6 -5
  94. data/spec/lib/jasmine/headless/file_checker_spec.rb +25 -9
  95. data/spec/lib/jasmine/headless/files_list_spec.rb +132 -158
  96. data/spec/lib/jasmine/headless/options_spec.rb +77 -0
  97. data/spec/lib/jasmine/headless/report_message/seed_spec.rb +18 -0
  98. data/spec/lib/jasmine/headless/report_spec.rb +16 -0
  99. data/spec/lib/jasmine/headless/runner_spec.rb +110 -33
  100. data/spec/lib/jasmine/headless/template_writer_spec.rb +31 -27
  101. data/spec/lib/jasmine/headless/unique_asset_list_spec.rb +3 -3
  102. data/spec/lib/jasmine/headless_spec.rb +36 -0
  103. data/spec/skel/template.html.erb_spec.rb +8 -0
  104. data/vendor/assets/coffeescripts/prolog.coffee +48 -21
  105. data/vendor/assets/javascripts/headless_reporter_result.js +3 -0
  106. data/vendor/assets/{coffeescripts → javascripts}/intense.coffee +0 -0
  107. data/vendor/assets/{coffeescripts → javascripts}/jasmine-extensions.coffee +4 -10
  108. data/vendor/assets/javascripts/jasmine.HeadlessReporter.Console.coffee +8 -0
  109. data/vendor/assets/javascripts/jasmine.HeadlessReporter.ConsoleBase.coffee +92 -0
  110. data/vendor/assets/javascripts/jasmine.HeadlessReporter.File.coffee +24 -0
  111. data/vendor/assets/javascripts/jasmine.HeadlessReporter.Tap.coffee +28 -0
  112. data/vendor/assets/javascripts/jasmine.HeadlessReporter.Verbose.coffee +64 -0
  113. data/vendor/assets/javascripts/jasmine.HeadlessReporter.coffee +58 -0
  114. data/vendor/assets/javascripts/prolog.js +44 -27
  115. metadata +157 -31
  116. data/ext/jasmine-webkit-specrunner/jasmine-webkit-specrunner.pro +0 -19
  117. data/lib/digest/jasmine_test.rb +0 -20
  118. data/spec/bin/jasmine-headless-webkit_spec.rb +0 -142
  119. data/vendor/assets/coffeescripts/jasmine.HeadlessConsoleReporter.coffee +0 -118
  120. data/vendor/assets/javascripts/intense.js +0 -44
  121. data/vendor/assets/javascripts/jasmine-extensions.js +0 -129
  122. data/vendor/assets/javascripts/jasmine.HeadlessConsoleReporter.js +0 -136
data/Gemfile CHANGED
@@ -6,18 +6,26 @@ gemspec
6
6
  gem 'rspec'
7
7
  gem 'fakefs', :require => nil
8
8
  gem 'guard'
9
+
9
10
  gem 'guard-rspec'
10
11
  gem 'guard-shell'
11
12
  gem 'guard-coffeescript'
12
- gem 'growl'
13
- gem 'rake', '0.8.7'
14
- gem 'mocha', '0.9.12'
15
- gem 'guard-jasmine-headless-webkit', :git => 'git://github.com/johnbintz/guard-jasmine-headless-webkit.git'
16
- gem 'facter'
13
+ gem 'guard-cucumber'
14
+
15
+ require 'rbconfig'
16
+ case RbConfig::CONFIG['host_os']
17
+ when /darwin/
18
+ gem 'rb-fsevent'
19
+ when /linux/
20
+ gem 'libnotify'
21
+ end
17
22
 
18
- gem 'jquery-rails'
23
+ gem 'mocha'
24
+
25
+ gem 'cucumber'
26
+
27
+ gem 'jquery-rails', '~> 1.0.0'
19
28
  gem 'ejs'
20
29
 
21
- gem 'simplecov'
22
- #gem 'perftools.rb'
30
+ gem 'guard-jasmine-headless-webkit', :git => 'git://github.com/johnbintz/guard-jasmine-headless-webkit.git'
23
31
 
data/Guardfile CHANGED
@@ -22,13 +22,18 @@ guard 'rspec', :version => 2, :all_on_start => false do
22
22
  watch('spec/spec_helper.rb') { "spec" }
23
23
  end
24
24
 
25
+ guard 'cucumber', :cli => '-r features --format pretty' do
26
+ watch(%r{^features/.+\.feature$})
27
+ watch(%r{^features/support/.+$}) { 'features' }
28
+ watch(%r{^features/steps/(.+)_steps\.rb$}) { 'features' }
29
+ end
30
+
25
31
  guard 'jasmine-headless-webkit', :all_on_start => false do
26
32
  watch(%r{^spec/javascripts/.+_spec\.coffee})
27
33
  watch(%r{^jasmine/(.+)\.coffee$}) { |m| "spec/javascripts/#{m[1]}_spec.coffee" }
28
34
  end
29
35
 
30
36
  def compile
31
- #system %{cd ext/jasmine-webkit-specrunner && ruby test.rb && ruby extconf.rb}
32
37
  system %{cd ext/jasmine-webkit-specrunner && ruby extconf.rb}
33
38
  end
34
39
 
data/Rakefile CHANGED
@@ -14,7 +14,7 @@ require 'jasmine/headless/task'
14
14
 
15
15
  Jasmine::Headless::Task.new
16
16
 
17
- PLATFORMS = %w{1.8.7 1.9.2 ree 1.9.3-rc1}
17
+ PLATFORMS = %w{1.8.7 1.9.2 ree 1.9.3}
18
18
 
19
19
  def rvm_bundle(command = '')
20
20
  Bundler.with_clean_env do
@@ -30,6 +30,7 @@ namespace :spec do
30
30
  task :platforms do
31
31
  rvm_bundle
32
32
  rvm_bundle "exec rspec spec"
33
+ rvm_bundle "exec cucumber"
33
34
  raise SpecError.new if $?.exitstatus != 0
34
35
  end
35
36
  end
@@ -0,0 +1,2 @@
1
+ default: -r features
2
+
@@ -11,6 +11,5 @@ void Page::javaScriptConsoleMessage(const QString & message, int lineNumber, con
11
11
  }
12
12
 
13
13
  void Page::javaScriptAlert(QWebFrame *, const QString &) {}
14
- bool Page::javaScriptConfirm(QWebFrame *, const QString &) {
15
- return false;
16
- }
14
+ bool Page::javaScriptConfirm(QWebFrame *, const QString &) { return false; }
15
+ bool Page::javaScriptPrompt(QWebFrame *, const QString &, const QString &, QString *) { return false; }
@@ -12,6 +12,7 @@ class Page: public QWebPage {
12
12
  void javaScriptConsoleMessage(const QString & message, int lineNumber, const QString & sourceID);
13
13
  void javaScriptAlert(QWebFrame *, const QString &);
14
14
  bool javaScriptConfirm(QWebFrame *, const QString &);
15
+ bool javaScriptPrompt(QWebFrame *, const QString &, const QString &, QString *);
15
16
  signals:
16
17
  void handleError(const QString & message, int lineNumber, const QString & sourceID);
17
18
  };
@@ -18,6 +18,7 @@ Runner::Runner() : QObject()
18
18
  , usedConsole(false)
19
19
  , isFinished(false)
20
20
  , useColors(false)
21
+ , quiet(false)
21
22
  {
22
23
  page.settings()->enablePersistentStorage();
23
24
  ticker.setInterval(TIMER_TICK);
@@ -62,17 +63,17 @@ void Runner::handleError(const QString &message, int lineNumber, const QString &
62
63
 
63
64
  void Runner::loadSpec()
64
65
  {
65
- if (reportFileName.isEmpty()) {
66
- outputFile = 0;
67
- ts = 0;
68
- } else {
69
- outputFile = new QFile(reportFileName);
70
- outputFile->open(QIODevice::WriteOnly);
66
+ QVectorIterator<QString> iterator(reportFiles);
71
67
 
72
- ts = new QTextStream(outputFile);
68
+ while (iterator.hasNext()) {
69
+ QFile *outputFile = new QFile(iterator.next());
70
+ outputFile->open(QIODevice::WriteOnly);
71
+ outputFiles.enqueue(outputFile);
73
72
  }
74
73
 
75
- page.mainFrame()->load(runnerFiles.dequeue());
74
+ QString runnerFile = runnerFiles.dequeue();
75
+
76
+ page.mainFrame()->load(runnerFile);
76
77
  ticker.start();
77
78
  }
78
79
 
@@ -104,8 +105,8 @@ void Runner::hasSpecFailure() {
104
105
  _hasSpecFailure = true;
105
106
  }
106
107
 
107
- void Runner::reportFile(const QString &file) {
108
- reportFileName = file;
108
+ void Runner::setReportFiles(QStack<QString> &files) {
109
+ reportFiles = files;
109
110
  }
110
111
 
111
112
  void Runner::timerPause() {
@@ -120,6 +121,22 @@ void Runner::ping() {
120
121
  runs = 0;
121
122
  }
122
123
 
124
+ void Runner::setSeed(QString s) {
125
+ seed = s;
126
+ }
127
+
128
+ void Runner::setQuiet(bool q) {
129
+ quiet = q;
130
+ }
131
+
132
+ QString Runner::getSeed() {
133
+ return seed;
134
+ }
135
+
136
+ bool Runner::isQuiet() {
137
+ return quiet;
138
+ }
139
+
123
140
  void Runner::print(const QString &fh, const QString &content) {
124
141
  if (fh == "stdout") {
125
142
  std::cout << qPrintable(content);
@@ -131,14 +148,18 @@ void Runner::print(const QString &fh, const QString &content) {
131
148
  std::cerr.flush();
132
149
  }
133
150
 
134
- if (fh == "report" && outputFile) {
135
- *ts << qPrintable(content);
136
- ts->flush();
151
+ if (fh.contains("report")) {
152
+ int index = (int)fh.split(":").last().toUInt();
153
+
154
+ QTextStream ts(outputFiles.at(index));
155
+ ts << qPrintable(content);
156
+ ts.flush();
137
157
  }
138
158
  }
139
159
 
140
160
  void Runner::finishSuite() {
141
161
  isFinished = true;
162
+ runs = 0;
142
163
  }
143
164
 
144
165
  void Runner::timerEvent() {
@@ -147,9 +168,9 @@ void Runner::timerEvent() {
147
168
  if (hasErrors && runs > 2)
148
169
  QApplication::instance()->exit(1);
149
170
 
150
- if (isFinished) {
151
- if (outputFile) {
152
- outputFile->close();
171
+ if (isFinished && runs > 2) {
172
+ while (!outputFiles.isEmpty()) {
173
+ outputFiles.dequeue()->close();
153
174
  }
154
175
 
155
176
  int exitCode = 0;
@@ -7,7 +7,9 @@
7
7
  #include <QTextStream>
8
8
  #include <iostream>
9
9
  #include <fstream>
10
+ #include <sstream>
10
11
  #include <QQueue>
12
+ #include <QApplication>
11
13
 
12
14
  #include "Page.h"
13
15
 
@@ -20,7 +22,10 @@ class Runner: public QObject {
20
22
 
21
23
  Runner();
22
24
  void setColors(bool colors);
23
- void reportFile(const QString &file);
25
+ void setReportFiles(QStack<QString> &files);
26
+ void setSeed(QString s);
27
+ void setQuiet(bool q);
28
+
24
29
  void addFile(const QString &spec);
25
30
  void go();
26
31
 
@@ -30,6 +35,10 @@ class Runner: public QObject {
30
35
  void hasUsedConsole();
31
36
  void hasError();
32
37
  void hasSpecFailure();
38
+
39
+ bool isQuiet();
40
+ QString getSeed();
41
+
33
42
  void print(const QString &fh, const QString &content);
34
43
  void finishSuite();
35
44
  void ping();
@@ -49,15 +58,16 @@ class Runner: public QObject {
49
58
  bool usedConsole;
50
59
  bool isFinished;
51
60
  bool useColors;
61
+ bool quiet;
52
62
 
53
- QQueue<QString> runnerFiles;
63
+ QString seed;
54
64
 
55
- QString reportFileName;
65
+ QQueue<QString> runnerFiles;
66
+ QStack<QString> reportFiles;
56
67
 
57
68
  void loadSpec();
58
69
 
59
- QFile *outputFile;
60
- QTextStream *ts;
70
+ QQueue<QFile *> outputFiles;
61
71
  };
62
72
 
63
73
  #endif
@@ -29,34 +29,44 @@
29
29
 
30
30
  int main(int argc, char** argv)
31
31
  {
32
- char *reporter = NULL;
33
- char showColors = false;
32
+ bool showColors = false;
33
+ bool isQuiet = false;
34
+ QString seed;
35
+ QStack<QString> reporterFiles;
34
36
 
35
37
  int c, index;
36
38
 
37
- while ((c = getopt(argc, argv, "cr:")) != -1) {
39
+ while ((c = getopt(argc, argv, "cr:s:q")) != -1) {
38
40
  switch(c) {
39
41
  case 'c':
40
42
  showColors = true;
41
43
  break;
44
+ case 'q':
45
+ isQuiet = true;
46
+ break;
42
47
  case 'r':
43
- reporter = optarg;
48
+ reporterFiles.push(QString(optarg));
49
+ break;
50
+ case 's':
51
+ seed = QString(optarg);
44
52
  break;
45
53
  }
46
54
  }
47
55
 
48
56
  if (optind == argc) {
49
57
  std::cerr << "Run Jasmine's SpecRunner headlessly" << std::endl << std::endl;
50
- std::cerr << " specrunner [-c] [-r <report file>] specrunner.html ..." << std::endl;
58
+ std::cerr << " specrunner [-c] [-s seed] [-r report file ...] specrunner.html ..." << std::endl;
51
59
  return 1;
52
60
  }
53
61
 
54
62
  QApplication app(argc, argv);
55
63
  app.setApplicationName("jasmine-headless-webkit");
56
64
  Runner runner;
57
- runner.setColors(showColors);
58
65
 
59
- runner.reportFile(reporter);
66
+ runner.setColors(showColors);
67
+ runner.setQuiet(isQuiet);
68
+ runner.setReportFiles(reporterFiles);
69
+ runner.setSeed(seed);
60
70
 
61
71
  for (index = optind; index < argc; index++) {
62
72
  runner.addFile(QString::fromLocal8Bit(argv[index]));
@@ -0,0 +1,7 @@
1
+ Feature: Bin - Failure
2
+ Scenario: Run a failing test
3
+ Given there is no existing "spec/report.txt" file
4
+ When I run `bin/jasmine-headless-webkit -j spec/jasmine/failure/failure.yml -f File:spec/report.txt`
5
+ Then the exit status should be 1
6
+ And the report file "spec/report.txt" should have 1 total, 1 failure, no console usage
7
+
@@ -0,0 +1,7 @@
1
+ Feature: Bin - Files
2
+ Scenario: List the files a test suite will use
3
+ Given I have a test suite
4
+ When I run `bin/jasmine-headless-webkit -j spec/jasmine/success/success.yml -l`
5
+ Then the exit status should be 0
6
+ And the output should include "spec/jasmine/success/success.js"
7
+ And the output should include "spec/jasmine/success/success_spec.js"
@@ -0,0 +1,18 @@
1
+ Feature: Bin - Filtered Run - Both Runs
2
+ Background:
3
+ Given there is no existing "spec/report.txt" file
4
+
5
+ Scenario: Run one and fail
6
+ When I run `bin/jasmine-headless-webkit -j spec/jasmine/filtered_failure/filtered_failure.yml -f File:spec/report.txt ./spec/jasmine/filtered_failure/failure_spec.js`
7
+ Then the exit status should be 1
8
+ And the report file "spec/report.txt" should have 1 total, 1 failure, no console usage
9
+
10
+ Scenario: Run both and succeed
11
+ When I run `bin/jasmine-headless-webkit -j spec/jasmine/filtered_success/filtered_success.yml -f File:spec/report.txt ./spec/jasmine/filtered_success/success_one_spec.js`
12
+ Then the exit status should be 0
13
+ And the report file "spec/report.txt" should have 2 total, 0 failures, no console usage
14
+
15
+ Scenario: Run both with console.log
16
+ When I run `bin/jasmine-headless-webkit -j spec/jasmine/filtered_success_with_console/filtered_success.yml -f File:spec/report.txt ./spec/jasmine/filtered_success_with_console/success_one_spec.js`
17
+ Then the exit status should be 2
18
+ And the report file "spec/report.txt" should have 2 total, 0 failures, yes console usage
@@ -0,0 +1,14 @@
1
+ Feature: Bin - No Full Run
2
+ Background:
3
+ Given there is no existing "spec/report.txt" file
4
+
5
+ Scenario: Only run the filtered run
6
+ When I run `bin/jasmine-headless-webkit -j spec/jasmine/filtered_success/filtered_success.yml -f File:spec/report.txt --no-full-run ./spec/jasmine/filtered_success/success_one_spec.js`
7
+ Then the exit status should be 0
8
+ And the report file "spec/report.txt" should have 1 total, 0 failure, no console usage
9
+
10
+ Scenario: Use a file outside of the normal test run
11
+ When I run `bin/jasmine-headless-webkit -j spec/jasmine/filtered_success/filtered_success.yml -f File:spec/report.txt ./spec/jasmine/filtered_success/success_other_file.js`
12
+ Then the exit status should be 0
13
+ And the report file "spec/report.txt" should have 1 total, 0 failure, no console usage
14
+
@@ -0,0 +1,7 @@
1
+ Feature: Bin - Help
2
+ Scenario: Display the Help
3
+ Given I have a test suite
4
+ When I run `bin/jasmine-headless-webkit -h`
5
+ Then I should get help output
6
+ And the exit status should be 0
7
+
@@ -0,0 +1,8 @@
1
+ Feature: Bin - Quiet Messages
2
+ Scenario: Run a test that would cause a lot of messages to be displayed and silence them all
3
+ Given I have a test suite
4
+ When I run `bin/jasmine-headless-webkit -q -j spec/jasmine/noisy/noisy.yml`
5
+ Then the exit status should be 0
6
+ And the output should not include "[Skipping File]"
7
+ And the output should not include "You should mock"
8
+
@@ -0,0 +1,8 @@
1
+ Feature: Bin - Runner Out
2
+ Scenario: Write out the runner to a specified file
3
+ Given I have a test suite
4
+ When I run `bin/jasmine-headless-webkit -j spec/jasmine/success/success.yml --runner-out spec/runner.html`
5
+ Then the exit status should be 0
6
+ And the file "spec/runner.html" should contain a JHW runner
7
+ When I delete the file "spec/runner.html"
8
+
@@ -0,0 +1,7 @@
1
+ Feature: Bin - Two spec files with same basename
2
+ Scenario: Run both files
3
+ Given there is no existing "spec/report.txt" file
4
+ When I run `bin/jasmine-headless-webkit -j spec/jasmine/two_spec_files_same_basename/jasmine.yml -f File:spec/report.txt`
5
+ Then the exit status should be 0
6
+ And the report file "spec/report.txt" should have 2 total, 0 failures, no console usage
7
+
@@ -0,0 +1,20 @@
1
+ Feature: Bin - Success
2
+ Scenario: Run a successful test with long format definition
3
+ Given there is no existing "spec/report.txt" file
4
+ When I run `bin/jasmine-headless-webkit --seed 1234 -j spec/jasmine/success/success.yml --format File --out spec/report.txt`
5
+ Then the exit status should be 0
6
+ And the report file "spec/report.txt" should have 1 total, 0 failures, no console usage
7
+ And the report file "spec/report.txt" should have seed 1234
8
+
9
+ Scenario: Run a successful test with legacy file reporting
10
+ Given there is no existing "spec/report.txt" file
11
+ When I run `bin/jasmine-headless-webkit -j spec/jasmine/success/success.yml --report spec/report.txt`
12
+ Then the exit status should be 0
13
+ And the report file "spec/report.txt" should have 1 total, 0 failures, no console usage
14
+
15
+ Scenario: Run a successful test with shortened format definition
16
+ Given there is no existing "spec/report.txt" file
17
+ When I run `bin/jasmine-headless-webkit -j spec/jasmine/success/success.yml -f File:spec/report.txt`
18
+ Then the exit status should be 0
19
+ And the report file "spec/report.txt" should have 1 total, 0 failures, no console usage
20
+
@@ -0,0 +1,5 @@
1
+ Feature: Bin - Success with JS Error
2
+ Scenario: Succeed
3
+ Given there is no existing "spec/report.txt" file
4
+ When I run `bin/jasmine-headless-webkit -j spec/jasmine/success_with_error/success_with_error.yml -f File:spec/report.txt`
5
+ Then the exit status should be 1
@@ -0,0 +1,7 @@
1
+ Feature: Bin - Try to Leave Page
2
+ Scenario: Fail on trying to leave the page
3
+ Given there is no existing "spec/report.txt" file
4
+ When I run `bin/jasmine-headless-webkit -j spec/jasmine/leave_page/leave_page.yml -f File:spec/report.txt`
5
+ Then the exit status should be 1
6
+ And the report file "spec/report.txt" should exist
7
+
@@ -0,0 +1,7 @@
1
+ Feature: Bin - Try to Click A Button
2
+ Scenario: Don't leave page when clicking a button
3
+ Given there is no existing "spec/report.txt" file
4
+ When I run `bin/jasmine-headless-webkit -j spec/jasmine/click_button/click_button.yml -f File:spec/report.txt`
5
+ Then the exit status should be 0
6
+ And the report file "spec/report.txt" should have 0 total, 0 failures, no console usage
7
+
@@ -0,0 +1,11 @@
1
+ Feature: Two files from source files
2
+ Scenario: Files are ordered directly
3
+ Given I have a test suite
4
+ When I run `bin/jasmine-headless-webkit -j spec/jasmine/two_files_from_src_files/jasmine.yml -l`
5
+ Then the exit status should be 0
6
+ And the following files should be loaded in order:
7
+ | vendor/vendor-file.js |
8
+ | vendor/vendor.js |
9
+ | app/app-file.js |
10
+ | app/app.js |
11
+
@@ -0,0 +1,7 @@
1
+ Feature: Bin - With CoffeeScript error
2
+ Scenario: Fail on CoffeeScript error
3
+ Given there is no existing "spec/report.txt" file
4
+ When I run `bin/jasmine-headless-webkit -j spec/jasmine/coffeescript_error/coffeescript_error.yml -f File:spec/report.txt`
5
+ Then the exit status should be 1
6
+ And the report file "spec/report.txt" should not exist
7
+
@@ -0,0 +1,7 @@
1
+ Feature: Use console.log
2
+ Scenario: Run a successful test that uses console.log
3
+ Given there is no existing "spec/report.txt" file
4
+ When I run `bin/jasmine-headless-webkit -j spec/jasmine/console_log/console_log.yml -f File:spec/report.txt`
5
+ Then the exit status should be 2
6
+ And the report file "spec/report.txt" should have 1 total, 0 failures, yes console usage
7
+
@@ -0,0 +1,7 @@
1
+ Feature: Bin - With Server
2
+ Scenario: Run using an HTTP server
3
+ Given there is no existing "spec/report.txt" file
4
+ When I run `bin/jasmine-headless-webkit --use-server -j spec/jasmine/success/success.yml -f File:spec/report.txt`
5
+ Then the exit status should be 0
6
+ And the report file "spec/report.txt" should have 1 total, 0 failures, no console usage
7
+
@@ -0,0 +1,7 @@
1
+ Feature: Bin - With window.prompt()
2
+ Scenario: Alert the user that window.prompt() needs to be stubbed
3
+ Given I have a test suite
4
+ When I run `bin/jasmine-headless-webkit -j spec/jasmine/window_prompt/window_prompt.yml`
5
+ Then the exit status should be 0
6
+ And the output should include "You should mock window.prompt"
7
+
@@ -0,0 +1,24 @@
1
+ Feature: Reporters
2
+ In order to allow for multiple types of output
3
+ I should be able to
4
+ Manage reporters and decide which ones to use
5
+
6
+ Scenario: Use default reporters
7
+ Given I have the default runner options
8
+ When I get a runner
9
+ And I get a template writer
10
+ Then the template should use the "Console" reporter to "stdout"
11
+ And the command to run the runner should not include a report file
12
+
13
+ Scenario: Use a file reporter
14
+ Given I have the default runner options
15
+ And I have the following reporters:
16
+ | Name | File |
17
+ | Console | |
18
+ | File | file |
19
+ When I get a runner
20
+ And I get a template writer
21
+ Then the template should use the "Console" reporter to "stdout"
22
+ And the template should use the "File" reporter to "report:0"
23
+ And the command to run the runner should include the report file "file"
24
+
@@ -0,0 +1,34 @@
1
+ Feature: Using the Runner directly
2
+ Scenario: Succeed
3
+ Given I have the following runner options:
4
+ """
5
+ :jasmine_config: spec/jasmine/success/success.yml
6
+ :reporters:
7
+ - [ 'File', 'spec/report.txt' ]
8
+ """
9
+ When I get a runner
10
+ And I run the runner
11
+ Then the runner should have an exit status of 0
12
+ And the report file "spec/report.txt" should have 1 total, 0 failures, no console usage
13
+
14
+ Scenario: JavaScript Error
15
+ Given I have the following runner options:
16
+ """
17
+ :jasmine_config: spec/jasmine/success_with_error/success_with_error.yml
18
+ """
19
+ When I get a runner
20
+ And I run the runner
21
+ Then the runner should have an exit status of 1
22
+
23
+ Scenario: Failure
24
+ Given I have the following runner options:
25
+ """
26
+ :jasmine_config: spec/jasmine/failure/failure.yml
27
+ :reporters:
28
+ - [ 'File', 'spec/report.txt' ]
29
+ """
30
+ When I get a runner
31
+ And I run the runner
32
+ Then the runner should have an exit status of 1
33
+ And the report file "spec/report.txt" should have 1 total, 1 failure, no console usage
34
+
@@ -0,0 +1,2 @@
1
+ Given /^I have a test suite$/ do
2
+ end
@@ -0,0 +1,4 @@
1
+ Given /^there is no existing "([^"]*)" file$/ do |file|
2
+ FileUtils.rm_rf file
3
+ end
4
+
@@ -0,0 +1,4 @@
1
+ Given /^I have the default runner options$/ do
2
+ @options = Jasmine::Headless::Options.new
3
+ end
4
+
@@ -0,0 +1,10 @@
1
+ Given /^I have the following reporters:$/ do |table|
2
+ @options[:reporters] = []
3
+
4
+ table.hashes.each do |hash|
5
+ reporter = [ hash['Name'] ]
6
+ reporter << hash['File'] if !hash['File'].empty?
7
+
8
+ @options[:reporters] << reporter
9
+ end
10
+ end
@@ -0,0 +1,3 @@
1
+ Given /^I have the following runner options:$/ do |string|
2
+ @options = YAML.load(string)
3
+ end
@@ -0,0 +1,3 @@
1
+ Then /^the exit status should be (\d+)$/ do |exitstatus|
2
+ $?.exitstatus.should == exitstatus.to_i
3
+ end
@@ -0,0 +1,4 @@
1
+ Then /^the file "([^"]*)" should contain a JHW runner$/ do |file|
2
+ File.read(file).should include('jasmine.HeadlessReporter')
3
+ end
4
+
@@ -0,0 +1,10 @@
1
+ Then /^the following files should be loaded in order:$/ do |table|
2
+ files = table.raw.flatten
3
+
4
+ @output.lines.collect(&:strip).each do |line|
5
+ files.shift if line[files.first]
6
+ end
7
+
8
+ files.should be_empty
9
+ end
10
+
@@ -0,0 +1,4 @@
1
+ Then /^I should get help output$/ do
2
+ @output.should include("Usage:")
3
+ end
4
+
@@ -0,0 +1,3 @@
1
+ Then /^the output should include "([^"]*)"$/ do |string|
2
+ @output.should include(string)
3
+ end
@@ -0,0 +1,4 @@
1
+ Then /^the output should not include "([^"]*)"$/ do |string|
2
+ @output.should_not include(string)
3
+ end
4
+
@@ -0,0 +1,4 @@
1
+ Then /^the report file "([^"]*)" should not exist$/ do |file|
2
+ File.file?(file).should be_false
3
+ end
4
+
@@ -0,0 +1,3 @@
1
+ Then /^the report file "([^"]*)" should exist$/ do |file|
2
+ File.file?(file).should be_true
3
+ end
@@ -0,0 +1,7 @@
1
+ Then /^the report file "(.*)" should have (\d+) total, (\d+) failures?, (no|yes) console usage$/ do |file, total, failures, console_usage|
2
+ report = Jasmine::Headless::Report.load(file)
3
+
4
+ report.total.should == total.to_i
5
+ report.failed.should == failures.to_i
6
+ report.has_used_console?.should == (console_usage == 'yes')
7
+ end
@@ -0,0 +1,4 @@
1
+ Then /^the report file "([^"]*)" should have seed (\d+)$/ do |file, seed|
2
+ report = Jasmine::Headless::Report.load(file)
3
+ report.seed.should == seed.to_i
4
+ end