cucumber 1.2.5 → 1.3.0

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 (110) hide show
  1. checksums.yaml +14 -6
  2. data/.ruby-gemset +1 -0
  3. data/.ruby-version +1 -0
  4. data/.travis.yml +1 -0
  5. data/.yardopts +1 -0
  6. data/CONTRIBUTING.md +2 -2
  7. data/History.md +38 -2
  8. data/bin/cucumber +2 -11
  9. data/cucumber.gemspec +3 -3
  10. data/cucumber.yml +5 -1
  11. data/examples/test_unit/Gemfile +4 -0
  12. data/examples/test_unit/features/step_definitions/test_unit_steps.rb +1 -4
  13. data/examples/watir/README.textile +2 -2
  14. data/examples/watir/features/support/env.rb +10 -7
  15. data/features/.cucumber/stepdefs.json +747 -1354
  16. data/features/assertions.feature +6 -2
  17. data/features/background.feature +3 -0
  18. data/features/backtraces.feature +3 -3
  19. data/features/before_hook.feature +43 -0
  20. data/features/bootstrap.feature +14 -2
  21. data/features/custom_formatter.feature +1 -1
  22. data/features/drb_server_integration.feature +3 -3
  23. data/features/formatter_callbacks.feature +2 -2
  24. data/features/formatter_step_file_colon_line.feature +1 -1
  25. data/features/html_formatter.feature +52 -1
  26. data/features/json_formatter.feature +93 -7
  27. data/features/load_path.feature +14 -0
  28. data/features/nested_steps.feature +75 -3
  29. data/features/nested_steps_i18n.feature +36 -0
  30. data/features/pretty_formatter.feature +31 -0
  31. data/features/progress_formatter.feature +31 -0
  32. data/features/raketask.feature +51 -0
  33. data/features/rerun_formatter.feature +1 -1
  34. data/features/stats_formatters.feature +17 -14
  35. data/features/step_definitions/cucumber_steps.rb +6 -4
  36. data/features/support/env.rb +31 -4
  37. data/features/support/feature_factory.rb +17 -0
  38. data/features/tagged_hooks.feature +37 -195
  39. data/features/transforms.feature +15 -15
  40. data/gem_tasks/cucumber.rake +2 -0
  41. data/gem_tasks/yard.rake +10 -6
  42. data/legacy_features/README.md +14 -0
  43. data/legacy_features/language_help.feature +3 -1
  44. data/legacy_features/report_called_undefined_steps.feature +1 -0
  45. data/legacy_features/snippets_when_using_star_keyword.feature +1 -0
  46. data/legacy_features/support/env.rb +4 -0
  47. data/lib/cucumber/ast/background.rb +35 -35
  48. data/lib/cucumber/ast/empty_background.rb +33 -0
  49. data/lib/cucumber/ast/examples.rb +5 -2
  50. data/lib/cucumber/ast/feature.rb +24 -35
  51. data/lib/cucumber/ast/features.rb +4 -1
  52. data/lib/cucumber/ast/has_steps.rb +9 -17
  53. data/lib/cucumber/ast/location.rb +41 -0
  54. data/lib/cucumber/ast/scenario.rb +37 -50
  55. data/lib/cucumber/ast/scenario_outline.rb +62 -49
  56. data/lib/cucumber/ast/step.rb +23 -27
  57. data/lib/cucumber/ast/step_collection.rb +16 -0
  58. data/lib/cucumber/ast/step_invocation.rb +4 -1
  59. data/lib/cucumber/ast/tree_walker.rb +7 -0
  60. data/lib/cucumber/cli/configuration.rb +15 -3
  61. data/lib/cucumber/cli/main.rb +24 -11
  62. data/lib/cucumber/cli/options.rb +24 -16
  63. data/lib/cucumber/configuration.rb +4 -0
  64. data/lib/cucumber/core_ext/disable_mini_and_test_unit_autorun.rb +10 -34
  65. data/lib/cucumber/core_ext/instance_exec.rb +4 -1
  66. data/lib/cucumber/core_ext/proc.rb +2 -0
  67. data/lib/cucumber/feature_file.rb +5 -12
  68. data/lib/cucumber/formatter/console.rb +10 -0
  69. data/lib/cucumber/formatter/gherkin_formatter_adapter.rb +4 -4
  70. data/lib/cucumber/formatter/html.rb +7 -42
  71. data/lib/cucumber/formatter/interceptor.rb +4 -0
  72. data/lib/cucumber/formatter/json_pretty.rb +0 -4
  73. data/lib/cucumber/formatter/junit.rb +8 -2
  74. data/lib/cucumber/formatter/pretty.rb +5 -1
  75. data/lib/cucumber/formatter/progress.rb +4 -0
  76. data/lib/cucumber/formatter/unicode.rb +12 -25
  77. data/lib/cucumber/formatter/usage.rb +7 -2
  78. data/lib/cucumber/js_support/js_snippets.rb +1 -1
  79. data/lib/cucumber/load_path.rb +13 -0
  80. data/lib/cucumber/parser/gherkin_builder.rb +237 -81
  81. data/lib/cucumber/platform.rb +1 -1
  82. data/lib/cucumber/py_support/py_language.rb +1 -1
  83. data/lib/cucumber/rake/task.rb +5 -1
  84. data/lib/cucumber/rb_support/rb_language.rb +20 -19
  85. data/lib/cucumber/rb_support/rb_world.rb +63 -21
  86. data/lib/cucumber/rb_support/snippet.rb +108 -0
  87. data/lib/cucumber/runtime.rb +1 -0
  88. data/lib/cucumber/runtime/support_code.rb +2 -2
  89. data/lib/cucumber/unit.rb +11 -0
  90. data/lib/cucumber/wire_support/wire_language.rb +1 -1
  91. data/spec/cucumber/ast/background_spec.rb +13 -6
  92. data/spec/cucumber/ast/feature_factory.rb +20 -10
  93. data/spec/cucumber/ast/features_spec.rb +51 -0
  94. data/spec/cucumber/ast/scenario_outline_spec.rb +13 -7
  95. data/spec/cucumber/ast/step_spec.rb +6 -4
  96. data/spec/cucumber/cli/configuration_spec.rb +34 -1
  97. data/spec/cucumber/cli/main_spec.rb +36 -26
  98. data/spec/cucumber/cli/options_spec.rb +28 -19
  99. data/spec/cucumber/core_ext/proc_spec.rb +13 -1
  100. data/spec/cucumber/formatter/interceptor_spec.rb +8 -0
  101. data/spec/cucumber/formatter/junit_spec.rb +33 -0
  102. data/spec/cucumber/formatter/pretty_spec.rb +391 -0
  103. data/spec/cucumber/rb_support/rb_language_spec.rb +21 -50
  104. data/spec/cucumber/rb_support/regexp_argument_matcher_spec.rb +2 -4
  105. data/spec/cucumber/rb_support/snippet_spec.rb +128 -0
  106. data/spec/cucumber/step_match_spec.rb +2 -6
  107. metadata +62 -113
  108. data/.rvmrc +0 -1
  109. data/features/hooks.feature +0 -59
  110. data/legacy_features/call_steps_from_stepdefs.feature +0 -154
