kosmas58-cucumber 0.3.92 → 0.3.93.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. data/History.txt +25 -0
  2. data/Manifest.txt +7 -0
  3. data/cucumber.yml +2 -2
  4. data/examples/i18n/pt/features/adicao.feature +4 -4
  5. data/features/html_formatter/a.html +4 -4
  6. data/features/profiles.feature +99 -0
  7. data/features/step_definitions/cucumber_steps.rb +20 -0
  8. data/features/work_in_progress.feature +1 -0
  9. data/gem_tasks/contributors.rake +4 -0
  10. data/lib/cucumber/ast/table.rb +2 -2
  11. data/lib/cucumber/cli/configuration.rb +25 -281
  12. data/lib/cucumber/cli/drb_client.rb +3 -1
  13. data/lib/cucumber/cli/main.rb +5 -7
  14. data/lib/cucumber/cli/options.rb +365 -0
  15. data/lib/cucumber/cli/profile_loader.rb +65 -0
  16. data/lib/cucumber/formatter/console.rb +1 -1
  17. data/lib/cucumber/formatter/html.rb +1 -0
  18. data/lib/cucumber/parser/feature.rb +67 -67
  19. data/lib/cucumber/parser/feature.tt +28 -1
  20. data/lib/cucumber/parser/i18n/language.rb +4 -0
  21. data/lib/cucumber/parser/table.rb +25 -25
  22. data/lib/cucumber/step_mother.rb +3 -1
  23. data/lib/cucumber/version.rb +2 -2
  24. data/lib/cucumber/webrat/table_locator.rb +1 -1
  25. data/rails_generators/cucumber/cucumber_generator.rb +6 -2
  26. data/rails_generators/cucumber/templates/cucumber +3 -2
  27. data/rails_generators/cucumber/templates/cucumber_environment.rb +7 -4
  28. data/rails_generators/cucumber/templates/de/webrat_steps.rb +9 -4
  29. data/rails_generators/cucumber/templates/en/webrat_steps.rb +4 -0
  30. data/spec/cucumber/cli/configuration_spec.rb +132 -102
  31. data/spec/cucumber/cli/main_spec.rb +14 -4
  32. data/spec/cucumber/cli/options_spec.rb +306 -0
  33. data/spec/cucumber/cli/profile_loader_spec.rb +10 -0
  34. data/spec/cucumber/formatter/html_spec.rb +18 -0
  35. data/spec/cucumber/parser/table_parser_spec.rb +1 -1
  36. data/spec/spec.opts +3 -1
  37. metadata +9 -2
data/History.txt CHANGED
@@ -1,5 +1,26 @@
1
1
  == (In Git)
2
2
 
