cucumber 0.8.6 → 0.8.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (180) hide show
  1. data/.rspec +1 -1
  2. data/Caliper.yml +4 -0
  3. data/History.txt +1557 -0
  4. data/LICENSE +1 -1
  5. data/README.rdoc +26 -0
  6. data/Rakefile +51 -5
  7. data/VERSION.yml +5 -0
  8. data/bin/cucumber +1 -7
  9. data/cucumber.gemspec +77 -3
  10. data/examples/i18n/ar/features/step_definitons/calculator_steps.rb +1 -1
  11. data/examples/i18n/he/features/step_definitons/calculator_steps.rb +1 -1
  12. data/examples/i18n/ro/features/step_definitons/calculator_steps.rb +7 -4
  13. data/examples/i18n/ro/features/suma.feature +11 -0
  14. data/examples/i18n/ru/features/division.feature +2 -2
  15. data/examples/i18n/tr/features/step_definitons/hesap_makinesi_adimlari.rb +3 -3
  16. data/examples/sinatra/features/support/env.rb +5 -2
  17. data/examples/v8/features/fibonacci.feature +1 -1
  18. data/examples/watir/features/step_definitions/search_steps.rb +1 -1
  19. data/features/announce.feature +164 -0
  20. data/features/around_hooks.feature +232 -0
  21. data/features/background.feature +95 -284
  22. data/features/bug_371.feature +32 -0
  23. data/features/bug_464.feature +16 -0
  24. data/features/bug_475.feature +42 -0
  25. data/features/bug_585_tab_indentation.feature +22 -0
  26. data/features/bug_600.feature +67 -0
  27. data/features/call_steps_from_stepdefs.feature +154 -0
  28. data/features/cucumber_cli.feature +591 -0
  29. data/features/cucumber_cli_outlines.feature +117 -0
  30. data/features/custom_formatter.feature +73 -3
  31. data/features/default_snippets.feature +42 -0
  32. data/features/diffing.feature +25 -0
  33. data/features/drb_server_integration.feature +174 -0
  34. data/features/exception_in_after_block.feature +127 -0
  35. data/features/exception_in_after_step_block.feature +104 -0
  36. data/features/exception_in_before_block.feature +98 -0
  37. data/features/exclude_files.feature +20 -0
  38. data/features/expand.feature +60 -0
  39. data/features/html_formatter.feature +8 -0
  40. data/features/html_formatter/a.html +582 -0
  41. data/features/json_formatter.feature +245 -160
  42. data/features/junit_formatter.feature +88 -0
  43. data/features/language_from_header.feature +30 -0
  44. data/features/language_help.feature +78 -0
  45. data/features/listener_debugger_formatter.feature +42 -0
  46. data/features/multiline_names.feature +44 -0
  47. data/features/negative_tagged_hooks.feature +60 -0
  48. data/features/post_configuration_hook.feature +37 -0
  49. data/features/profiles.feature +126 -0
  50. data/features/rake_task.feature +152 -0
  51. data/features/report_called_undefined_steps.feature +34 -0
  52. data/features/rerun_formatter.feature +45 -0
  53. data/features/simplest.feature +11 -0
  54. data/features/snippet.feature +23 -0
  55. data/features/snippets_when_using_star_keyword.feature +36 -0
  56. data/features/step_definitions/cucumber_steps.rb +153 -7
  57. data/features/step_definitions/extra_steps.rb +2 -0
  58. data/features/step_definitions/simplest_steps.rb +3 -0
  59. data/features/step_definitions/wire_steps.rb +32 -0
  60. data/features/support/env.rb +140 -18
  61. data/features/support/env.rb.simplest +7 -0
  62. data/features/support/fake_wire_server.rb +77 -0
  63. data/features/table_diffing.feature +45 -0
  64. data/features/table_mapping.feature +34 -0
  65. data/features/tag_logic.feature +258 -0
  66. data/features/transform.feature +245 -0
  67. data/features/unicode_table.feature +35 -0
  68. data/features/usage_and_stepdefs_formatter.feature +169 -0
  69. data/features/wire_protocol.feature +332 -0
  70. data/features/wire_protocol_table_diffing.feature +119 -0
  71. data/features/wire_protocol_tags.feature +87 -0
  72. data/features/wire_protocol_timeouts.feature +63 -0
  73. data/features/work_in_progress.feature +156 -0
  74. data/fixtures/json/features/pystring.feature +8 -0
  75. data/fixtures/junit/features/pending.feature +1 -3
  76. data/fixtures/self_test/features/background/background_tagged_before_on_outline.feature +12 -0
  77. data/fixtures/self_test/features/background/background_with_name.feature +7 -0
  78. data/fixtures/self_test/features/background/failing_background.feature +12 -0
  79. data/fixtures/self_test/features/background/failing_background_after_success.feature +11 -0
  80. data/fixtures/self_test/features/background/multiline_args_background.feature +32 -0
  81. data/fixtures/self_test/features/background/passing_background.feature +10 -0
  82. data/fixtures/self_test/features/background/pending_background.feature +10 -0
  83. data/fixtures/self_test/features/background/scenario_outline_failing_background.feature +16 -0
  84. data/fixtures/self_test/features/background/scenario_outline_passing_background.feature +16 -0
  85. data/fixtures/self_test/features/support/env.rb +0 -8
  86. data/fixtures/tickets/features.html +1 -1
  87. data/gem_tasks/examples.rake +1 -1
  88. data/gem_tasks/features.rake +14 -0
  89. data/gem_tasks/sdoc.rake +12 -0
  90. data/lib/cucumber.rb +0 -12
  91. data/lib/cucumber/ast.rb +1 -1
  92. data/lib/cucumber/ast/background.rb +5 -21
  93. data/lib/cucumber/ast/examples.rb +4 -12
  94. data/lib/cucumber/ast/feature.rb +5 -13
  95. data/lib/cucumber/ast/feature_element.rb +4 -9
  96. data/lib/cucumber/ast/outline_table.rb +4 -4
  97. data/lib/cucumber/ast/py_string.rb +80 -0
  98. data/lib/cucumber/ast/scenario.rb +5 -7
  99. data/lib/cucumber/ast/scenario_outline.rb +15 -23
  100. data/lib/cucumber/ast/step.rb +0 -5
  101. data/lib/cucumber/ast/step_invocation.rb +15 -21
  102. data/lib/cucumber/ast/table.rb +8 -14
  103. data/lib/cucumber/ast/tree_walker.rb +48 -10
  104. data/lib/cucumber/cli/configuration.rb +8 -33
  105. data/lib/cucumber/cli/main.rb +35 -20
  106. data/lib/cucumber/cli/options.rb +7 -8
  107. data/lib/cucumber/cli/profile_loader.rb +0 -2
  108. data/lib/cucumber/core_ext/proc.rb +1 -2
  109. data/lib/cucumber/feature_file.rb +15 -47
  110. data/lib/cucumber/formatter/ansicolor.rb +5 -3
  111. data/lib/cucumber/formatter/color_io.rb +23 -0
  112. data/lib/cucumber/formatter/console.rb +23 -27
  113. data/lib/cucumber/formatter/cucumber.css +17 -34
  114. data/lib/cucumber/formatter/cucumber.sass +182 -173
  115. data/lib/cucumber/formatter/html.rb +11 -46
  116. data/lib/cucumber/formatter/io.rb +4 -2
  117. data/lib/cucumber/formatter/json.rb +152 -15
  118. data/lib/cucumber/formatter/json_pretty.rb +6 -5
  119. data/lib/cucumber/formatter/junit.rb +22 -28
  120. data/lib/cucumber/formatter/pdf.rb +6 -6
  121. data/lib/cucumber/formatter/pretty.rb +5 -5
  122. data/lib/cucumber/formatter/rerun.rb +11 -22
  123. data/lib/cucumber/formatter/tag_cloud.rb +35 -0
  124. data/lib/cucumber/formatter/unicode.rb +20 -41
  125. data/lib/cucumber/js_support/js_dsl.js +4 -4
  126. data/lib/cucumber/js_support/js_language.rb +5 -9
  127. data/lib/cucumber/js_support/js_snippets.rb +2 -2
  128. data/lib/cucumber/language_support.rb +2 -2
  129. data/lib/cucumber/parser/gherkin_builder.rb +30 -35
  130. data/lib/cucumber/platform.rb +8 -8
  131. data/lib/cucumber/py_support/py_language.rb +2 -2
  132. data/lib/cucumber/rake/task.rb +31 -74
  133. data/lib/cucumber/rb_support/rb_dsl.rb +0 -1
  134. data/lib/cucumber/rb_support/rb_language.rb +8 -10
  135. data/lib/cucumber/rb_support/rb_step_definition.rb +0 -8
  136. data/lib/cucumber/rb_support/rb_transform.rb +0 -17
  137. data/lib/cucumber/rb_support/rb_world.rb +18 -26
  138. data/lib/cucumber/rspec/doubles.rb +3 -3
  139. data/lib/cucumber/step_match.rb +2 -6
  140. data/lib/cucumber/step_mother.rb +427 -6
  141. data/lib/cucumber/wire_support/configuration.rb +1 -4
  142. data/lib/cucumber/wire_support/wire_language.rb +10 -3
  143. data/spec/cucumber/ast/background_spec.rb +6 -68
  144. data/spec/cucumber/ast/feature_factory.rb +4 -5
  145. data/spec/cucumber/ast/feature_spec.rb +4 -4
  146. data/spec/cucumber/ast/outline_table_spec.rb +1 -1
  147. data/spec/cucumber/ast/py_string_spec.rb +40 -0
  148. data/spec/cucumber/ast/scenario_outline_spec.rb +11 -15
  149. data/spec/cucumber/ast/scenario_spec.rb +4 -4
  150. data/spec/cucumber/ast/step_spec.rb +3 -3
  151. data/spec/cucumber/ast/table_spec.rb +2 -38
  152. data/spec/cucumber/ast/tree_walker_spec.rb +2 -2
  153. data/spec/cucumber/broadcaster_spec.rb +1 -1
  154. data/spec/cucumber/cli/configuration_spec.rb +6 -32
  155. data/spec/cucumber/cli/drb_client_spec.rb +3 -2
  156. data/spec/cucumber/cli/main_spec.rb +43 -43
  157. data/spec/cucumber/cli/options_spec.rb +1 -28
  158. data/spec/cucumber/cli/profile_loader_spec.rb +1 -1
  159. data/spec/cucumber/core_ext/proc_spec.rb +1 -1
  160. data/spec/cucumber/formatter/ansicolor_spec.rb +1 -1
  161. data/spec/cucumber/formatter/color_io_spec.rb +29 -0
  162. data/spec/cucumber/formatter/duration_spec.rb +1 -1
  163. data/spec/cucumber/formatter/html_spec.rb +5 -3
  164. data/spec/cucumber/formatter/junit_spec.rb +2 -16
  165. data/spec/cucumber/formatter/progress_spec.rb +1 -1
  166. data/spec/cucumber/formatter/spec_helper.rb +12 -11
  167. data/spec/cucumber/rb_support/rb_language_spec.rb +28 -241
  168. data/spec/cucumber/rb_support/rb_step_definition_spec.rb +28 -33
  169. data/spec/cucumber/rb_support/regexp_argument_matcher_spec.rb +1 -1
  170. data/spec/cucumber/step_match_spec.rb +9 -11
  171. data/spec/cucumber/step_mother_spec.rb +302 -0
  172. data/spec/cucumber/wire_support/configuration_spec.rb +1 -1
  173. data/spec/cucumber/wire_support/connection_spec.rb +1 -1
  174. data/spec/cucumber/wire_support/wire_exception_spec.rb +1 -1
  175. data/spec/cucumber/wire_support/wire_language_spec.rb +1 -1
  176. data/spec/cucumber/wire_support/wire_packet_spec.rb +1 -1
  177. data/spec/cucumber/wire_support/wire_step_definition_spec.rb +1 -1
  178. data/spec/cucumber/world/pending_spec.rb +2 -2
  179. data/spec/spec_helper.rb +20 -13
  180. metadata +78 -4