@@ -26,14 +26,25 @@ module Cucumber
26
26
  %w{4444 55555 666666}
27
27
  ])
28
28
  doc_string = Ast::DocString.new(%{\n I like\nCucumber sandwich\n}, '')
29
+ location = Ast::Location.new('foo.feature', 2)
30
+ language = stub.as_null_object
29
31
 
30
- background = Ast::Background.new(Ast::Comment.new(""), 2, "Background:", "", "",
32
+ background = Ast::Background.new(
33
+ language,
34
+ location,
35
+ Ast::Comment.new(""),
36
+ "Background:",
37
+ "",
38
+ "",
31
39
  [
32
- Step.new(3, "Given", "a passing step")
40
+ Step.new(language, location.on_line(3), "Given", "a passing step")
33
41
  ]
34
42
  )
35
43
 
36
- f = Ast::Feature.new(
44
+ location = Location.new('features/pretty_printing.feature', 0)
45
+
46
+ Ast::Feature.new(
47
+ location,
37
48
  background,
38
49
  Ast::Comment.new("# My feature comment\n"),
39
50
  Ast::Tags.new(6, [Gherkin::Formatter::Model::Tag.new('one', 6), Gherkin::Formatter::Model::Tag.new('two', 6)]),
@@ -41,21 +52,20 @@ module Cucumber
41
52
  "Pretty printing",
42
53
  "",
43
54
  [Ast::Scenario.new(
55
+ language,
56
+ location.on_line(9),
44
57
  background,
45
58
  Ast::Comment.new(" # My scenario comment \n# On two lines \n"),
46
59
  Ast::Tags.new(8, [Gherkin::Formatter::Model::Tag.new('three', 8), Gherkin::Formatter::Model::Tag.new('four', 8)]),
47
- 9,
60
+ Ast::Tags.new(1, []),
48
61
  "Scenario:", "A Scenario", "",
49
62
  [
50
- Step.new(10, "Given", "a passing step with an inline arg:", table),
51
- Step.new(11, "Given", "a happy step with an inline arg:", doc_string),
52
- Step.new(12, "Given", "a failing step")
63
+ Step.new(language, location.on_line(10), "Given", "a passing step with an inline arg:", table),
64
+ Step.new(language, location.on_line(11), "Given", "a happy step with an inline arg:", doc_string),
65
+ Step.new(language, location.on_line(12), "Given", "a failing step")
53
66
  ]
54
67
  )]
55
68
  )
56
- f.file = 'features/pretty_printing.feature'
57
- f.features = Features.new
58
- f
59
69
  end
60
70
  end
61
71
  end
@@ -0,0 +1,51 @@
1
+ require 'spec_helper'
2
+ require 'cucumber/ast/feature_factory'
3
+
4
+ module Cucumber
5
+ module Ast
6
+ describe Features do
7
+ it "has a step_count" do
8
+ parse_feature(<<-GHERKIN)
9
+ Feature:
10
+ Background:
11
+ Given step 1
12
+ And step 2
13
+
14
+ Scenario:
15
+ Given step 3
16
+ And step 4
17
+ And step 5
18
+
19
+ Scenario Outline:
20
+ Given step <n>
21
+ And another step
22
+
23
+ Examples:
24
+ | n |
25
+ | 6 |
26
+ | 7 |
27
+
28
+ Examples:
29
+ | n |
30
+ | 8 |
31
+ GHERKIN
32
+
33
+ features.step_count.should == (2 + 3) + (3 * (2 + 2))
34
+ end
35
+
36
+ def parse_feature(gherkin)
37
+ path = 'features/test.feature'
38
+ builder = Cucumber::Parser::GherkinBuilder.new(path)
39
+ parser = Gherkin::Parser::Parser.new(builder, true, "root", false)
40
+ parser.parse(gherkin, path, 0)
41
+ builder.language = parser.i18n_language
42
+ feature = builder.result
43
+ features.add_feature(feature)
44
+ end
45
+
46
+ let(:features) { Features.new }
47
+
48
+ end
49
+ end
50
+ end
51
+
@@ -26,23 +26,28 @@ module Cucumber
26
26
  @eaten.should == n.to_i
27
27
  end
28
28
 
29
+ location = Ast::Location.new('foo.feature', 19)
30
+ language = stub
31
+
29
32
  @scenario_outline = ScenarioOutline.new(
30
- background=nil,
33
+ language,
34
+ location,
35
+ background=Ast::EmptyBackground.new,
31
36
  Comment.new(""),
32
37
  Tags.new(18, []),
33
- 19,
38
+ Tags.new(0, []),
34
39
  "Scenario:", "My outline", "",
35
40
  [
36
- Step.new(20, 'Given', 'there are <start> cucumbers'),
37
- Step.new(21, 'When', 'I eat <eat> cucumbers'),
38
- Step.new(22, 'Then', 'I should have <left> cucumbers'),
39
- Step.new(23, 'And', 'I should have <eat> cucumbers in my belly')
41
+ Step.new(language, location.on_line(20), 'Given', 'there are <start> cucumbers'),
42
+ Step.new(language, location.on_line(21), 'When', 'I eat <eat> cucumbers'),
43
+ Step.new(language, location.on_line(22), 'Then', 'I should have <left> cucumbers'),
44
+ Step.new(language, location.on_line(23), 'And', 'I should have <eat> cucumbers in my belly')
40
45
  ],
41
46
  [
42
47
  [
43
48
  [
49
+ location.on_line(24),
44
50
  Comment.new("#Mmmm... cucumbers\n"),
45
- 24,
46
51
  'Examples:',
47
52
  'First table',
48
53
  '',
@@ -61,6 +66,7 @@ module Cucumber
61
66
  it "should replace all variables and call outline once for each table row" do
62
67
  visitor = TreeWalker.new(@step_mother)
63
68
  visitor.should_receive(:visit_table_row).exactly(3).times
69
+ @scenario_outline.feature = stub.as_null_object
64
70
  visitor.visit_feature_element(@scenario_outline)
65
71
  end
66
72
  end
@@ -6,8 +6,10 @@ require 'cucumber/core_ext/string'
6
6
  module Cucumber
7
7
  module Ast
8
8
  describe Step do
9
+ let(:language) { stub }
10
+
9
11
  it "should replace arguments in name" do
10
- step = Step.new(1, 'Given', 'a <color> cucumber')
12
+ step = Step.new(language, 1, 'Given', 'a <color> cucumber')
11
13
 
12
14
  invocation_table = Table.new([
13
15
  %w{color taste},
@@ -20,7 +22,7 @@ module Cucumber
20
22
  end
21
23
 
22
24
  it "should use empty string for the replacement of arguments in name when replace value is nil" do
23
- step = Step.new(1, 'Given', 'a <color>cucumber')
25
+ step = Step.new(language, 1, 'Given', 'a <color>cucumber')
24
26
 
25
27
  invocation_table = Table.new([
26
28
  ['color'],
@@ -35,7 +37,7 @@ module Cucumber
35
37
  it "should replace arguments in table arg" do
36
38
  arg_table = Table.new([%w{taste_<taste> color_<color>}])
37
39
 
38
- step = Step.new(1, 'Given', 'a <color> cucumber', arg_table)
40
+ step = Step.new(language, 1, 'Given', 'a <color> cucumber', arg_table)
39
41
 
40
42
  invocation_table = Table.new([
41
43
  %w{color taste},
@@ -50,7 +52,7 @@ module Cucumber
50
52
  it "should replace arguments in py string arg" do
51
53
  doc_string = DocString.new('taste_<taste> color_<color>', '')
52
54
 
53
- step = Step.new(1, 'Given', 'a <color> cucumber', doc_string)
55
+ step = Step.new(language, 1, 'Given', 'a <color> cucumber', doc_string)
54
56
 
55
57
  invocation_table = Table.new([
56
58
  %w{color taste},
@@ -127,6 +127,7 @@ module Cli
127
127
  end
128
128
 
129
129
  context '--profile' do
130
+ include RSpec::WorkInProgress
130
131
 
131
132
  it "expands args from profiles in the cucumber.yml file" do
132
133
  given_cucumber_yml_defined_as({'bongo' => '--require from/yml'})
@@ -151,7 +152,7 @@ module Cli
151
152
  end
152
153
 
153
154
  it "parses ERB syntax in the cucumber.yml file" do
154
- given_cucumber_yml_defined_as 'default' => "<%= '--require some_file' %>"
155
+ given_cucumber_yml_defined_as("---\ndefault: \"<%=\"--require some_file\"%>\"\n")
155
156
 
156
157
  config.parse!([])
157
158
  config.options[:require].should include('some_file')
@@ -309,6 +310,11 @@ END_OF_MESSAGE
309
310
  end.should raise_error("All but one formatter must use --out, only one can print to each stream (or STDOUT)")
310
311
  end
311
312
 
313
+ it "should accept same --format options with implicit STDOUT, and keep only one" do
314
+ config.parse!(%w{--format pretty --format pretty})
315
+ config.formats.should == [["pretty", out]]
316
+ end
317
+
312
318
  it "should not accept multiple --out streams pointing to the same place" do
313
319
  lambda do
314
320
  config.parse!(%w{--format pretty --out file1 --format progress --out file1})
@@ -320,6 +326,16 @@ END_OF_MESSAGE
320
326
  config.formats.should == [["progress", "file1"], ["profile" ,"file2"]]
321
327
  end
322
328
 
329
+ it "should accept same --format options with same --out streams and keep only one" do
330
+ config.parse!(%w{--format html --out file --format pretty --format html --out file})
331
+ config.formats.should == [["pretty", out], ["html", "file"]]
332
+ end
333
+
334
+ it "should accept same --format options with different --out streams" do
335
+ config.parse!(%w{--format html --out file1 --format html --out file2})
336
+ config.formats.should == [["html", "file1"], ["html", "file2"]]
337
+ end
338
+
323
339
  it "should accept --color option" do
324
340
  Cucumber::Term::ANSIColor.should_receive(:coloring=).with(true)
325
341
  config.parse!(['--color'])
@@ -434,6 +450,23 @@ END_OF_MESSAGE
434
450
  config.dry_run?.should be_false
435
451
  end
436
452
  end
453
+
454
+ describe "#snippet_type" do
455
+ it "returns the snippet type when it was set" do
456
+ config.parse!(["--snippet-type", "classic"])
457
+ config.snippet_type.should eql :classic
458
+ end
459
+
460
+ it "returns the snippet type when it was set with shorthand option" do
461
+ config.parse!(["-I", "classic"])
462
+ config.snippet_type.should eql :classic
463
+ end
464
+
465
+ it "returns the default snippet type if it was not set" do
466
+ config.parse!([])
467
+ config.snippet_type.should eql :regexp
468
+ end
469
+ end
437
470
  end
438
471
  end
439
472
  end
@@ -7,17 +7,16 @@ module Cucumber
7
7
  module Cli
8
8
  describe Main do
9
9
  before(:each) do
10
- @out = StringIO.new
11
- @err = StringIO.new
12
- Kernel.stub!(:exit).and_return(nil)
13
10
  File.stub!(:exist?).and_return(false) # When Configuration checks for cucumber.yml
14
11
  Dir.stub!(:[]).and_return([]) # to prevent cucumber's features dir to being laoded
15
12
  end
16
13
 
17
- let(:args) { [] }
18
- let(:out_stream) { nil }
19
- let(:err_stream) { nil }
20
- subject { Main.new(args, out_stream, err_stream)}
14
+ let(:args) { [] }
15
+ let(:stdin) { StringIO.new }
16
+ let(:stdout) { StringIO.new }
17
+ let(:stderr) { StringIO.new }
18
+ let(:kernel) { mock(:kernel) }
19
+ subject { Main.new(args, stdin, stdout, stderr, kernel)}
21
20
 
22
21
  describe "#execute!" do
23
22
  context "passed an existing runtime" do
@@ -31,6 +30,7 @@ module Cucumber
31
30
  expected_configuration = double('Configuration', :drb? => false).as_null_object
32
31
  Configuration.stub!(:new => expected_configuration)
33
32
  existing_runtime.should_receive(:configure).with(expected_configuration)
33
+ kernel.should_receive(:exit).with(1)
34
34
  do_execute
35
35
  end
36
36
 
@@ -38,7 +38,8 @@ module Cucumber
38
38
  expected_results = double('results', :failure? => true)
39
39
  existing_runtime.should_receive(:run!)
40
40
  existing_runtime.stub!(:results).and_return(expected_results)
41
- do_execute.should == expected_results.failure?
41
+ kernel.should_receive(:exit).with(1)
42
+ do_execute
42
43
  end
43
44
  end
44
45
 
@@ -54,7 +55,8 @@ module Cucumber
54
55
  runtime.stub(:results).and_return(results)
55
56
 
56
57
  Cucumber.wants_to_quit = true
57
- subject.execute!.should be_true
58
+ kernel.should_receive(:exit).with(1)
59
+ subject.execute!
58
60
  end
59
61
  end
60
62
  end
@@ -62,19 +64,22 @@ module Cucumber
62
64
  describe "verbose mode" do
63
65
 
64
66
  before(:each) do
65
- b = Cucumber::Parser::GherkinBuilder.new
66
- @empty_feature = b.feature(Gherkin::Formatter::Model::Feature.new([], [], "Feature", "Foo", "", 99, ""))
67
+ b = Cucumber::Parser::GherkinBuilder.new('features/foo.feature')
68
+ b.feature(Gherkin::Formatter::Model::Feature.new([], [], "Feature", "Foo", "", 99, ""))
69
+ b.language = stub
70
+ @empty_feature = b.result
67
71
  end
68
72
 
69
73
  it "should show feature files parsed" do
70
- @cli = Main.new(%w{--verbose example.feature}, @out)
71
- @cli.stub!(:require)
74
+ cli = Main.new(%w{--verbose example.feature}, stdin, stdout, stderr, kernel)
75
+ cli.stub!(:require)
72
76
 
73
77
  Cucumber::FeatureFile.stub!(:new).and_return(mock("feature file", :parse => @empty_feature))
74
78
 
75
- @cli.execute!
79
+ kernel.should_receive(:exit).with(0)
80
+ cli.execute!
76
81
 
77
- @out.string.should include('example.feature')
82
+ stdout.string.should include('example.feature')
78
83
  end
79
84
 
80
85
  end
@@ -82,7 +87,7 @@ module Cucumber
82
87
  describe "--format with class" do
83
88
  describe "in module" do
84
89
  it "should resolve each module until it gets Formatter class" do
85
- cli = Main.new(%w{--format ZooModule::MonkeyFormatterClass}, nil)
90
+ cli = Main.new(%w{--format ZooModule::MonkeyFormatterClass}, stdin, stdout, stderr, kernel)
86
91
  mock_module = mock('module')
87
92
  Object.stub!(:const_defined?).and_return(true)
88
93
  mock_module.stub!(:const_defined?).and_return(true)
@@ -97,6 +102,7 @@ module Cucumber
97
102
  mock_module.should_receive(:const_get).with('MonkeyFormatterClass', false).and_return(mock('formatter class', :new => f))
98
103
  end
99
104
 
105
+ kernel.should_receive(:exit).with(0)
100
106
  cli.execute!
101
107
  end
102
108
  end
@@ -104,13 +110,12 @@ module Cucumber
104
110
 
105
111
  [ProfilesNotDefinedError, YmlLoadError, ProfileNotFound].each do |exception_klass|
106
112
 
107
- it "rescues #{exception_klass}, prints the message to the error stream and returns true" do
113
+ it "rescues #{exception_klass}, prints the message to the error stream" do
108
114
  Configuration.stub!(:new).and_return(configuration = mock('configuration'))
109
115
  configuration.stub!(:parse!).and_raise(exception_klass.new("error message"))
110
116
 
111
- main = Main.new('', out = StringIO.new, error = StringIO.new)
112
- main.execute!.should be_true
113
- error.string.should == "error message\n"
117
+ subject.execute!
118
+ stderr.string.should == "error message\n"
114
119
  end
115
120
  end
116
121
 
@@ -119,16 +124,20 @@ module Cucumber
119
124
  @configuration = mock('Configuration', :drb? => true, :dotcucumber => false).as_null_object
120
125
  Configuration.stub!(:new).and_return(@configuration)
121
126
 
122
- @args = ['features']
127
+ args = ['features']
123
128
 
124
- @cli = Main.new(@args, @out, @err)
125
- @step_mother = mock('StepMother').as_null_object
126
- StepMother.stub!(:new).and_return(@step_mother)
129
+ step_mother = mock('StepMother').as_null_object
130
+ StepMother.stub!(:new).and_return(step_mother)
131
+
132
+ @cli = Main.new(args, stdin, stdout, stderr, kernel)
127
133
  end
128
134
 
129
135
  it "delegates the execution to the DRB client passing the args and streams" do
130
136
  @configuration.stub :drb_port => 1450
131
- DRbClient.should_receive(:run).with(@args, @err, @out, 1450).and_return(true)
137
+ DRbClient.should_receive(:run) do
138
+ kernel.exit(1)
139
+ end
140
+ kernel.should_receive(:exit).with(1)
132
141
  @cli.execute!
133
142
  end
134
143
 
@@ -147,8 +156,9 @@ module Cucumber
147
156
  before { DRbClient.stub!(:run).and_raise(DRbClientError.new('error message.')) }
148
157
 
149
158
  it "alerts the user that execution will be performed locally" do
159
+ kernel.should_receive(:exit).with(1)
150
160
  @cli.execute!
151
- @err.string.should include("WARNING: error message. Running features locally:")
161
+ stderr.string.should include("WARNING: error message. Running features locally:")
152
162
  end
153
163
 
154
164
  end
@@ -123,25 +123,6 @@ module Cli
123
123
 
124
124
  context '-p PROFILE or --profile PROFILE' do
125
125
 
126
- it "notifies the user that an individual profile is being used" do
127
- given_cucumber_yml_defined_as({'foo' => [1,2,3]})
128
- options.parse!(%w{--profile foo})
129
- output_stream.string.should =~ /Using the foo profile...\n/
130
- end
131
-
132
- it "notifies the user when multiple profiles are being used" do
133
- given_cucumber_yml_defined_as({'foo' => [1,2,3], 'bar' => ['v'], 'dog' => ['v']})
134
- options.parse!(%w{--profile foo --profile bar --profile dog})
135
- output_stream.string.should =~ /Using the foo, bar and dog profiles...\n/
136
- end
137
-
138
- it "notifies the user of all profiles being used, even when they are nested" do
139
- given_cucumber_yml_defined_as('foo' => '-p bar', 'bar' => 'features')
140
- after_parsing('-p foo') do
141
- output_stream.string.should =~ /Using the foo and bar profiles.../
142
- end
143
- end
144
-
145
126
  it "uses the default profile passed in during initialization if none are specified by the user" do
146
127
  given_cucumber_yml_defined_as({'default' => '--require some_file'})
147
128
 
@@ -223,6 +204,25 @@ module Cli
223
204
  options[:formats].should == [['progress', output_stream], ['html', 'features.html']]
224
205
  end
225
206
 
207
+ it "only reads cucumber.yml once" do
208
+ original_parse_count = $cucumber_yml_read_count
209
+ $cucumber_yml_read_count = 0
210
+
211
+ begin
212
+ given_cucumber_yml_defined_as(<<-END
213
+ <% $cucumber_yml_read_count += 1 %>
214
+ default: --format pretty
215
+ END
216
+ )
217
+ options = Options.new(output_stream, error_stream, :default_profile => 'default')
218
+ options.parse!(%w(-f progress))
219
+
220
+ $cucumber_yml_read_count.should == 1
221
+ ensure
222
+ $cucumber_yml_read_count = original_parse_count
223
+ end
224
+ end
225
+
226
226
  it "respects --quiet when defined in the profile" do
227
227
  given_cucumber_yml_defined_as('foo' => '-q')
228
228
  options.parse!(%w[-p foo])
@@ -289,6 +289,15 @@ module Cli
289
289
  options[:paths].should == ['my_feature.feature']
290
290
  end
291
291
  end
292
+
293
+ context '--snippet-type' do
294
+ it "parses the snippet type argument" do
295
+ after_parsing('--snippet-type classic') do
296
+ options[:snippet_type].should eql :classic
297
+ end
298
+ end
299
+ end
300
+
292
301
  end
293
302
 
294
303
  describe '#expanded_args_without_drb' do