cucumber 1.2.1 → 1.2.2

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 (172) hide show
  1. data/.rvmrc +1 -1
  2. data/.travis.yml +3 -2
  3. data/DEVELOPERS.md +48 -0
  4. data/History.md +22 -3
  5. data/README.md +13 -31
  6. data/Rakefile +1 -0
  7. data/cucumber.gemspec +18 -17
  8. data/cucumber.yml +3 -2
  9. data/examples/i18n/cs/Rakefile +6 -0
  10. data/examples/i18n/cs/features/addition.feature +17 -0
  11. data/examples/i18n/cs/features/division.feature +11 -0
  12. data/examples/i18n/cs/features/step_definitons/calculator_steps.rb +24 -0
  13. data/examples/i18n/cs/lib/calculator.rb +14 -0
  14. data/examples/i18n/hi/Rakefile +6 -0
  15. data/examples/i18n/hi/features/addition.feature +16 -0
  16. data/examples/i18n/hi/features/division.feature +10 -0
  17. data/examples/i18n/hi/features/step_definitons/calculator_steps.rb +24 -0
  18. data/examples/i18n/hi/lib/calculator.rb +15 -0
  19. data/examples/python/README.textile +2 -1
  20. data/examples/ruby2python/README.textile +2 -1
  21. data/features/.cucumber/stepdefs.json +1688 -445
  22. data/features/assertions.feature +69 -0
  23. data/features/formatter_callbacks.feature +189 -0
  24. data/features/html_formatter.feature +19 -0
  25. data/features/json_formatter.feature +8 -4
  26. data/features/nested_steps_with_second_arg.feature +73 -0
  27. data/features/step_definitions.feature +65 -0
  28. data/features/step_definitions/cucumber_steps.rb +18 -3
  29. data/fixtures/self_test/features/support/env.rb +1 -1
  30. data/gem_tasks/cucumber.rake +5 -3
  31. data/gem_tasks/downloads.rb +3 -3
  32. data/gem_tasks/stats +4 -2
  33. data/gem_tasks/yard.rake +31 -13
  34. data/legacy_features/default_snippets.feature +3 -3
  35. data/legacy_features/language_help.feature +4 -0
  36. data/legacy_features/report_called_undefined_steps.feature +1 -1
  37. data/legacy_features/snippet.feature +3 -3
  38. data/legacy_features/snippets_when_using_star_keyword.feature +1 -1
  39. data/legacy_features/step_definitions/cucumber_steps.rb +4 -3
  40. data/legacy_features/support/env.rb +1 -1
  41. data/legacy_features/support/fake_wire_server.rb +9 -9
  42. data/lib/autotest/cucumber_mixin.rb +14 -14
  43. data/lib/autotest/discover.rb +2 -0
  44. data/lib/cucumber.rb +2 -2
  45. data/lib/cucumber/ast.rb +1 -1
  46. data/lib/cucumber/ast/background.rb +11 -7
  47. data/lib/cucumber/ast/comment.rb +2 -2
  48. data/lib/cucumber/ast/doc_string.rb +1 -1
  49. data/lib/cucumber/ast/examples.rb +1 -1
  50. data/lib/cucumber/ast/feature.rb +2 -2
  51. data/lib/cucumber/ast/feature_element.rb +1 -1
  52. data/lib/cucumber/ast/multiline_argument.rb +2 -2
  53. data/lib/cucumber/ast/names.rb +2 -2
  54. data/lib/cucumber/ast/outline_table.rb +4 -5
  55. data/lib/cucumber/ast/scenario.rb +14 -14
  56. data/lib/cucumber/ast/scenario_outline.rb +4 -4
  57. data/lib/cucumber/ast/step.rb +3 -3
  58. data/lib/cucumber/ast/step_collection.rb +5 -5
  59. data/lib/cucumber/ast/step_invocation.rb +8 -8
  60. data/lib/cucumber/ast/table.rb +40 -27
  61. data/lib/cucumber/ast/tree_walker.rb +9 -8
  62. data/lib/cucumber/ast/visitor.rb +1 -1
  63. data/lib/cucumber/cli/configuration.rb +10 -10
  64. data/lib/cucumber/cli/drb_client.rb +1 -1
  65. data/lib/cucumber/cli/main.rb +3 -3
  66. data/lib/cucumber/cli/options.rb +3 -2
  67. data/lib/cucumber/cli/profile_loader.rb +1 -1
  68. data/lib/cucumber/configuration.rb +12 -12
  69. data/lib/cucumber/constantize.rb +11 -2
  70. data/lib/cucumber/core_ext/disable_mini_and_test_unit_autorun.rb +1 -1
  71. data/lib/cucumber/core_ext/instance_exec.rb +4 -4
  72. data/lib/cucumber/core_ext/proc.rb +3 -3
  73. data/lib/cucumber/errors.rb +1 -1
  74. data/lib/cucumber/feature_file.rb +1 -1
  75. data/lib/cucumber/formatter/ansicolor.rb +36 -23
  76. data/lib/cucumber/formatter/console.rb +45 -25
  77. data/lib/cucumber/formatter/debug.rb +7 -7
  78. data/lib/cucumber/formatter/duration.rb +1 -1
  79. data/lib/cucumber/formatter/gherkin_formatter_adapter.rb +7 -0
  80. data/lib/cucumber/formatter/gpretty.rb +1 -1
  81. data/lib/cucumber/formatter/html.rb +52 -53
  82. data/lib/cucumber/formatter/interceptor.rb +2 -2
  83. data/lib/cucumber/formatter/json.rb +1 -1
  84. data/lib/cucumber/formatter/json_pretty.rb +2 -1
  85. data/lib/cucumber/formatter/junit.rb +1 -1
  86. data/lib/cucumber/formatter/ordered_xml_markup.rb +1 -1
  87. data/lib/cucumber/formatter/pretty.rb +12 -12
  88. data/lib/cucumber/formatter/progress.rb +5 -5
  89. data/lib/cucumber/formatter/rerun.rb +5 -5
  90. data/lib/cucumber/formatter/stepdefs.rb +1 -1
  91. data/lib/cucumber/formatter/steps.rb +6 -6
  92. data/lib/cucumber/formatter/summary.rb +6 -6
  93. data/lib/cucumber/formatter/unicode.rb +18 -18
  94. data/lib/cucumber/formatter/usage.rb +7 -7
  95. data/lib/cucumber/js_support/js_dsl.js +1 -1
  96. data/lib/cucumber/language_support.rb +1 -1
  97. data/lib/cucumber/parser/gherkin_builder.rb +33 -33
  98. data/lib/cucumber/platform.rb +3 -2
  99. data/lib/cucumber/py_support/py_dsl.py +2 -2
  100. data/lib/cucumber/py_support/py_language.py +2 -2
  101. data/lib/cucumber/py_support/py_language.rb +2 -2
  102. data/lib/cucumber/rake/task.rb +4 -3
  103. data/lib/cucumber/rb_support/rb_dsl.rb +10 -10
  104. data/lib/cucumber/rb_support/rb_language.rb +27 -19
  105. data/lib/cucumber/rb_support/rb_step_definition.rb +39 -11
  106. data/lib/cucumber/rb_support/rb_transform.rb +3 -3
  107. data/lib/cucumber/rb_support/rb_world.rb +15 -15
  108. data/lib/cucumber/rb_support/regexp_argument_matcher.rb +1 -1
  109. data/lib/cucumber/rspec/disable_option_parser.rb +1 -1
  110. data/lib/cucumber/rspec/doubles.rb +1 -1
  111. data/lib/cucumber/runtime.rb +11 -10
  112. data/lib/cucumber/runtime/features_loader.rb +6 -6
  113. data/lib/cucumber/runtime/for_programming_languages.rb +8 -15
  114. data/lib/cucumber/runtime/results.rb +6 -6
  115. data/lib/cucumber/runtime/support_code.rb +37 -28
  116. data/lib/cucumber/runtime/user_interface.rb +4 -4
  117. data/lib/cucumber/step_definition_light.rb +4 -4
  118. data/lib/cucumber/step_definitions.rb +2 -3
  119. data/lib/cucumber/step_match.rb +6 -6
  120. data/lib/cucumber/step_mother.rb +1 -1
  121. data/lib/cucumber/term/ansicolor.rb +22 -22
  122. data/lib/cucumber/wire_support/configuration.rb +11 -14
  123. data/lib/cucumber/wire_support/connection.rb +10 -9
  124. data/lib/cucumber/wire_support/request_handler.rb +3 -3
  125. data/lib/cucumber/wire_support/wire_exception.rb +3 -3
  126. data/lib/cucumber/wire_support/wire_language.rb +11 -11
  127. data/lib/cucumber/wire_support/wire_packet.rb +7 -5
  128. data/lib/cucumber/wire_support/wire_protocol.rb +6 -6
  129. data/lib/cucumber/wire_support/wire_protocol/requests.rb +20 -20
  130. data/lib/cucumber/wire_support/wire_step_definition.rb +4 -4
  131. data/spec/cucumber/ast/background_spec.rb +4 -4
  132. data/spec/cucumber/ast/doc_string_spec.rb +8 -8
  133. data/spec/cucumber/ast/feature_factory.rb +4 -4
  134. data/spec/cucumber/ast/feature_spec.rb +18 -18
  135. data/spec/cucumber/ast/outline_table_spec.rb +3 -3
  136. data/spec/cucumber/ast/step_spec.rb +4 -4
  137. data/spec/cucumber/ast/table_spec.rb +50 -29
  138. data/spec/cucumber/ast/tree_walker_spec.rb +12 -4
  139. data/spec/cucumber/broadcaster_spec.rb +1 -1
  140. data/spec/cucumber/cli/configuration_spec.rb +10 -4
  141. data/spec/cucumber/cli/drb_client_spec.rb +1 -1
  142. data/spec/cucumber/cli/main_spec.rb +28 -7
  143. data/spec/cucumber/cli/options_spec.rb +3 -3
  144. data/spec/cucumber/configuration_spec.rb +4 -4
  145. data/spec/cucumber/constantize_spec.rb +2 -0
  146. data/spec/cucumber/core_ext/proc_spec.rb +7 -7
  147. data/spec/cucumber/formatter/ansicolor_spec.rb +2 -2
  148. data/spec/cucumber/formatter/duration_spec.rb +2 -2
  149. data/spec/cucumber/formatter/html_spec.rb +31 -31
  150. data/spec/cucumber/formatter/interceptor_spec.rb +10 -0
  151. data/spec/cucumber/formatter/progress_spec.rb +1 -1
  152. data/spec/cucumber/formatter/spec_helper.rb +7 -7
  153. data/spec/cucumber/rake/forked_spec.rb +15 -2
  154. data/spec/cucumber/rake/rcov_spec.rb +2 -2
  155. data/spec/cucumber/rb_support/rb_language_spec.rb +34 -17
  156. data/spec/cucumber/rb_support/rb_step_definition_spec.rb +45 -35
  157. data/spec/cucumber/rb_support/rb_transform_spec.rb +3 -3
  158. data/spec/cucumber/runtime/for_programming_languages_spec.rb +31 -0
  159. data/spec/cucumber/runtime/results_spec.rb +5 -5
  160. data/spec/cucumber/runtime/support_code_spec.rb +13 -2
  161. data/spec/cucumber/runtime_spec.rb +7 -7
  162. data/spec/cucumber/step_match_spec.rb +2 -2
  163. data/spec/cucumber/wire_support/configuration_spec.rb +16 -6
  164. data/spec/cucumber/wire_support/connection_spec.rb +25 -11
  165. data/spec/cucumber/wire_support/wire_exception_spec.rb +3 -3
  166. data/spec/cucumber/wire_support/wire_language_spec.rb +3 -3
  167. data/spec/cucumber/wire_support/wire_packet_spec.rb +4 -4
  168. data/spec/cucumber/wire_support/wire_step_definition_spec.rb +1 -1
  169. data/spec/spec_helper.rb +2 -2
  170. metadata +98 -128
  171. data/legacy_features/html_formatter.feature +0 -8
  172. data/legacy_features/html_formatter/a.html +0 -561