3
+ === New features
4
+ * Added examples/python that uses rubypython. (Aslak Hellesøy)
5
+ * Document builtin formatters with --help. (#406 Aslak Hellesøy)
6
+
7
+ == 0.3.93 2009-08-03
8
+
9
+ Highlights in this release: Improved profile handling (cucumber.yml) and a fix for cucumber hanging.
10
+
11
+ === New features
12
+ * script/generate cucumber --spork now sets up a spork gem dependency in the cucumber.rb environment. (Aslak Hellesøy)
13
+ * Feature files defined on the command line override any that are present in profiles. (#344 Ben Mabey)
14
+ * Default (STDOUT) formatter defined in profile can be overridden from the command line. (#344 Ben Mabey)
15
+ * Displays which profile, if any, is being used. (Ben Mabey)
16
+ * click_link_within(parent, link) webrat step (Joakim Kolsjö)
17
+
18
+ === Bugfixes
19
+ * script/cucumber correctly loads the gem's binary if the plugin isn't installed.
20
+ * Cucumber hangs waiting for Ctrl+C if an Error is raised (#374 Aslak Hellesøy)
21
+
22
+ == 0.3.92 2009-07-29
23
+
3
24
  This release has some minor improvements to the new Table.diff! functionality. For example,
4
25
  if you're using Webrat and you want to compare a feature table with a HTML table containing
5
26
  links in one of the columns, you can do:
@@ -16,6 +37,9 @@ links in one of the columns, you can do:
16
37
  * Upgrade Sinatra example to work with rack-test 0.3.0 and aslakhellesoy-webrat 0.4.4.1 (Aslak Hellesøy)
17
38
  * require 'cucumber/webrat/table_locator' added to Spork environment for Rails (Anders Furseth)
18
39
 
40
+ === Changed Features
41
+ * The 'default' profile is now ALWAYS used unless you specify another profile or use the -P or --no-profile flag. (#344 Ben Mabey)
42
+
19
43
  == 0.3.91 2009-07-27
20
44
 
21
45
  === New Features
@@ -23,6 +47,7 @@ links in one of the columns, you can do:
23
47
  * Run can be stopped programmatically by setting $cucumber_interrupted = true, for example in an After block. (Aslak Hellesøy)
24
48
  * Table support for cuke4duke
25
49
 
50
+
26
51
  == 0.3.90 2009-07-22
27
52
 
28
53
  The Hot summer release
data/Manifest.txt CHANGED
@@ -262,6 +262,7 @@ features/html_formatter/a.html
262
262
  features/junit_formatter.feature
263
263
  features/language_from_header.feature
264
264
  features/multiline_names.feature
265
+ features/profiles.feature
265
266
  features/rake_task.feature
266
267
  features/report_called_undefined_steps.feature
267
268
  features/snippet.feature
@@ -273,6 +274,7 @@ features/table_diffing.feature
273
274
  features/unicode_table.feature
274
275
  features/usage.feature
275
276
  features/work_in_progress.feature
277
+ gem_tasks/contributors.rake
276
278
  gem_tasks/deployment.rake
277
279
  gem_tasks/environment.rake
278
280
  gem_tasks/features.rake
@@ -311,6 +313,8 @@ lib/cucumber/cli/configuration.rb
311
313
  lib/cucumber/cli/drb_client.rb
312
314
  lib/cucumber/cli/language_help_formatter.rb
313
315
  lib/cucumber/cli/main.rb
316
+ lib/cucumber/cli/options.rb
317
+ lib/cucumber/cli/profile_loader.rb
314
318
  lib/cucumber/core_ext/exception.rb
315
319
  lib/cucumber/core_ext/instance_exec.rb
316
320
  lib/cucumber/core_ext/proc.rb
@@ -384,11 +388,14 @@ spec/cucumber/broadcaster_spec.rb
384
388
  spec/cucumber/cli/configuration_spec.rb
385
389
  spec/cucumber/cli/drb_client_spec.rb
386
390
  spec/cucumber/cli/main_spec.rb
391
+ spec/cucumber/cli/options_spec.rb
392
+ spec/cucumber/cli/profile_loader_spec.rb
387
393
  spec/cucumber/core_ext/proc_spec.rb
388
394
  spec/cucumber/core_ext/string_spec.rb
389
395
  spec/cucumber/formatter/ansicolor_spec.rb
390
396
  spec/cucumber/formatter/color_io_spec.rb
391
397
  spec/cucumber/formatter/duration_spec.rb
398
+ spec/cucumber/formatter/html_spec.rb
392
399
  spec/cucumber/formatter/progress_spec.rb
393
400
  spec/cucumber/parser/feature_parser_spec.rb
394
401
  spec/cucumber/parser/table_parser_spec.rb
data/cucumber.yml CHANGED
@@ -1,4 +1,4 @@
1
- default: --format progress features --tags ~@proposed,~@in_progress
1
+ default: --format progress --tags ~@proposed,~@in-progress features
2
2
  html: --format progress features html --out=doc/features_report.html --tags ~@proposed,~@in_progress
3
3
  performance: --format profile features --tags ~@proposed,~@in_progress
4
- wip: --tags @in_progress --wip features
4
+ wip: --tags @in-progress --wip features
@@ -5,7 +5,7 @@ Funcionalidade: Adição
5
5
  Eu quero saber como somar dois números
6
6
 
7
7
  Cenário: Adicionar dois números
8
- Dado que eu digitei 50 na calculadora
9
- E que eu digitei 70 na calculadora
10
- Quando eu aperto o botão de soma
11
- Então o resultado na calculadora deve ser 120
8
+ Dado que eu digitei 50 na calculadora
9
+ E que eu digitei 70 na calculadora
10
+ Quando eu aperto o botão de soma
11
+ Então o resultado na calculadora deve ser 120
@@ -139,7 +139,7 @@ features/background/failing_background.feature:5:in `Given failing without a tab
139
139
  features/background/failing_background_after_success.feature:5:in `And '10' global cukes'</pre></li><li class="step skipped" id="features_background_failing_background_after_success_feature_11"><div><span class="keyword">Then</span> <span class="step val">I should have '<span class="param">10</span>' global cukes</span></div></li></ol></div></div><div class="feature"><h2><span class="val">Feature: Passing background with multiline args</span></h2><p class="narrative"></p><div class="background"><h3><span class="keyword">Background:</span> <span class="val"></span></h3><ol><li class="step passed" id="features_background_multiline_args_background_feature_4"><div><span class="keyword">Given</span> <span class="step val">table</span></div><table><tr id="row_5"><td class="val" id="row_5_0">a</td><td class="val" id="row_5_1">b</td></tr><tr id="row_6"><td class="val" id="row_6_0">c</td><td class="val" id="row_6_1">d</td></tr></table></li><li class="step passed" id="features_background_multiline_args_background_feature_7"><div><span class="keyword">And</span> <span class="step val">multiline string</span></div><pre class="val"> I'm a cucumber and I'm okay. &#x000A; I sleep all night and I test all day</pre></li></ol></div><div class="scenario"><h3><span class="keyword">Scenario:</span> <span class="val">passing background</span></h3><ol><li class="step passed" id="features_background_multiline_args_background_feature_14"><div><span class="keyword">Then</span> <span class="step val">the table should be</span></div><table><tr id="row_15"><td class="val" id="row_15_0">a</td><td class="val" id="row_15_1">b</td></tr><tr id="row_16"><td class="val" id="row_16_0">c</td><td class="val" id="row_16_1">d</td></tr></table></li><li class="step passed" id="features_background_multiline_args_background_feature_17"><div><span class="keyword">Then</span> <span class="step val">the multiline string should be</span></div><pre class="val"> I'm a cucumber and I'm okay. &#x000A; I sleep all night and I test all day</pre></li></ol></div><div class="scenario"><h3><span class="keyword">Scenario:</span> <span class="val">another passing background</span></h3><ol><li class="step passed" id="features_background_multiline_args_background_feature_24"><div><span class="keyword">Then</span> <span class="step val">the table should be</span></div><table><tr id="row_25"><td class="val" id="row_25_0">a</td><td class="val" id="row_25_1">b</td></tr><tr id="row_26"><td class="val" id="row_26_0">c</td><td class="val" id="row_26_1">d</td></tr></table></li><li class="step passed" id="features_background_multiline_args_background_feature_27"><div><span class="keyword">Then</span> <span class="step val">the multiline string should be</span></div><pre class="val"> I'm a cucumber and I'm okay. &#x000A; I sleep all night and I test all day</pre></li></ol></div></div><div class="feature"><h2><span class="val">Feature: Passing background sample</span></h2><p class="narrative"></p><div class="background"><h3><span class="keyword">Background:</span> <span class="val"></span></h3><ol><li class="step passed" id="features_background_passing_background_feature_4"><div><span class="keyword">Given</span> <span class="step val">'<span class="param">10</span>' cukes</span></div></li></ol></div><div class="scenario"><h3><span class="keyword">Scenario:</span> <span class="val">passing background</span></h3><ol><li class="step passed" id="features_background_passing_background_feature_7"><div><span class="keyword">Then</span> <span class="step val">I should have '<span class="param">10</span>' cukes</span></div></li></ol></div><div class="scenario"><h3><span class="keyword">Scenario:</span> <span class="val">another passing background</span></h3><ol><li class="step passed" id="features_background_passing_background_feature_10"><div><span class="keyword">Then</span> <span class="step val">I should have '<span class="param">10</span>' cukes</span></div></li></ol></div></div><div class="feature"><h2><span class="val">Feature: Pending background sample</span></h2><p class="narrative"></p><div class="background"><h3><span class="keyword">Background:</span> <span class="val"></span></h3><ol><li class="step undefined" id="features_background_pending_background_feature_4"><div><span class="keyword">Given</span> <span class="step val">pending</span></div></li></ol></div><div class="scenario"><h3><span class="keyword">Scenario:</span> <span class="val">pending background</span></h3><ol><li class="step skipped" id="features_background_pending_background_feature_7"><div><span class="keyword">Then</span> <span class="step val">I should have '<span class="param">10</span>' cukes</span></div></li></ol></div><div class="scenario"><h3><span class="keyword">Scenario:</span> <span class="val">another pending background</span></h3><ol><li class="step skipped" id="features_background_pending_background_feature_10"><div><span class="keyword">Then</span> <span class="step val">I should have '<span class="param">10</span>' cukes</span></div></li></ol></div></div><div class="feature"><h2><span class="val">Feature: Failing background with scenario outlines sample</span></h2><p class="narrative"></p><div class="background"><h3><span class="keyword">Background:</span> <span class="val"></span></h3><ol><li class="step failed" id="features_background_scenario_outline_failing_background_feature_4"><div><span class="keyword">Given</span> <span class="step val">failing without a table</span></div><pre class="failed">FAIL (RuntimeError)
140
140
  ./features/step_definitions/sample_steps.rb:2:in `flunker'
141
141
  ./features/step_definitions/sample_steps.rb:16:in `/^failing without a table$/'
142
- features/background/scenario_outline_failing_background.feature:4:in `Given failing without a table'</pre></li></ol></div><div class="scenario outline"><h3><span class="keyword">Scenario Outline:</span> <span class="val">failing background</span></h3><ol><li class="step skipped" id="features_background_scenario_outline_failing_background_feature_7"><div><span class="keyword">Then</span> <span class="step val">I should have '&lt;count&gt;' cukes</span></div></li></ol><div class="examples"><h4><span class="keyword">Examples:</span> <span class="val"></span></h4><table><tr id="row_9"><th class="val skipped_param" id="row_9_0">count</th></tr><tr id="row_10"><td class="val skipped" id="row_10_0">10</td></tr><tr><td class="failed" colspan="1"><pre>FAIL (RuntimeError)
142
+ features/background/scenario_outline_failing_background.feature:4:in `Given failing without a table'</pre></li></ol></div><div class="scenario outline"><h3><span class="keyword">Scenario Outline:</span> <span class="val">failing background</span></h3><ol><li class="step skipped" id="features_background_scenario_outline_failing_background_feature_7"><div><span class="keyword">Then</span> <span class="step val">I should have '&lt;count&gt;' cukes</span></div></li></ol><div class="examples"><h4><span class="keyword">Examples:</span> <span class="val"></span></h4><table><tr id="row_9"><th class="val skipped_param" id="row_9_0">count</th></tr><tr id="row_10"><td class="val skipped" id="row_10_0">10</td></tr><tr><td colspan="1" class="failed"><pre>FAIL (RuntimeError)
143
143
  ./features/step_definitions/sample_steps.rb:2:in `flunker'
144
144
  ./features/step_definitions/sample_steps.rb:16:in `/^failing without a table$/'
145
145
  features/background/scenario_outline_failing_background.feature:4:in `Given failing without a table'</pre></td></tr></table></div></div><div class="scenario outline"><h3><span class="keyword">Scenario Outline:</span> <span class="val">another failing background</span></h3><ol><li class="step skipped" id="features_background_scenario_outline_failing_background_feature_13"><div><span class="keyword">Then</span> <span class="step val">I should have '&lt;count&gt;' cukes</span></div></li></ol><div class="examples"><h4><span class="keyword">Examples:</span> <span class="val"></span></h4><table><tr id="row_15"><th class="val skipped_param" id="row_15_0">count</th></tr><tr id="row_16"><td class="val skipped" id="row_16_0">10</td></tr></table></div></div></div><div class="feature"><h2><span class="val">Feature: Passing background with scenario outlines sample</span></h2><p class="narrative"></p><div class="background"><h3><span class="keyword">Background:</span> <span class="val"></span></h3><ol><li class="step passed" id="features_background_scenario_outline_passing_background_feature_4"><div><span class="keyword">Given</span> <span class="step val">'<span class="param">10</span>' cukes</span></div></li></ol></div><div class="scenario outline"><h3><span class="keyword">Scenario Outline:</span> <span class="val">passing background</span></h3><ol><li class="step skipped" id="features_background_scenario_outline_passing_background_feature_7"><div><span class="keyword">Then</span> <span class="step val">I should have '&lt;count&gt;' cukes</span></div></li></ol><div class="examples"><h4><span class="keyword">Examples:</span> <span class="val"></span></h4><table><tr id="row_9"><th class="val skipped_param" id="row_9_0">count</th></tr><tr id="row_10"><td class="val passed" id="row_10_0">10</td></tr></table></div></div><div class="scenario outline"><h3><span class="keyword">Scenario Outline:</span> <span class="val">another passing background</span></h3><ol><li class="step skipped" id="features_background_scenario_outline_passing_background_feature_13"><div><span class="keyword">Then</span> <span class="step val">I should have '&lt;count&gt;' cukes</span></div></li></ol><div class="examples"><h4><span class="keyword">Examples:</span> <span class="val"></span></h4><table><tr id="row_15"><th class="val skipped_param" id="row_15_0">count</th></tr><tr id="row_16"><td class="val passed" id="row_16_0">10</td></tr></table></div></div></div><div class="feature"><h2><span class="val">Feature: Calling undefined step</span></h2><p class="narrative"></p><div class="scenario"><h3><span class="keyword">Scenario:</span> <span class="val">Call directly</span></h3><ol><li class="step undefined" id="features_call_undefined_step_from_step_def_feature_4"><div><span class="keyword">Given</span> <span class="step val">a step definition that calls an undefined step</span></div><pre class="undefined">Undefined step: "this does not exist" (Cucumber::Undefined)
@@ -163,7 +163,7 @@ yawn</span></h3><ol><li class="step passed" id="features_multiline_name_feature_
163
163
  which goes on and on and on for three lines
164
164
  yawn</span></h3><ol><li class="step skipped" id="features_multiline_name_feature_16"><div><span class="keyword">Given</span> <span class="step val">&lt;state&gt; without a table</span></div></li></ol><div class="examples"><h4><span class="keyword">Examples:</span> <span class="val"></span></h4><table><tr id="row_18"><th class="val skipped_param" id="row_18_0">state</th></tr><tr id="row_19"><td class="val passed" id="row_19_0">passing</td></tr></table></div></div><div class="scenario outline"><h3><span class="keyword">Scenario Outline:</span> <span class="val">name</span></h3><ol><li class="step skipped" id="features_multiline_name_feature_22"><div><span class="keyword">Given</span> <span class="step val">&lt;state&gt; without a table</span></div></li></ol><div class="examples"><h4><span class="keyword">Examples:</span> <span class="val">I'm a multiline name
165
165
  which goes on and on and on for three lines
166
- yawn</span></h4><table><tr id="row_26"><th class="val skipped_param" id="row_26_0">state</th></tr><tr id="row_27"><td class="val passed" id="row_27_0">passing</td></tr></table></div></div></div><div class="feature"><h2><span class="val">Feature: Outline Sample</span></h2><p class="narrative"></p><div class="scenario"><h3><span class="keyword">Scenario:</span> <span class="val">I have no steps</span></h3><ol></ol></div><div class="scenario outline"><h3><span class="keyword">Scenario Outline:</span> <span class="val">Test state</span></h3><ol><li class="step skipped" id="features_outline_sample_feature_6"><div><span class="keyword">Given</span> <span class="step val">&lt;state&gt; without a table</span></div></li><li class="step skipped" id="features_outline_sample_feature_7"><div><span class="keyword">Given</span> <span class="step val">&lt;other_state&gt; without a table</span></div></li></ol><div class="examples"><h4><span class="keyword">Examples:</span> <span class="val">Rainbow colours</span></h4><table><tr id="row_9"><th class="val skipped_param" id="row_9_0">state</th><th class="val skipped_param" id="row_9_1">other_state</th></tr><tr id="row_10"><td class="val undefined" id="row_10_0">missing</td><td class="val skipped" id="row_10_1">passing</td></tr><tr id="row_11"><td class="val passed" id="row_11_0">passing</td><td class="val passed" id="row_11_1">passing</td></tr><tr id="row_12"><td class="val failed" id="row_12_0">failing</td><td class="val skipped" id="row_12_1">passing</td></tr><tr><td class="failed" colspan="2"><pre>FAIL (RuntimeError)
166
+ yawn</span></h4><table><tr id="row_26"><th class="val skipped_param" id="row_26_0">state</th></tr><tr id="row_27"><td class="val passed" id="row_27_0">passing</td></tr></table></div></div></div><div class="feature"><h2><span class="val">Feature: Outline Sample</span></h2><p class="narrative"></p><div class="scenario"><h3><span class="keyword">Scenario:</span> <span class="val">I have no steps</span></h3><ol></ol></div><div class="scenario outline"><h3><span class="keyword">Scenario Outline:</span> <span class="val">Test state</span></h3><ol><li class="step skipped" id="features_outline_sample_feature_6"><div><span class="keyword">Given</span> <span class="step val">&lt;state&gt; without a table</span></div></li><li class="step skipped" id="features_outline_sample_feature_7"><div><span class="keyword">Given</span> <span class="step val">&lt;other_state&gt; without a table</span></div></li></ol><div class="examples"><h4><span class="keyword">Examples:</span> <span class="val">Rainbow colours</span></h4><table><tr id="row_9"><th class="val skipped_param" id="row_9_0">state</th><th class="val skipped_param" id="row_9_1">other_state</th></tr><tr id="row_10"><td class="val undefined" id="row_10_0">missing</td><td class="val skipped" id="row_10_1">passing</td></tr><tr id="row_11"><td class="val passed" id="row_11_0">passing</td><td class="val passed" id="row_11_1">passing</td></tr><tr id="row_12"><td class="val failed" id="row_12_0">failing</td><td class="val skipped" id="row_12_1">passing</td></tr><tr><td colspan="2" class="failed"><pre>FAIL (RuntimeError)
167
167
  ./features/step_definitions/sample_steps.rb:2:in `flunker'
168
168
  ./features/step_definitions/sample_steps.rb:16:in `/^failing without a table$/'
169
169
  features/outline_sample.feature:6:in `Given <state> without a table'</pre></td></tr></table></div><div class="examples"><h4><span class="keyword">Examples:</span> <span class="val">Only passing</span></h4><table><tr id="row_14"><th class="val skipped_param" id="row_14_0">state</th><th class="val skipped_param" id="row_14_1">other_state</th></tr><tr id="row_15"><td class="val passed" id="row_15_0">passing</td><td class="val passed" id="row_15_1">passing</td></tr></table></div></div></div><div class="feature"><pre class="comment"># Feature comment<br/></pre><span class="tag">@one</span><h2><span class="val">Feature: Sample</span></h2><p class="narrative"></p><div class="scenario"><span class="tag">@two</span> <span class="tag">@three</span><h3><span class="keyword">Scenario:</span> <span class="val">Missing</span></h3><ol><li class="step undefined" id="features_sample_feature_7"><div><span class="keyword">Given</span> <span class="step val">missing</span></div></li></ol></div><div class="scenario"><pre class="comment"># Scenario comment<br/></pre><span class="tag">@three</span><h3><span class="keyword">Scenario:</span> <span class="val">Passing</span></h3><ol><li class="step passed" id="features_sample_feature_12"><div><span class="keyword">Given</span> <span class="step val">passing</span></div><table><tr id="row_13"><td class="val" id="row_13_0">a</td><td class="val" id="row_13_1">b</td></tr><tr id="row_14"><td class="val" id="row_14_0">c</td><td class="val" id="row_14_1">d</td></tr></table></li></ol></div><div class="scenario"><span class="tag">@four</span><h3><span class="keyword">Scenario:</span> <span class="val">Failing</span></h3><ol><li class="step failed" id="features_sample_feature_18"><div><span class="keyword">Given</span> <span class="step val">failing</span></div><pre class="val">hello</pre><pre class="failed">FAIL (RuntimeError)
@@ -172,10 +172,10 @@ features/outline_sample.feature:6:in `Given <state> without a table'</pre></td><
172
172
  features/sample.feature:18:in `Given failing'</pre></li></ol></div></div><div class="feature"><h2><span class="val">Feature: search examples</span></h2><p class="narrative"></p><div class="background"><h3><span class="keyword">Background:</span> <span class="val">Hantu Pisang background match</span></h3><ol><li class="step passed" id="features_search_sample_feature_4"><div><span class="keyword">Given</span> <span class="step val">passing without a table</span></div></li></ol></div><div class="scenario"><h3><span class="keyword">Scenario:</span> <span class="val">should match Hantu Pisang</span></h3><ol><li class="step passed" id="features_search_sample_feature_7"><div><span class="keyword">Given</span> <span class="step val">passing without a table</span></div></li></ol></div><div class="scenario"><h3><span class="keyword">Scenario:</span> <span class="val">Ignore me</span></h3><ol><li class="step failed" id="features_search_sample_feature_10"><div><span class="keyword">Given</span> <span class="step val">failing without a table</span></div><pre class="failed">FAIL (RuntimeError)
173
173
  ./features/step_definitions/sample_steps.rb:2:in `flunker'
174
174
  ./features/step_definitions/sample_steps.rb:16:in `/^failing without a table$/'
175
- features/search_sample.feature:10:in `Given failing without a table'</pre></li></ol></div><div class="scenario outline"><h3><span class="keyword">Scenario Outline:</span> <span class="val">Ignore me</span></h3><ol><li class="step skipped" id="features_search_sample_feature_13"><div><span class="keyword">Given</span> <span class="step val">&lt;state&gt; without a table</span></div></li></ol><div class="examples"><h4><span class="keyword">Examples:</span> <span class="val"></span></h4><table><tr id="row_15"><th class="val skipped_param" id="row_15_0">state</th></tr><tr id="row_16"><td class="val failed" id="row_16_0">failing</td></tr><tr><td class="failed" colspan="1"><pre>FAIL (RuntimeError)
175
+ features/search_sample.feature:10:in `Given failing without a table'</pre></li></ol></div><div class="scenario outline"><h3><span class="keyword">Scenario Outline:</span> <span class="val">Ignore me</span></h3><ol><li class="step skipped" id="features_search_sample_feature_13"><div><span class="keyword">Given</span> <span class="step val">&lt;state&gt; without a table</span></div></li></ol><div class="examples"><h4><span class="keyword">Examples:</span> <span class="val"></span></h4><table><tr id="row_15"><th class="val skipped_param" id="row_15_0">state</th></tr><tr id="row_16"><td class="val failed" id="row_16_0">failing</td></tr><tr><td colspan="1" class="failed"><pre>FAIL (RuntimeError)
176
176
  ./features/step_definitions/sample_steps.rb:2:in `flunker'
177
177
  ./features/step_definitions/sample_steps.rb:16:in `/^failing without a table$/'
178
- features/search_sample.feature:13:in `Given <state> without a table'</pre></td></tr></table></div></div><div class="scenario outline"><h3><span class="keyword">Scenario Outline:</span> <span class="val">Hantu Pisang match</span></h3><ol><li class="step skipped" id="features_search_sample_feature_19"><div><span class="keyword">Given</span> <span class="step val">&lt;state&gt; without a table</span></div></li></ol><div class="examples"><h4><span class="keyword">Examples:</span> <span class="val"></span></h4><table><tr id="row_21"><th class="val skipped_param" id="row_21_0">state</th></tr><tr id="row_22"><td class="val passed" id="row_22_0">passing</td></tr></table></div></div><div class="scenario outline"><h3><span class="keyword">Scenario Outline:</span> <span class="val">no match in name but in examples</span></h3><ol><li class="step skipped" id="features_search_sample_feature_25"><div><span class="keyword">Given</span> <span class="step val">&lt;state&gt; without a table</span></div></li></ol><div class="examples"><h4><span class="keyword">Examples:</span> <span class="val">Hantu Pisang</span></h4><table><tr id="row_27"><th class="val skipped_param" id="row_27_0">state</th></tr><tr id="row_28"><td class="val passed" id="row_28_0">passing</td></tr></table></div><div class="examples"><h4><span class="keyword">Examples:</span> <span class="val">Ignore me</span></h4><table><tr id="row_31"><th class="val skipped_param" id="row_31_0">state</th></tr><tr id="row_32"><td class="val failed" id="row_32_0">failing</td></tr><tr><td class="failed" colspan="1"><pre>FAIL (RuntimeError)
178
+ features/search_sample.feature:13:in `Given <state> without a table'</pre></td></tr></table></div></div><div class="scenario outline"><h3><span class="keyword">Scenario Outline:</span> <span class="val">Hantu Pisang match</span></h3><ol><li class="step skipped" id="features_search_sample_feature_19"><div><span class="keyword">Given</span> <span class="step val">&lt;state&gt; without a table</span></div></li></ol><div class="examples"><h4><span class="keyword">Examples:</span> <span class="val"></span></h4><table><tr id="row_21"><th class="val skipped_param" id="row_21_0">state</th></tr><tr id="row_22"><td class="val passed" id="row_22_0">passing</td></tr></table></div></div><div class="scenario outline"><h3><span class="keyword">Scenario Outline:</span> <span class="val">no match in name but in examples</span></h3><ol><li class="step skipped" id="features_search_sample_feature_25"><div><span class="keyword">Given</span> <span class="step val">&lt;state&gt; without a table</span></div></li></ol><div class="examples"><h4><span class="keyword">Examples:</span> <span class="val">Hantu Pisang</span></h4><table><tr id="row_27"><th class="val skipped_param" id="row_27_0">state</th></tr><tr id="row_28"><td class="val passed" id="row_28_0">passing</td></tr></table></div><div class="examples"><h4><span class="keyword">Examples:</span> <span class="val">Ignore me</span></h4><table><tr id="row_31"><th class="val skipped_param" id="row_31_0">state</th></tr><tr id="row_32"><td class="val failed" id="row_32_0">failing</td></tr><tr><td colspan="1" class="failed"><pre>FAIL (RuntimeError)
179
179
  ./features/step_definitions/sample_steps.rb:2:in `flunker'
180
180
  ./features/step_definitions/sample_steps.rb:16:in `/^failing without a table$/'
181
181
  features/search_sample.feature:25:in `Given <state> without a table'</pre></td></tr></table></div></div></div><div class="feature"><span class="tag">@lots</span><h2><span class="val">Feature: Tons of cukes</span></h2><p class="narrative"></p><div class="scenario"><h3><span class="keyword">Scenario:</span> <span class="val">Lots and lots</span></h3><ol><li class="step passed" id="features_tons_of_cukes_feature_4"><div><span class="keyword">Given</span> <span class="step val">'<span class="param">2</span>' cukes</span></div></li><li class="step failed" id="features_tons_of_cukes_feature_5"><div><span class="keyword">Given</span> <span class="step val">'<span class="param">2</span>' cukes</span></div><pre class="failed">We already have 2 cukes! (RuntimeError)
@@ -0,0 +1,99 @@
1
+ Feature: Profiles
2
+ In order to save time and prevent carpal tunnel syndrome
3
+ Cucumber users can save and reuse commonly used cucumber flags in a 'cucumber.yml' file.
4
+ These named arguments are called profiles and the yml file should be in the root of your project.
5
+ Any cucumber argument is valid in a profile. To see all the available flags type 'cucumber --help'
6
+ For more information about profiles please see the wiki:
7
+ http://wiki.github.com/aslakhellesoy/cucumber/cucumberyml
8
+
9
+ Background: Basic App
10
+ Given a standard Cucumber project directory structure
11
+ And a file named "features/sample.feature" with:
12
+ """
13
+ Feature: Sample
14
+ Scenario: this is a test
15
+ Given I am just testing stuff
16
+ """
17
+ And a file named "features/support/env.rb"
18
+ And a file named "features/support/super_env.rb"
19
+ And the following profiles are defined:
20
+ """
21
+ default: features/sample.feature --require features/support/env.rb -v
22
+ super: features/sample.feature --require features/support/super_env.rb -v
23
+ """
24
+
25
+ Scenario: Explicitly defining a profile to run
26
+ When I run cucumber features/sample.feature --profile super
27
+ Then the output should contain
28
+ """
29
+ Using the super profile...
30
+ """
31
+ And exactly these files should be loaded: features/support/super_env.rb
32
+
33
+ Scenario: Defining multiple profiles to run
34
+ When I run cucumber features/sample.feature --profile default --profile super
35
+ Then the output should contain
36
+ """
37
+ Using the default and super profiles...
38
+ """
39
+ And exactly these files should be loaded: features/support/env.rb, features/support/super_env.rb
40
+
41
+ Scenario: Arguments passed in but no profile specified
42
+ When I run cucumber -v
43
+ Then the default profile should be used
44
+ And exactly these files should be loaded: features/support/env.rb
45
+
46
+ Scenario: Trying to use a missing profile
47
+ When I run cucumber -p foo
48
+ Then STDERR should be
49
+ """
50
+ Could not find profile: 'foo'
51
+
52
+ Defined profiles in cucumber.yml:
53
+ * default
54
+ * super
55
+
56
+ """
57
+
58
+ Scenario Outline: Disabling the default profile
59
+ When I run cucumber -v features/ <Flag>
60
+ Then the output should contain
61
+ """
62
+ Disabling profiles...
63
+ """
64
+ And exactly these files should be loaded: features/support/env.rb, features/support/super_env.rb
65
+
66
+ Examples:
67
+ | Flag |
68
+ | -P |
69
+ | --no-profile |
70
+
71
+
72
+ Scenario: Overriding the profile's features to run
73
+ Given a file named "features/another.feature" with:
74
+ """
75
+ Feature: Just this one should be ran
76
+ """
77
+ When I run cucumber -p default features/another.feature
78
+ Then exactly these features should be ran: features/another.feature
79
+
80
+ Scenario: Overriding the profile's formatter
81
+ You will most likely want to define a formatter in your default formatter.
82
+ However, you often want to run your features with a different formatter
83
+ yet still use the other the other arguments in the profile. Cucumber will
84
+ allow you to do this by giving precedence to the formatter specified on the
85
+ command line and override the one in the profile.
86
+
87
+ Given the following profiles are defined:
88
+ """
89
+ default: features/sample.feature --require features/support/env.rb -v --format profile
90
+ """
91
+ When I run cucumber features --format pretty
92
+ And the output should contain
93
+ """
94
+ Feature: Sample
95
+ """
96
+
97
+
98
+
99
+
@@ -111,6 +111,10 @@ Then /^STDERR should not match$/ do |text|
111
111
  last_stderr.should_not =~ /#{text}/
112
112
  end
113
113
 
114
+ Then /^STDERR should be$/ do |text|
115
+ last_stderr.should == text
116
+ end
117
+
114
118
  Then /^STDERR should be empty$/ do
115
119
  last_stderr.should == ""
116
120
  end
@@ -128,3 +132,19 @@ Then /^"([^\"]*)" should be required$/ do |file_name|
128
132
  last_stdout.should include("* #{file_name}")
129
133
  end
130
134
 
135
+ Then /^exactly these files should be loaded:\s*(.*)$/ do |files|
136
+ last_stdout.scan(/^ \* (.*\.rb)$/).flatten.should == files.split(/,\s+/)
137
+ end
138
+
139
+ Then /^exactly these features should be ran:\s*(.*)$/ do |files|
140
+ last_stdout.scan(/^ \* (.*\.feature)$/).flatten.should == files.split(/,\s+/)
141
+ end
142
+
143
+ Then /^the (.*) profile should be used$/ do |profile|
144
+ last_stdout.should =~ /Using the #{profile} profile/
145
+ end
146
+
147
+ Then /^print output$/ do
148
+ puts last_stdout
149
+ end
150
+
@@ -52,6 +52,7 @@ Feature: Cucumber --work-in-progress switch
52
52
  @mri186
53
53
  Scenario: Pass with Failing Scenarios
54
54
  When I run cucumber -q -w -t @failing features/wip.feature
55
+ Then STDERR should be empty
55
56
  Then it should pass with
56
57
  """
57
58
  Feature: WIP
@@ -0,0 +1,4 @@
1
+ task :contributors do
2
+ contributors = `git log --pretty=short --no-merges | git shortlog -ne | egrep -ve '^ +' | egrep -ve '^$'`
3
+ puts contributors.split("\n").length
4
+ end
@@ -135,8 +135,8 @@ module Cucumber
135
135
  #
136
136
  # A StepDefinition receiving this table can then map the columns:
137
137
  #
138
- # mapped_table = table.map_columns('Phone Number' => :phone, 'Address' => :address)
139
- # hashes = mapped_table.hashes
138
+ # table.map_headers!('Phone Number' => :phone, 'Address' => :address)
139
+ # table.hashes
140
140
  # # => [{:phone => '123456', :address => 'xyz'}, {:phone => '345678', :address => 'abc'}]
141
141
  #
142
142
  def map_headers!(mappings)
@@ -1,200 +1,29 @@
1
+ require 'cucumber/cli/options'
2
+
1
3
  module Cucumber
2
4
  module Cli
3
5
  class YmlLoadError < StandardError; end
6
+ class ProfilesNotDefinedError < YmlLoadError; end
7
+ class ProfileNotFound < StandardError; end
4
8
 
5
9
  class Configuration
6
- BUILTIN_FORMATS = {
7
- 'html' => 'Cucumber::Formatter::Html',
8
- 'pretty' => 'Cucumber::Formatter::Pretty',
9
- 'profile' => 'Cucumber::Formatter::Profile',
10
- 'progress' => 'Cucumber::Formatter::Progress',
11
- 'rerun' => 'Cucumber::Formatter::Rerun',
12
- 'usage' => 'Cucumber::Formatter::Usage',
13
- 'junit' => 'Cucumber::Formatter::Junit',
14
- 'tag_cloud' => 'Cucumber::Formatter::TagCloud',
15
- 'steps' => 'Cucumber::Formatter::Steps'
16
- }
17
- DRB_FLAG = '--drb'
18
- PROFILE_SHORT_FLAG = '-p'
19
- PROFILE_LONG_FLAG = '--profile'
20
-
21
- attr_reader :paths
22
10
  attr_reader :options
23
11
 
24
12
  def initialize(out_stream = STDOUT, error_stream = STDERR)
25
13
  @out_stream = out_stream
26
14
  @error_stream = error_stream
27
-
28
- @paths = []
29
- @options = default_options
15
+ @options = Options.new(@out_stream, @error_stream, :default_profile => 'default')
30
16
  end
31
17
 
32
18
  def parse!(args)
33
- args.concat(%w{--profile default}) if args.empty?
34
19
  @args = args
35
- expand_profiles_into_args
36
- return if parse_drb
20
+ @options.parse!(args)
21
+ raise("You can't use both --strict and --wip") if strict? && wip?
37
22
 
38
- @args.each do |arg|
39
- if arg =~ /^(\w+)=(.*)$/
40
- ENV[$1] = $2
41
- @args.delete(arg)
42
- end
43
- end
44
-
45
- @args.extend(::OptionParser::Arguable)
46
-
47
- @args.options do |opts|
48
- opts.banner = ["Usage: cucumber [options] [ [FILE|DIR|URL][:LINE[:LINE]*] ]+", "",
49
- "Examples:",
50
- "cucumber examples/i18n/en/features",
51
- "cucumber --language it examples/i18n/it/features/somma.feature:6:98:113",
52
- "cucumber -s -i http://rubyurl.com/eeCl", "", "",
53
- ].join("\n")
54
- opts.on("-r LIBRARY|DIR", "--require LIBRARY|DIR",
55
- "Require files before executing the features. If this",
56
- "option is not specified, all *.rb files that are",
57
- "siblings or below the features will be loaded auto-",
58
- "matically. Automatic loading is disabled when this",
59
- "option is specified, and all loading becomes explicit.",
60
- "Files under directories named \"support\" are always",
61
- "loaded first.",
62
- "This option can be specified multiple times.") do |v|
63
- @options[:require] ||= []
64
- @options[:require] << v
65
- end
66
- opts.on("-l LANG", "--language LANG",
67
- "Specify language for features (Default: #{@options[:lang]})",
68
- %{Run with "--language help" to see all languages},
69
- %{Run with "--language LANG help" to list keywords for LANG}) do |v|
70
- if v == 'help'
71
- list_languages_and_exit
72
- elsif args==['help']
73
- list_keywords_and_exit(v)
74
- else
75
- @options[:lang] = v
76
- end
77
- end
78
- opts.on("-f FORMAT", "--format FORMAT",
79
- "How to format features (Default: pretty)",
80
- "Available formats: #{BUILTIN_FORMATS.keys.sort.join(", ")}",
81
- "FORMAT can also be the fully qualified class name of",
82
- "your own custom formatter. If the class isn't loaded,",
83
- "Cucumber will attempt to require a file with a relative",
84
- "file name that is the underscore name of the class name.",
85
- "Example: --format Foo::BarZap -> Cucumber will look for",
86
- "foo/bar_zap.rb. You can place the file with this relative",
87
- "path underneath your features/support directory or anywhere",
88
- "on Ruby's LOAD_PATH, for example in a Ruby gem.") do |v|
89
- @options[:formats] << [v, @out_stream]
90
- @active_format = v
91
- end
92
- opts.on("-o", "--out [FILE|DIR]",
93
- "Write output to a file/directory instead of STDOUT. This option",
94
- "applies to the previously specified --format, or the",
95
- "default format if no format is specified. Check the specific",
96
- "formatter's docs to see whether to pass a file or a dir.") do |v|
97
- @options[:formats] << ['pretty', nil] if @options[:formats].empty?
98
- @options[:formats][-1][1] = v
99
- end
100
- opts.on("-t TAGS", "--tags TAGS",
101
- "Only execute the features or scenarios with the specified tags.",
102
- "TAGS must be comma-separated without spaces. Prefix tags with ~ to",
103
- "exclude features or scenarios having that tag. Tags can be specified",
104
- "with or without the @ prefix.") do |v|
105
- include_tags, exclude_tags = *parse_tags(v)
106
- @options[:include_tags] += include_tags
107
- @options[:exclude_tags] += exclude_tags
108
- end
109
- opts.on("-n NAME", "--name NAME",
110
- "Only execute the feature elements which match part of the given name.",
111
- "If this option is given more than once, it will match against all the",
112
- "given names.") do |v|
113
- @options[:name_regexps] << /#{v}/
114
- end
115
- opts.on("-e", "--exclude PATTERN", "Don't run feature files or require ruby files matching PATTERN") do |v|
116
- @options[:excludes] << Regexp.new(v)
117
- end
118
- opts.on(PROFILE_SHORT_FLAG, "#{PROFILE_LONG_FLAG} PROFILE", "Pull commandline arguments from cucumber.yml.") do |v|
119
- # Processing of this is done previsouly so that the DRb flag can be detected within profiles.
120
- end
121
- opts.on("-c", "--[no-]color",
122
- "Whether or not to use ANSI color in the output. Cucumber decides",
123
- "based on your platform and the output destination if not specified.") do |v|
124
- Term::ANSIColor.coloring = v
125
- end
126
- opts.on("-d", "--dry-run", "Invokes formatters without executing the steps.",
127
- "This also omits the loading of your support/env.rb file if it exists.",
128
- "Implies --quiet.") do
129
- @options[:dry_run] = true
130
- @quiet = true
131
- end
132
- opts.on("-a", "--autoformat DIRECTORY",
133
- "Reformats (pretty prints) feature files and write them to DIRECTORY.",
134
- "Be careful if you choose to overwrite the originals.",
135
- "Implies --dry-run --formatter pretty.") do |directory|
136
- @options[:autoformat] = directory
137
- Term::ANSIColor.coloring = false
138
- @options[:dry_run] = true
139
- @quiet = true
140
- end
141
- opts.on("-m", "--no-multiline",
142
- "Don't print multiline strings and tables under steps.") do
143
- @options[:no_multiline] = true
144
- end
145
- opts.on("-s", "--no-source",
146
- "Don't print the file and line of the step definition with the steps.") do
147
- @options[:source] = false
148
- end
149
- opts.on("-i", "--no-snippets", "Don't print snippets for pending steps.") do
150
- @options[:snippets] = false
151
- end
152
- opts.on("-q", "--quiet", "Alias for --no-snippets --no-source.") do
153
- @quiet = true
154
- end
155
- opts.on("-b", "--backtrace", "Show full backtrace for all errors.") do
156
- Exception.cucumber_full_backtrace = true
157
- end
158
- opts.on("-S", "--strict", "Fail if there are any undefined steps.") do
159
- @options[:strict] = true
160
- end
161
- opts.on("-w", "--wip", "Fail if there are any passing scenarios.") do
162
- @options[:wip] = true
163
- end
164
- opts.on("-v", "--verbose", "Show the files and features loaded.") do
165
- @options[:verbose] = true
166
- end
167
- opts.on("-g", "--guess", "Guess best match for Ambiguous steps.") do
168
- @options[:guess] = true
169
- end
170
- opts.on("-x", "--expand", "Expand Scenario Outline Tables in output.") do
171
- @options[:expand] = true
172
- end
173
- opts.on("--no-diff", "Disable diff output on failing expectations.") do
174
- @options[:diff_enabled] = false
175
- end
176
- opts.on(DRB_FLAG, "Run features against a DRb server. (i.e. with the spork gem)") do
177
- # Processing of this is done previsouly in order to short circuit args from being lost.
178
- end
179
- opts.on_tail("--version", "Show version.") do
180
- @out_stream.puts VERSION::STRING
181
- Kernel.exit
182
- end
183
- opts.on_tail("-h", "--help", "You're looking at it.") do
184
- @out_stream.puts opts.help
185
- Kernel.exit
186
- end
187
- end.parse!
23
+ return @args.replace(@options.expanded_args_without_drb) if drb?
188
24
 
25
+ set_environment_variables
189
26
  arrange_formats
190
-
191
- @options[:snippets] = true if !@quiet && @options[:snippets].nil?
192
- @options[:source] = true if !@quiet && @options[:source].nil?
193
-
194
- raise("You can't use both --strict and --wip") if @options[:strict] && @options[:wip]
195
-
196
- # Whatever is left after option parsing is the FILE arguments
197
- @paths += @args
198
27
  end
199
28
 
200
29
  def verbose?
@@ -218,18 +47,11 @@ module Cucumber
218
47
  end
219
48
 
220
49
  def drb?
221
- @drb
50
+ @options[:drb]
222
51
  end
223
52
 
224
- def parse_tags(tag_string)
225
- tag_names = tag_string.split(",")
226
- excludes, includes = tag_names.partition{|tag| tag =~ /^~/}
227
- excludes = excludes.map{|tag| tag[1..-1]}
228
-
229
- # Strip @
230
- includes = includes.map{|tag| Ast::Tags.strip_prefix(tag)}
231
- excludes = excludes.map{|tag| Ast::Tags.strip_prefix(tag)}
232
- [includes, excludes]
53
+ def paths
54
+ @options[:paths]
233
55
  end
234
56
 
235
57
  def build_formatter_broadcaster(step_mother)
@@ -262,15 +84,15 @@ module Cucumber
262
84
  end
263
85
 
264
86
  def formatter_class(format)
265
- if(builtin = BUILTIN_FORMATS[format])
266
- constantize(builtin)
87
+ if(builtin = Options::BUILTIN_FORMATS[format])
88
+ constantize(builtin[0])
267
89
  else
268
90
  constantize(format)
269
91
  end
270
92
  end
271
93
 
272
94
  def files_to_require
273
- requires = @options[:require] || require_dirs
95
+ requires = @options[:require].empty? ? require_dirs : @options[:require]
274
96
  files = requires.map do |path|
275
97
  path = path.gsub(/\\/, '/') # In case we're on windows. Globs don't work with backslashes.
276
98
  path = path.gsub(/\/$/, '') # Strip trailing slash.
@@ -285,7 +107,7 @@ module Cucumber
285
107
  end
286
108
 
287
109
  def feature_files
288
- potential_feature_files = @paths.map do |path|
110
+ potential_feature_files = @options[:paths].map do |path|
289
111
  path = path.gsub(/\\/, '/') # In case we're on windows. Globs don't work with backslashes.
290
112
  path = path.chomp('/')
291
113
  File.directory?(path) ? Dir["#{path}/**/*.feature"] : path
@@ -294,7 +116,13 @@ module Cucumber
294
116
  potential_feature_files
295
117
  end
296
118
 
297
- protected
119
+ private
120
+
121
+ def set_environment_variables
122
+ @options[:env_vars].each do |var, value|
123
+ ENV[var] = value
124
+ end
125
+ end
298
126
 
299
127
  def arrange_formats
300
128
  @options[:formats] << ['pretty', @out_stream] if @options[:formats].empty?
@@ -309,11 +137,11 @@ module Cucumber
309
137
  end
310
138
 
311
139
  def feature_dirs
312
- @paths.map { |f| File.directory?(f) ? f : File.dirname(f) }.uniq
140
+ paths.map { |f| File.directory?(f) ? f : File.dirname(f) }.uniq
313
141
  end
314
142
 
315
143
  def require_dirs
316
- feature_dirs+Dir['vendor/{gems,plugins}/*/cucumber']
144
+ feature_dirs + Dir['vendor/{gems,plugins}/*/cucumber']
317
145
  end
318
146
 
319
147
  def constantize(camel_cased_word)
@@ -341,90 +169,6 @@ module Cucumber
341
169
  downcase
342
170
  end
343
171
 
344
- def expand_profiles_into_args
345
- while (profile_index = @args.index(PROFILE_SHORT_FLAG) || @args.index(PROFILE_LONG_FLAG)) do
346
- @args.delete_at(profile_index)
347
- @args[profile_index] = args_from_profile(@args[profile_index])
348
- @args.flatten!
349
- end
350
- end
351
-
352
- def args_from_profile(profile)
353
- unless cucumber_yml.has_key?(profile)
354
- raise(<<-END_OF_ERROR)
355
- Could not find profile: '#{profile}'
356
-
357
- Defined profiles in cucumber.yml:
358
- * #{cucumber_yml.keys.join("\n * ")}
359
- END_OF_ERROR
360
- end
361
-
362
- args_from_yml = cucumber_yml[profile] || ''
363
-
364
- case(args_from_yml)
365
- when String
366
- raise "The '#{profile}' profile in cucumber.yml was blank. Please define the command line arguments for the '#{profile}' profile in cucumber.yml.\n" if args_from_yml =~ /^\s*$/
367
- args_from_yml = args_from_yml.split(' ')
368
- when Array
369
- raise "The '#{profile}' profile in cucumber.yml was empty. Please define the command line arguments for the '#{profile}' profile in cucumber.yml.\n" if args_from_yml.empty?
370
- else
371
- raise "The '#{profile}' profile in cucumber.yml was a #{args_from_yml.class}. It must be a String or Array"
372
- end
373
- args_from_yml
374
- end
375
-
376
- def cucumber_yml
377
- return @cucumber_yml if @cucumber_yml
378
- unless File.exist?('cucumber.yml')
379
- raise(YmlLoadError,"cucumber.yml was not found. Please refer to cucumber's documentation on defining profiles in cucumber.yml. You must define a 'default' profile to use the cucumber command without any arguments.\nType 'cucumber --help' for usage.\n")
380
- end
381
-
382
- require 'yaml'
383
- begin
384
- @cucumber_yml = YAML::load(IO.read('cucumber.yml'))
385
- rescue StandardError => e
386
- raise(YmlLoadError,"cucumber.yml was found, but could not be parsed. Please refer to cucumber's documentation on correct profile usage.\n")
387
- end
388
-
389
- if @cucumber_yml.nil? || !@cucumber_yml.is_a?(Hash)
390
- raise(YmlLoadError,"cucumber.yml was found, but was blank or malformed. Please refer to cucumber's documentation on correct profile usage.\n")
391
- end
392
-
393
- return @cucumber_yml
394
- end
395
-
396
- # TODO: Move to Language
397
- def list_keywords_and_exit(lang)
398
- unless Cucumber::LANGUAGES[lang]
399
- raise("No language with key #{lang}")
400
- end
401
- LanguageHelpFormatter.list_keywords(@out_stream, lang)
402
- Kernel.exit
403
- end
404
-
405
- def list_languages_and_exit
406
- LanguageHelpFormatter.list_languages(@out_stream)
407
- Kernel.exit
408
- end
409
-
410
- def parse_drb
411
- @drb = @args.delete(DRB_FLAG) ? true : false
412
- end
413
-
414
- def default_options
415
- {
416
- :strict => false,
417
- :require => nil,
418
- :lang => nil,
419
- :dry_run => false,
420
- :formats => [],
421
- :excludes => [],
422
- :include_tags => [],
423
- :exclude_tags => [],
424
- :name_regexps => [],
425
- :diff_enabled => true
426
- }
427
- end
428
172
  end
429
173
 
430
174
  end