@@ -1,12 +1,9 @@
1
- require 'spec_helper'
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
2
  require 'yaml'
3
3
 
4
4
  module Cucumber
5
5
  module Cli
6
6
  describe Configuration do
7
- module ExposesOptions
8
- attr_reader :options
9
- end
10
7
 
11
8
  def given_cucumber_yml_defined_as(hash_or_string)
12
9
  File.stub!(:exist?).and_return(true)
@@ -26,7 +23,7 @@ module Cli
26
23
  end
27
24
 
28
25
  def config
29
- @config ||= Configuration.new(@out = StringIO.new, @error = StringIO.new).extend(ExposesOptions)
26
+ @config ||= Configuration.new(@out = StringIO.new, @error = StringIO.new)
30
27
  end
31
28
 
32
29
  def reset_config
@@ -290,17 +287,17 @@ END_OF_MESSAGE
290
287
 
291
288
  it "should accept --out option" do
292
289
  config.parse!(%w{--out jalla.txt})
293
- config.formats.should == [['pretty', 'jalla.txt']]
290
+ config.options[:formats].should == [['pretty', 'jalla.txt']]
294
291
  end
295
292
 
296
293
  it "should accept multiple --out options" do
297
294
  config.parse!(%w{--format progress --out file1 --out file2})