@@ -68,6 +68,16 @@ module Cucumber::Formatter
68
68
  $stdout.should_not be interceptor
69
69
  end
70
70
 
71
+ it 'should noop if $stdout or $stderr has been overwritten' do
72
+ $stdout = StringIO.new
73
+ pipe = Interceptor::Pipe.unwrap! :stdout
74
+ pipe.should == $stdout
75
+
76
+ $stderr = StringIO.new
77
+ pipe = Interceptor::Pipe.unwrap! :stderr
78
+ pipe.should == $stderr
79
+ end
80
+
71
81
  it 'should disable the pipe bypass' do
72
82
  buffer = '(::)'
73
83
  Interceptor::Pipe.unwrap! :stdout
@@ -11,7 +11,7 @@ module Cucumber
11
11
  progress = Cucumber::Formatter::Progress.new(mock("step mother"), @out, {})
12
12
  @visitor = Cucumber::Ast::TreeWalker.new(nil, [progress])
13
13
  end
14
-
14
+
15
15
  describe "visiting a table cell value without a status" do
16
16
  it "should take the status from the last run step" do
17
17
  @visitor.visit_step_result('', '', nil, :failed, nil, 10, nil, nil)
@@ -3,12 +3,12 @@ module Cucumber
3
3
 
4
4
  module SpecHelperDsl
5
5
  attr_reader :feature_content, :step_defs, :feature_filename
6
-
6
+
7
7
  def define_feature(string, feature_file = 'spec.feature')
8
8
  @feature_content = string
9
9
  @feature_filename = feature_file
10
10
  end
11
-
11
+
12
12
  def define_steps(&block)
13
13
  @step_defs = block
14
14
  end
@@ -20,11 +20,11 @@ module Cucumber
20
20
  features = load_features(self.class.feature_content || raise("No feature content defined!"))
21
21
  run(features)
22
22
  end
23
-
23
+
24
24
  def step_mother
25
25
  @step_mother ||= Runtime.new
26
26
  end
27
-
27
+
28
28
  def load_features(content)
29
29
  feature_file = FeatureFile.new(self.class.feature_filename, content)
30
30
  features = Ast::Features.new
@@ -33,20 +33,20 @@ module Cucumber
33
33
  features.add_feature(feature) if feature
34
34
  features
35
35
  end
36
-
36
+
37
37
  def run(features)
38
38
  configuration = Cucumber::Configuration.default
39
39
  tree_walker = Cucumber::Ast::TreeWalker.new(step_mother, [@formatter], configuration)
40
40
  tree_walker.visit_features(features)
41
41
  end
42
-
42
+
43
43
  def define_steps