298
- config.formats.should == [['progress', 'file2']]
295
+ config.options[:formats].should == [['progress', 'file2']]
299
296
  end
300
297
 
301
298
  it "should accept multiple --format options and put the STDOUT one first so progress is seen" do
302
299
  config.parse!(%w{--format pretty --out pretty.txt --format progress})
303
- config.formats.should == [['progress', out], ['pretty', 'pretty.txt']]
300
+ config.options[:formats].should == [['progress', out], ['pretty', 'pretty.txt']]
304
301
  end
305
302
 
306
303
  it "should not accept multiple --format options when both use implicit STDOUT" do
@@ -317,7 +314,7 @@ END_OF_MESSAGE
317
314
 
318
315
  it "should associate --out to previous --format" do
319
316
  config.parse!(%w{--format progress --out file1 --format profile --out file2})
320
- config.formats.should == [["progress", "file1"], ["profile" ,"file2"]]
317
+ config.options[:formats].should == [["progress", "file1"], ["profile" ,"file2"]]
321
318
  end
322
319
 
323
320
  it "should accept --color option" do
@@ -402,30 +399,7 @@ END_OF_MESSAGE
402
399
  ENV["RAILS_ENV"].should == "selenium"
403
400
  config.feature_files.should_not include('RAILS_ENV=selenium')
404
401
  end
405
-
406
- describe "#tag_expression" do
407
- it "returns an empty expression when no tags are specified" do
408
- config.parse!([])
409
- config.tag_expression.should be_empty
410
- end
411
402
 
412
- it "returns an expression when tags are specified" do
413
- config.parse!(['--tags','@foo'])
414
- config.tag_expression.should_not be_empty
415
- end
416
- end
417
-
418
- describe "#dry_run?" do
419
- it "returns true when --dry-run was specified on in the arguments" do
420
- config.parse!(['--dry-run'])
421
- config.dry_run?.should be_true
422
- end
423
-
424
- it "returns false by default" do
425
- config.parse!([])
426
- config.dry_run?.should be_false
427
- end
428
- end
429
403
  end
430
404
  end
431
405
  end
@@ -1,4 +1,5 @@
1
- require 'spec_helper'
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
2
3
 
3
4
  module Cucumber
4
5
  module Cli
@@ -29,7 +30,7 @@ module Cucumber
29
30
 
30
31
  it "returns raises an error when it can't connect to the server" do
31
32
  DRbObject.stub!(:new_with_uri).and_raise(DRb::DRbConnError)
32
- lambda { DRbClient.run(@args, @error_stream, @out_stream) }.should raise_error(DRbClientError, "No DRb server is running.")
33
+ running { DRbClient.run(@args, @error_stream, @out_stream) }.should raise_error(DRbClientError, "No DRb server is running.")
33
34
  end