44
44
  return unless step_defs = self.class.step_defs
45
45
  rb = step_mother.load_programming_language('rb')
46
46
  dsl = Object.new
47
47
  dsl.extend RbSupport::RbDsl
48
48
  dsl.instance_exec &step_defs
49
- end
49
+ end
50
50
  end
51
51
  end
52
52
  end
@@ -24,9 +24,22 @@ module Cucumber
24
24
  end
25
25
 
26
26
  it "uses bundle exec to find cucumber and libraries" do
27
+ bundle_cmd = Gem.default_exec_format % 'bundle'
28
+
29
+ subject.cmd.should == [Cucumber::RUBY_BINARY,
30
+ '-S',
31
+ bundle_cmd,
32
+ 'exec',
33
+ 'cucumber',
34
+ '--cuke-option'] + feature_files
35
+ end
36
+
37
+ it "obeys program suffix for bundler" do
38
+ Gem::ConfigMap.stub(:[]).with(:ruby_install_name).and_return('XrubyY')
39
+
27
40
  subject.cmd.should == [Cucumber::RUBY_BINARY,
28
41
  '-S',
29
- 'bundle',
42
+ 'XbundleY',
30
43
  'exec',
31
44
  'cucumber',
32
45
  '--cuke-option'] + feature_files
@@ -59,4 +72,4 @@ module Cucumber
59
72
  end
60
73
 
61
74
  end
62
- end
75
+ end
@@ -61,11 +61,11 @@ module Cucumber
61
61
  '--',
62
62
  '--cuke-option'] + feature_files
63
63
  end
64
-
64
+
65
65
  end
66
66
 
67
67
 
68
68
  end
69
69
 
70
70
  end
71
- end
71
+ end
@@ -10,7 +10,7 @@ module Cucumber
10
10
  let(:support_code) do
11
11
  Cucumber::Runtime::SupportCode.new(user_interface, {})
12
12
  end
13
- let(:dsl) do
13
+ let(:dsl) do
14
14
  rb
15
15
  Object.new.extend(RbSupport::RbDsl)
16
16
  end
@@ -18,12 +18,20 @@ module Cucumber
18
18
  def unindented(s)
19
19
  s.split("\n")[1..-2].join("\n").indent(-10)
20
20
  end
21
-
21
+
22
22
  describe "snippets" do
23
-
23
+
24
+ it "should wrap snippet patterns in parentheses" do
25
+ rb.snippet_text('Given', 'A "string" with 4 spaces', nil).should == unindented(%{
26
+ Given(/^A "(.*?)" with (\\d+) spaces$/) do |arg1, arg2|
27
+ pending # express the regexp above with the code you wish you had
28
+ end
29
+ })
30
+ end
31
+
24
32
  it "should recognise numbers in name and make according regexp" do
25
33
  rb.snippet_text('Given', 'Cloud 9 yeah', nil).should == unindented(%{
26
- Given /^Cloud (\\d+) yeah$/ do |arg1|
34
+ Given(/^Cloud (\\d+) yeah$/) do |arg1|
27
35
  pending # express the regexp above with the code you wish you had
28
36
  end
29
37
  })
@@ -31,7 +39,7 @@ module Cucumber
31
39
 
32
40
  it "should recognise a mix of ints, strings and why not a table too" do