34
35
 
35
36
  it "returns the result from the DRb server call" do
@@ -1,7 +1,5 @@
1
- require 'spec_helper'
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
2
  require 'yaml'
3
- require 'cucumber/parser/gherkin_builder'
4
- require 'gherkin/formatter/model'
5
3
 
6
4
  module Cucumber
7
5
  module Cli
@@ -13,41 +11,11 @@ module Cucumber
13
11
  File.stub!(:exist?).and_return(false) # When Configuration checks for cucumber.yml
14
12
  Dir.stub!(:[]).and_return([]) # to prevent cucumber's features dir to being laoded
15
13
  end
16
-
17
- let(:args) { [] }
18
- let(:out_stream) { nil }
19
- let(:err_stream) { nil }
20
- subject { Main.new(args, out_stream, err_stream)}
21
-
22
- describe "#execute!" do
23
- context "passed an existing runtime" do
24
- let(:existing_runtime) { double('runtime').as_null_object }
25
-
26
- def do_execute
27
- subject.execute!(existing_runtime)
28
- end
29
-
30
- it "configures that runtime" do
31
- expected_configuration = double('Configuration', :drb? => false).as_null_object
32
- Configuration.stub!(:new => expected_configuration)
33
- existing_runtime.should_receive(:configure).with(expected_configuration)
34
- do_execute
35
- end
36
-
37
- it "uses that runtime for running and reporting results" do
38
- expected_results = double('results', :failure? => true)
39
- existing_runtime.should_receive(:run!)
40
- existing_runtime.stub!(:results).and_return(expected_results)
41
- do_execute.should == expected_results.failure?
42
- end
43
- end
44
- end
45
14
 
46
15
  describe "verbose mode" do
47
16
 
48
17
  before(:each) do
49
- b = Cucumber::Parser::GherkinBuilder.new
50
- @empty_feature = b.feature(Gherkin::Formatter::Model::Feature.new([], [], "Feature", "Foo", "", 99))
18
+ @empty_feature = Cucumber::Ast::Feature.new(nil, Cucumber::Ast::Comment.new(''), Cucumber::Ast::Tags.new(2, []), "Feature", "Foo", [])
51
19
  end
52
20
 
53
21
  it "should show feature files parsed" do
@@ -56,7 +24,7 @@ module Cucumber
56
24
 
57
25
  Cucumber::FeatureFile.stub!(:new).and_return(mock("feature file", :parse => @empty_feature))
58
26
 
59
- @cli.execute!
27
+ @cli.execute!(Cucumber::StepMother.new)
60
28
 
61
29
  @out.string.should include('example.feature')
62
30
  end
@@ -64,7 +32,9 @@ module Cucumber
64
32
  end
65
33
 
66
34
  describe "--format with class" do
67
- describe "in module" do
35
+
36
+ describe "in module" do
37
+
68
38
  it "should resolve each module until it gets Formatter class" do
69
39
  cli = Main.new(%w{--format ZooModule::MonkeyFormatterClass}, nil)
70
40
  mock_module = mock('module')
@@ -76,11 +46,42 @@ module Cucumber
76
46
  Object.should_receive(:const_get).with('ZooModule').and_return(mock_module)
77
47
  mock_module.should_receive(:const_get).with('MonkeyFormatterClass').and_return(mock('formatter class', :new => f))
78
48
 
79
- cli.execute!
49
+ cli.execute!(Cucumber::StepMother.new)
80
50
  end
51
+
81
52
  end
82
53
  end
83
54
 
55
+ describe "setup step sequence" do
56
+
57
+ it "should load files and execute hooks in order" do
58
+ Configuration.stub!(:new).and_return(configuration = mock('configuration').as_null_object)
59
+ step_mother = mock('step mother').as_null_object
60
+ configuration.stub!(:drb?).and_return false
61
+ cli = Main.new(%w{--verbose example.feature}, @out)
62
+ cli.stub!(:require)
63
+
64
+ configuration.stub!(:support_to_load).and_return(['support'])
65
+ configuration.stub!(:step_defs_to_load).and_return(['step defs'])
66
+
67
+ # Support must be loaded first to ensure post configuration hook can
68
+ # run before anything else.
69
+ step_mother.should_receive(:load_code_files).with(['support']).ordered
70
+ # The post configuration hook/s (if any) need to be run next to enable
71
+ # extensions to do their thing before features are loaded
72
+ step_mother.should_receive(:after_configuration).with(configuration).ordered
73
+ # Feature files must be loaded before step definitions are required.
74
+ # This is because i18n step methods are only aliased when
75
+ # features are loaded. If we swap the order, the requires
76
+ # will fail.
77
+ step_mother.should_receive(:load_plain_text_features).ordered
78
+ step_mother.should_receive(:load_code_files).with(['step defs']).ordered
79
+
80
+ cli.execute!(step_mother)
81
+ end
82
+
83
+ end
84
+
84
85
  [ProfilesNotDefinedError, YmlLoadError, ProfileNotFound].each do |exception_klass|
85
86
 
86
87
  it "rescues #{exception_klass}, prints the message to the error stream and returns true" do
@@ -88,7 +89,7 @@ module Cucumber
88
89
  configuration.stub!(:parse!).and_raise(exception_klass.new("error message"))
89
90
 
90
91
  main = Main.new('', out = StringIO.new, error = StringIO.new)
91
- main.execute!.should be_true
92
+ main.execute!(Cucumber::StepMother.new).should be_true
92
93
  error.string.should == "error message\n"
93
94
  end
94
95
  end
@@ -102,31 +103,30 @@ module Cucumber
102
103
 
103
104
  @cli = Main.new(@args, @out, @err)
104
105
  @step_mother = mock('StepMother').as_null_object
105
- StepMother.stub!(:new).and_return(@step_mother)
106
106
  end
107
107
 
108
108
  it "delegates the execution to the DRB client passing the args and streams" do
109
109
  @configuration.stub :drb_port => 1450
110
110
  DRbClient.should_receive(:run).with(@args, @err, @out, 1450).and_return(true)
111
- @cli.execute!
111
+ @cli.execute!(@step_mother)
112
112
  end
113
113
 
114
114
  it "returns the result from the DRbClient" do
115
115
  DRbClient.stub!(:run).and_return('foo')
116
- @cli.execute!.should == 'foo'
116
+ @cli.execute!(@step_mother).should == 'foo'
117
117
  end
118
118
 
119
119
  it "ceases execution if the DrbClient is able to perform the execution" do
120
120
  DRbClient.stub!(:run).and_return(true)
121
121
  @configuration.should_not_receive(:build_formatter_broadcaster)
122
- @cli.execute!
122
+ @cli.execute!(@step_mother)
123
123
  end
124
124
 
125
125
  context "when the DrbClient is unable to perfrom the execution" do
126
126
  before { DRbClient.stub!(:run).and_raise(DRbClientError.new('error message.')) }