33
41
  rb.snippet_text('Given', 'I have 9 "awesome" cukes in 37 "boxes"', Cucumber::Ast::Table).should == unindented(%{
34
- Given /^I have (\\d+) "(.*?)" cukes in (\\d+) "(.*?)"$/ do |arg1, arg2, arg3, arg4, table|
42
+ Given(/^I have (\\d+) "(.*?)" cukes in (\\d+) "(.*?)"$/) do |arg1, arg2, arg3, arg4, table|
35
43
  # table is a Cucumber::Ast::Table
36
44
  pending # express the regexp above with the code you wish you had
37
45
  end
@@ -40,7 +48,7 @@ module Cucumber
40
48
 
41
49
  it "should recognise quotes in name and make according regexp" do
42
50
  rb.snippet_text('Given', 'A "first" arg', nil).should == unindented(%{
43
- Given /^A "(.*?)" arg$/ do |arg1|
51
+ Given(/^A "(.*?)" arg$/) do |arg1|
44
52
  pending # express the regexp above with the code you wish you had
45
53
  end
46
54
  })
@@ -48,15 +56,15 @@ module Cucumber
48
56
 
49
57
  it "should recognise several quoted words in name and make according regexp and args" do
50
58
  rb.snippet_text('Given', 'A "first" and "second" arg', nil).should == unindented(%{
51
- Given /^A "(.*?)" and "(.*?)" arg$/ do |arg1, arg2|
59
+ Given(/^A "(.*?)" and "(.*?)" arg$/) do |arg1, arg2|
52
60
  pending # express the regexp above with the code you wish you had
53
61
  end
54
62
  })
55
63
  end
56
-
64
+
57
65
  it "should not use quote group when there are no quotes" do
58
66
  rb.snippet_text('Given', 'A first arg', nil).should == unindented(%{
59
- Given /^A first arg$/ do
67
+ Given(/^A first arg$/) do
60
68
  pending # express the regexp above with the code you wish you had
61
69
  end
62
70
  })
@@ -64,38 +72,38 @@ module Cucumber
64
72
 
65
73
  it "should be helpful with tables" do
66
74
  rb.snippet_text('Given', 'A "first" arg', Cucumber::Ast::Table).should == unindented(%{
67
- Given /^A "(.*?)" arg$/ do |arg1, table|
75
+ Given(/^A "(.*?)" arg$/) do |arg1, table|
68
76
  # table is a Cucumber::Ast::Table
69
77
  pending # express the regexp above with the code you wish you had
70
78
  end
71
79
  })
72
80
  end
73
-
81
+
74
82
  end
75
-
83
+
76
84
  describe "#load_code_file" do
77
85
  after do
78
86
  FileUtils.rm_rf('tmp.rb')
79
87
  end
80
-
88
+
81
89
  def a_file_called(name)
82
90
  File.open('tmp.rb', 'w') do |f|
83
91
  f.puts yield
84
92
  end
85
93
  end
86
-
94
+
87
95
  it "re-loads the file when called multiple times" do
88
96
  a_file_called('tmp.rb') do
89
97
  "$foo = 1"
90
98
  end
91
-
99
+
92
100
  rb.load_code_file('tmp.rb')
93
101
  $foo.should == 1
94
-
102
+
95
103
  a_file_called('tmp.rb') do
96
104
  "$foo = 2"
97
105
  end
98
-
106
+
99
107
  rb.load_code_file('tmp.rb')
100
108
  $foo.should == 2
101
109
  end
@@ -189,6 +197,15 @@ or http://wiki.github.com/cucumber/cucumber/a-whole-new-world.
189
197
  rb.execute_transforms(['abc']).should == [42]
190
198
  rb.execute_transforms(['abbc']).should == [42]
191
199
  end
200
+
201
+ it "transforms times" do
202
+ require 'time'
203
+ dsl.Transform(/^(\d\d-\d\d-\d\d\d\d)$/) do |arg|
204
+ Time.parse(arg)
205
+ end
206
+ rb.execute_transforms(['10-0E-1971']).should == ['10-0E-1971']
207
+ rb.execute_transforms(['10-03-1971']).should == [Time.parse('10-03-1971')]
208
+ end
192
209
  end
193
210
 
194
211
  describe "with capture groups" do
@@ -7,19 +7,22 @@ module Cucumber
7
7
  module RbSupport
8
8
  describe RbStepDefinition do
9
9
  let(:user_interface) { double('user interface') }
10
- let(:support_code) { Cucumber::Runtime::SupportCode.new(user_interface) }
11
- let(:rb) { support_code.load_programming_language('rb')}
12
- let(:dsl) do
10
+ let(:support_code) { Cucumber::Runtime::SupportCode.new(user_interface) }
11
+ let(:rb) { support_code.load_programming_language('rb') }
12
+ let(:dsl) do
13
13
  rb
14
14
  Object.new.extend(Cucumber::RbSupport::RbDsl)
15
15
  end
16
-
17
- before do
18
- rb.before(mock('scenario').as_null_object)
19
16
 
17
+ before do
18
+ rb.before(mock('scenario').as_null_object)
20
19
  $inside = nil
21
20
  end
22
-
21
+
22
+ def run_step(text)
23
+ support_code.step_match(text).invoke(nil)
24
+ end
25
+
23
26
  it "should allow calling of other steps" do
24
27
  dsl.Given /Outside/ do
25
28
  step "Inside"
@@ -28,7 +31,7 @@ module Cucumber
28
31
  $inside = true
29
32
  end
30
33
 
31
- support_code.step_match("Outside").invoke(nil)
34
+ run_step "Outside"
32
35
  $inside.should == true
33
36
  end
34
37
 
@@ -40,24 +43,35 @@ module Cucumber
40
43
  $inside = table.raw[0][0]
41
44
  end
42
45
 
43
- support_code.step_match("Outside").invoke(nil)
46
+ run_step "Outside"
44
47
  $inside.should == 'inside'
45
48
  end
46
49
 
47
- it "should call a method on the world when specified with a symbol" do
48
- rb.current_world.should_receive(:with_symbol)
49
- dsl.Given /With symbol/, :with_symbol
50
+ context "mapping to world methods" do
51
+ it "should call a method on the world when specified with a symbol" do
52
+ rb.current_world.should_receive(:with_symbol)
53
+ dsl.Given /With symbol/, :with_symbol
50
54
 
51
- support_code.step_match("With symbol").invoke(nil)
52
- end
55
+ run_step "With symbol"
56
+ end
53
57
 
54
- it "should call a method on a specified object" do
55
- target = double('target')
56
- target.should_receive(:with_symbol)
57
- rb.current_world.stub!(:target).and_return(target)
58
- dsl.Given /With symbol on block/, :with_symbol, :on => lambda { target }
58
+ it "should call a method on a specified object" do
59
+ target = double('target')
60
+ rb.current_world.stub(:target => target)
61
+ dsl.Given /With symbol on block/, :with_symbol, :on => lambda { target }
59
62
 
60
- support_code.step_match("With symbol on block").invoke(nil)
63
+ target.should_receive(:with_symbol)
64
+ run_step "With symbol on block"
65
+ end
66
+
67
+ it "should call a method on a specified world attribute" do
68
+ target = double('target')
69
+ rb.current_world.stub(:target => target)
70
+ dsl.Given /With symbol on symbol/, :with_symbol, :on => :target
71
+
72
+ target.should_receive(:with_symbol)
73
+ run_step "With symbol on symbol"
74
+ end
61
75
  end
62
76
 
63
77
  it "should raise Undefined when inside step is not defined" do
@@ -65,9 +79,8 @@ module Cucumber
65
79
  step 'Inside'
66
80
  end
67
81
 
68
- lambda do
69
- support_code.step_match('Outside').invoke(nil)
70
- end.should raise_error(Cucumber::Undefined, 'Undefined step: "Inside"')
82
+ lambda { run_step "Outside" }.
83
+ should raise_error(Cucumber::Undefined, 'Undefined step: "Inside"')
71
84
  end
72
85
 
73
86
  it "should allow forced pending" do
@@ -75,18 +88,16 @@ module Cucumber
75
88
  pending("Do me!")
76
89
  end
77
90
 
78
- lambda do
79
- support_code.step_match("Outside").invoke(nil)
80
- end.should raise_error(Cucumber::Pending, "Do me!")
91
+ lambda { run_step "Outside" }.
92
+ should raise_error(Cucumber::Pending, "Do me!")
81
93
  end
82
94
 
83
95
  it "should raise ArityMismatchError when the number of capture groups differs from the number of step arguments" do
84
96
  dsl.Given /No group: \w+/ do |arg|
85
97
  end
86
98
 
87
- lambda do
88
- support_code.step_match("No group: arg").invoke(nil)
89
- end.should raise_error(Cucumber::ArityMismatchError)
99
+ lambda { run_step "No group: arg" }.
100
+ should raise_error(Cucumber::ArityMismatchError)
90
101
  end
91
102
 
92
103
  it "should allow puts" do
@@ -94,16 +105,15 @@ module Cucumber
94
105
  dsl.Given /Loud/ do
95
106
  puts 'wasup'
96
107
  end
97
-
98
- support_code.step_match("Loud").invoke(nil)
108
+ run_step "Loud"
99
109
  end
100
-
110
+
101
111
  it "should recognize $arg style captures" do
112
+ arg_value = "wow!"
102
113
  dsl.Given "capture this: $arg" do |arg|
103
- arg.should == 'this'
114
+ arg.should == arg_value
104
115
  end
105
-
106
- support_code.step_match('capture this: this').invoke(nil)
116
+ run_step "capture this: wow!"
107
117
  end
108
118
 
109
119
  it "should have a JSON representation of the signature" do
@@ -11,15 +11,15 @@ module Cucumber
11
11
  it "converts captures groups to non-capture groups" do
12
12
  transform(/(a|b)bc/).to_s.should == "(?:a|b)bc"
13
13
  end
14
-
14
+
15
15
  it "leaves non capture groups alone" do
16
16
  transform(/(?:a|b)bc/).to_s.should == "(?:a|b)bc"
17
17
  end
18
-
18
+
19
19
  it "strips away anchors" do
20
20
  transform(/^xyz$/).to_s.should == "xyz"
21
21
  end
22
22
  end
23
23
  end
24
24
  end
25
- end
25
+ end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ module Cucumber
4
+ describe Runtime::ForProgrammingLanguages do
5
+
6
+ let(:user_interface) { double('user interface') }
7
+ subject { Runtime::SupportCode.new(user_interface,{}) }
8
+ let(:runtime_facade) { Runtime::ForProgrammingLanguages.new(subject, user_interface) }
9
+
10
+ it 'should produce Ast::DocString by #doc_string with default content-type' do
11
+ str = runtime_facade.doc_string('DOC')
12
+ str.should be_kind_of(Ast::DocString)
13
+ str.content_type.should eq('')
14
+ end
15
+
16
+ it 'should produce Ast::DocString by #doc_string with ruby content-type' do
17
+ str = runtime_facade.doc_string('DOC','ruby')
18
+ str.should be_kind_of(Ast::DocString)
19
+ str.content_type.should eq('ruby')
20
+ end
21
+
22
+ it 'should produce Ast::Table by #table' do
23
+ runtime_facade.table(%{
24
+ | account | description | amount |
25
+ | INT-100 | Taxi | 114 |
26
+ | CUC-101 | Peeler | 22 |
27
+ }).should be_kind_of(Ast::Table)
28
+ end
29
+
30
+ end
31
+ end
@@ -24,16 +24,16 @@ module Cucumber
24
24
  subject.scenario_visited(failed_scenario)
25
25
  subject.should be_failure
26
26
  end
27
-
27
+
28
28
  it 'should return true if a step failed' do
29
29
  subject.step_visited(failed_step)
30
30
  subject.should be_failure
31
31
  end
32
-
32
+
33
33
  it 'should return false if there are no scenarios' do
34
34
  subject.should_not be_failure
35
35
  end
36
-
36
+
37
37
  it 'should return false if all scenarios passed' do
38
38
  subject.scenario_visited(passed_scenario)
39
39
  subject.scenario_visited(passed_scenario)
@@ -49,7 +49,7 @@ module Cucumber
49
49
  subject.step_visited(pending_step)
50
50
  subject.should be_failure
51
51
  end
52
-
52
+
53
53
  it 'should return true if a step is undefined' do
54
54
  subject.step_visited(undefined_step)
55
55
  subject.should be_failure
@@ -70,7 +70,7 @@ module Cucumber
70
70
  it 'should return false if there are no scenarios' do
71
71
  subject.should_not be_failure
72
72
  end
73
-
73
+
74
74
  it 'should return false if all scenarios fail' do
75
75
  subject.scenario_visited(failed_scenario)
76
76
  subject.should_not be_failure