127
127
 
128
128
  it "alerts the user that execution will be performed locally" do
129
- @cli.execute!
129
+ @cli.execute!(@step_mother)
130
130
  @err.string.should include("WARNING: error message. Running features locally:")
131
131
  end
132
132
 
@@ -1,6 +1,5 @@
1
- require 'spec_helper'
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
2
  require 'yaml'
3
- require 'cucumber/cli/options'
4
3
 
5
4
  module Cucumber
6
5
  module Cli
@@ -112,13 +111,6 @@ module Cli
112
111
  end
113
112
  end
114
113
 
115
- context '-l LINES or --lines LINES' do
116
- it "adds line numbers to args" do
117
- options.parse!(%w{-l24 FILE})
118
- options.instance_variable_get(:@args).should == ['FILE:24']
119
- end
120
- end
121
-
122
114
  context '-p PROFILE or --profile PROFILE' do
123
115
 
124
116
  it "notifies the user that an individual profile is being used" do
@@ -332,25 +324,6 @@ module Cli
332
324
 
333
325
  end
334
326
 
335
- describe "dry-run" do
336
- it "should have the default value for snippets" do
337
- given_cucumber_yml_defined_as({'foo' => %w[--dry-run]})
338
- options.parse!(%w{--dry-run})
339
- options[:snippets].should == true
340
- end
341
-
342
- it "should set snippets to false when no-snippets provided after dry-run" do
343
- given_cucumber_yml_defined_as({'foo' => %w[--dry-run --no-snippets]})
344
- options.parse!(%w{--dry-run --no-snippets})
345
- options[:snippets].should == false
346
- end
347
-
348
- it "should set snippets to false when no-snippets provided before dry-run" do
349
- given_cucumber_yml_defined_as({'foo' => %w[--no-snippet --dry-run]})
350
- options.parse!(%w{--no-snippets --dry-run})
351
- options[:snippets].should == false
352
- end
353
- end
354
327
  end
355
328
 
356
329
  end
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
2
  require 'yaml'
3
3
 
4
4
  module Cucumber
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
2
  require 'cucumber/core_ext/proc'
3
3
 
4
4
  describe Proc do
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
2
  require 'cucumber/formatter/ansicolor'
3
3
 
4
4
  module Cucumber
@@ -0,0 +1,29 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+ require 'cucumber/formatter/color_io'
3
+
4
+ module Cucumber
5
+ module Formatter
6
+ describe ColorIO do
7
+ describe "<<" do
8
+ it "should convert to a print using kernel" do
9
+ kernel = mock('Kernel')
10
+ color_io = ColorIO.new(kernel, nil)
11
+
12
+ kernel.should_receive(:print).with("monkeys")
13
+
14
+ color_io << "monkeys"
15
+ end
16
+
17
+ it "should allow chained <<" do
18
+ kernel = mock('Kernel')
19
+ color_io = ColorIO.new(kernel, nil)
20
+
21
+ kernel.should_receive(:print).with("monkeys")
22
+ kernel.should_receive(:print).with(" are tasty")
23
+
24
+ color_io << "monkeys" << " are tasty"
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
2
  require 'cucumber/formatter/duration'
3
3
 
4
4
  module Cucumber
@@ -1,5 +1,5 @@
1
- require 'spec_helper'
2
- require 'cucumber/formatter/spec_helper'
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
3
3
  require 'cucumber/formatter/html'
4
4
  require 'nokogiri'
5
5
  require 'cucumber/rb_support/rb_language'
@@ -11,7 +11,9 @@ module Cucumber
11
11
  extend SpecHelperDsl
12
12
  include SpecHelper
13
13
 
14
- RSpec::Matchers.define :have_css_node do |css, regexp|
14
+ matcher = defined?(Spec::Matchers) ? Spec::Matchers : RSpec::Matchers
15
+
16
+ matcher.define :have_css_node do |css, regexp|
15
17
  match do |doc|
16
18
  nodes = doc.css(css)
17
19
  nodes.detect{ |node| node.text =~ regexp }
@@ -1,5 +1,5 @@
1
- require 'spec_helper'
2
- require 'cucumber/formatter/spec_helper'
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
3
3
 
4
4
  require 'cucumber/formatter/junit'
5
5
  require 'nokogiri'
@@ -51,19 +51,6 @@ module Cucumber::Formatter
51
51
 
52
52
  it { @doc.to_s.should =~ /One passing scenario, one failing scenario/ }
53
53
  end
54
-
55
- describe "with a scenario in a subdirectory" do
56
- define_feature %{
57
- Feature: One passing scenario, one failing scenario
58
-
59
- Scenario: Passing
60
- Given a passing scenario
61
- }, File.join('features', 'some', 'path', 'spec.feature')
62
-
63
- it 'writes the filename including the subdirectory' do
64
- @formatter.written_files.keys.first.should == File.join('', 'TEST-some_path_spec.xml')
65
- end
66
- end
67
54
 
68
55
  describe "with a scenario outline table" do
69
56
  define_steps do
@@ -94,7 +81,6 @@ module Cucumber::Formatter
94
81
  it { @doc.to_s.should =~ /Big Mac/ }
95
82
  it { @doc.to_s.should_not =~ /Things/ }
96
83
  it { @doc.to_s.should_not =~ /Good|Evil/ }
97
- it { @doc.to_s.should_not =~ /type="skipped"/}
98
84
  end
99
85
 
100
86
  describe "with a regular data table scenario" do
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
2
  require 'cucumber/formatter/progress'
3
3
 
4
4
  module Cucumber
@@ -2,11 +2,10 @@ module Cucumber
2
2
  module Formatter
3
3
 
4
4
  module SpecHelperDsl
5
- attr_reader :feature_content, :step_defs, :feature_filename
5
+ attr_reader :feature_content, :step_defs
6
6
 
7
- def define_feature(string, feature_file = 'spec.feature')
7
+ def define_feature(string)
8
8
  @feature_content = string
9
- @feature_filename = feature_file
10
9
  end
11
10
 
12
11
  def define_steps(&block)
@@ -22,31 +21,33 @@ module Cucumber
22
21
  end
23
22
 
24
23
  def step_mother
25
- @step_mother ||= Runtime.new
24
+ @step_mother ||= StepMother.new
26
25
  end
27
26
 
28
27
  def load_features(content)
29
- feature_file = FeatureFile.new(self.class.feature_filename, content)
28
+ feature_file = FeatureFile.new('spec.feature', content)
30
29
  features = Ast::Features.new
31
- filters = []
32
- feature = feature_file.parse(filters, {})
30
+ feature = feature_file.parse(options, {})
33
31
  features.add_feature(feature) if feature
34
32
  features
35
33
  end
36
34
 
37
35
  def run(features)
38
- configuration = Cucumber::Configuration.default
39
- tree_walker = Cucumber::Ast::TreeWalker.new(step_mother, [@formatter], configuration)
36
+ tree_walker = Cucumber::Ast::TreeWalker.new(@step_mother, [@formatter], options, STDOUT)
40
37
  tree_walker.visit_features(features)
41
38
  end
42
39
 
43
40
  def define_steps
44
41
  return unless step_defs = self.class.step_defs
45
- rb = step_mother.load_programming_language('rb')
46
- dsl = Object.new
42
+ rb = @step_mother.load_programming_language('rb')
43
+ dsl = Object.new
47
44
  dsl.extend RbSupport::RbDsl
48
45
  dsl.instance_exec &step_defs
49
46
  end
47
+
48
+ def options
49
+ @options ||= mock(Cucumber::Cli::Options, :filters => [], :[] => nil)
50
+ end
50
51
  end
51
52
  end
52
53
  end