cucumber 0.8.5 → 0.8.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (181) hide show
  1. data/.rspec +1 -1
  2. data/LICENSE +1 -1
  3. data/Rakefile +5 -51
  4. data/bin/cucumber +7 -1
  5. data/cucumber.gemspec +463 -679
  6. data/examples/i18n/ar/features/step_definitons/calculator_steps.rb +1 -1
  7. data/examples/i18n/he/features/step_definitons/calculator_steps.rb +1 -1
  8. data/examples/i18n/ro/features/step_definitons/calculator_steps.rb +4 -7
  9. data/examples/i18n/ru/features/division.feature +2 -2
  10. data/examples/i18n/tr/features/step_definitons/hesap_makinesi_adimlari.rb +3 -3
  11. data/examples/sinatra/features/support/env.rb +2 -5
  12. data/examples/v8/features/fibonacci.feature +1 -1
  13. data/examples/watir/features/step_definitions/search_steps.rb +1 -1
  14. data/features/background.feature +284 -95
  15. data/features/custom_formatter.feature +3 -73
  16. data/features/json_formatter.feature +160 -245
  17. data/features/step_definitions/cucumber_steps.rb +7 -153
  18. data/features/support/env.rb +18 -140
  19. data/fixtures/junit/features/pending.feature +3 -1
  20. data/fixtures/self_test/features/support/env.rb +8 -0
  21. data/fixtures/tickets/features.html +1 -1
  22. data/gem_tasks/examples.rake +1 -1
  23. data/lib/cucumber.rb +12 -0
  24. data/lib/cucumber/ast.rb +1 -1
  25. data/lib/cucumber/ast/background.rb +21 -5
  26. data/lib/cucumber/ast/examples.rb +12 -4
  27. data/lib/cucumber/ast/feature.rb +13 -5
  28. data/lib/cucumber/ast/feature_element.rb +9 -4
  29. data/lib/cucumber/ast/outline_table.rb +4 -4
  30. data/lib/cucumber/ast/scenario.rb +7 -5
  31. data/lib/cucumber/ast/scenario_outline.rb +23 -15
  32. data/lib/cucumber/ast/step.rb +5 -0
  33. data/lib/cucumber/ast/step_invocation.rb +21 -15
  34. data/lib/cucumber/ast/table.rb +14 -8
  35. data/lib/cucumber/ast/tree_walker.rb +10 -48
  36. data/lib/cucumber/cli/configuration.rb +33 -8
  37. data/lib/cucumber/cli/main.rb +20 -35
  38. data/lib/cucumber/cli/options.rb +8 -7
  39. data/lib/cucumber/cli/profile_loader.rb +2 -0
  40. data/lib/cucumber/core_ext/proc.rb +2 -1
  41. data/lib/cucumber/feature_file.rb +47 -15
  42. data/lib/cucumber/formatter/ansicolor.rb +3 -5
  43. data/lib/cucumber/formatter/console.rb +27 -23
  44. data/lib/cucumber/formatter/cucumber.css +34 -17
  45. data/lib/cucumber/formatter/cucumber.sass +173 -182
  46. data/lib/cucumber/formatter/html.rb +46 -11
  47. data/lib/cucumber/formatter/io.rb +2 -4
  48. data/lib/cucumber/formatter/json.rb +15 -152
  49. data/lib/cucumber/formatter/json_pretty.rb +5 -6
  50. data/lib/cucumber/formatter/junit.rb +28 -22
  51. data/lib/cucumber/formatter/pdf.rb +6 -6
  52. data/lib/cucumber/formatter/pretty.rb +5 -5
  53. data/lib/cucumber/formatter/rerun.rb +22 -11
  54. data/lib/cucumber/formatter/unicode.rb +41 -20
  55. data/lib/cucumber/js_support/js_dsl.js +4 -4
  56. data/lib/cucumber/js_support/js_language.rb +9 -5
  57. data/lib/cucumber/js_support/js_snippets.rb +2 -2
  58. data/lib/cucumber/language_support.rb +2 -2
  59. data/lib/cucumber/parser/gherkin_builder.rb +35 -30
  60. data/lib/cucumber/platform.rb +8 -8
  61. data/lib/cucumber/py_support/py_language.rb +2 -2
  62. data/lib/cucumber/rake/task.rb +80 -31
  63. data/lib/cucumber/rb_support/rb_dsl.rb +1 -0
  64. data/lib/cucumber/rb_support/rb_language.rb +10 -8
  65. data/lib/cucumber/rb_support/rb_step_definition.rb +8 -0
  66. data/lib/cucumber/rb_support/rb_transform.rb +17 -0
  67. data/lib/cucumber/rb_support/rb_world.rb +26 -18
  68. data/lib/cucumber/rspec/doubles.rb +3 -3
  69. data/lib/cucumber/step_match.rb +6 -2
  70. data/lib/cucumber/step_mother.rb +6 -427
  71. data/lib/cucumber/wire_support/configuration.rb +4 -1
  72. data/lib/cucumber/wire_support/wire_language.rb +3 -10
  73. data/spec/cucumber/ast/background_spec.rb +68 -6
  74. data/spec/cucumber/ast/feature_factory.rb +5 -4
  75. data/spec/cucumber/ast/feature_spec.rb +4 -4
  76. data/spec/cucumber/ast/outline_table_spec.rb +1 -1
  77. data/spec/cucumber/ast/scenario_outline_spec.rb +15 -11
  78. data/spec/cucumber/ast/scenario_spec.rb +4 -4
  79. data/spec/cucumber/ast/step_spec.rb +3 -3
  80. data/spec/cucumber/ast/table_spec.rb +38 -2
  81. data/spec/cucumber/ast/tree_walker_spec.rb +2 -2
  82. data/spec/cucumber/broadcaster_spec.rb +1 -1
  83. data/spec/cucumber/cli/configuration_spec.rb +32 -6
  84. data/spec/cucumber/cli/drb_client_spec.rb +2 -3
  85. data/spec/cucumber/cli/main_spec.rb +43 -43
  86. data/spec/cucumber/cli/options_spec.rb +28 -1
  87. data/spec/cucumber/cli/profile_loader_spec.rb +1 -1
  88. data/spec/cucumber/core_ext/proc_spec.rb +1 -1
  89. data/spec/cucumber/formatter/ansicolor_spec.rb +1 -1
  90. data/spec/cucumber/formatter/duration_spec.rb +1 -1
  91. data/spec/cucumber/formatter/html_spec.rb +3 -5
  92. data/spec/cucumber/formatter/junit_spec.rb +16 -2
  93. data/spec/cucumber/formatter/progress_spec.rb +1 -1
  94. data/spec/cucumber/formatter/spec_helper.rb +11 -12
  95. data/spec/cucumber/rb_support/rb_language_spec.rb +241 -28
  96. data/spec/cucumber/rb_support/rb_step_definition_spec.rb +33 -28
  97. data/spec/cucumber/rb_support/regexp_argument_matcher_spec.rb +1 -1
  98. data/spec/cucumber/step_match_spec.rb +11 -9
  99. data/spec/cucumber/wire_support/configuration_spec.rb +1 -1
  100. data/spec/cucumber/wire_support/connection_spec.rb +1 -1
  101. data/spec/cucumber/wire_support/wire_exception_spec.rb +1 -1
  102. data/spec/cucumber/wire_support/wire_language_spec.rb +1 -1
  103. data/spec/cucumber/wire_support/wire_packet_spec.rb +1 -1
  104. data/spec/cucumber/wire_support/wire_step_definition_spec.rb +1 -1
  105. data/spec/cucumber/world/pending_spec.rb +2 -2
  106. data/spec/spec_helper.rb +13 -20
  107. metadata +11 -222
  108. data/.gitignore +0 -20
  109. data/Caliper.yml +0 -4
  110. data/History.txt +0 -1552
  111. data/README.rdoc +0 -26
  112. data/VERSION.yml +0 -5
  113. data/examples/i18n/ro/features/suma.feature +0 -11
  114. data/features/announce.feature +0 -164
  115. data/features/around_hooks.feature +0 -232
  116. data/features/bug_371.feature +0 -32
  117. data/features/bug_464.feature +0 -16
  118. data/features/bug_475.feature +0 -42
  119. data/features/bug_585_tab_indentation.feature +0 -22
  120. data/features/bug_600.feature +0 -67
  121. data/features/call_steps_from_stepdefs.feature +0 -154
  122. data/features/cucumber_cli.feature +0 -591
  123. data/features/cucumber_cli_outlines.feature +0 -117
  124. data/features/default_snippets.feature +0 -42
  125. data/features/diffing.feature +0 -25
  126. data/features/drb_server_integration.feature +0 -174
  127. data/features/exception_in_after_block.feature +0 -127
  128. data/features/exception_in_after_step_block.feature +0 -104
  129. data/features/exception_in_before_block.feature +0 -98
  130. data/features/exclude_files.feature +0 -20
  131. data/features/expand.feature +0 -60
  132. data/features/html_formatter.feature +0 -8
  133. data/features/html_formatter/a.html +0 -582
  134. data/features/junit_formatter.feature +0 -88
  135. data/features/language_from_header.feature +0 -30
  136. data/features/language_help.feature +0 -78
  137. data/features/listener_debugger_formatter.feature +0 -42
  138. data/features/multiline_names.feature +0 -44
  139. data/features/negative_tagged_hooks.feature +0 -60
  140. data/features/post_configuration_hook.feature +0 -37
  141. data/features/profiles.feature +0 -126
  142. data/features/rake_task.feature +0 -152
  143. data/features/report_called_undefined_steps.feature +0 -34
  144. data/features/rerun_formatter.feature +0 -45
  145. data/features/simplest.feature +0 -11
  146. data/features/snippet.feature +0 -23
  147. data/features/snippets_when_using_star_keyword.feature +0 -36
  148. data/features/step_definitions/extra_steps.rb +0 -2
  149. data/features/step_definitions/simplest_steps.rb +0 -3
  150. data/features/step_definitions/wire_steps.rb +0 -32
  151. data/features/support/env.rb.simplest +0 -7
  152. data/features/support/fake_wire_server.rb +0 -77
  153. data/features/table_diffing.feature +0 -45
  154. data/features/table_mapping.feature +0 -34
  155. data/features/tag_logic.feature +0 -258
  156. data/features/transform.feature +0 -245
  157. data/features/unicode_table.feature +0 -35
  158. data/features/usage_and_stepdefs_formatter.feature +0 -169
  159. data/features/wire_protocol.feature +0 -332
  160. data/features/wire_protocol_table_diffing.feature +0 -119
  161. data/features/wire_protocol_tags.feature +0 -87
  162. data/features/wire_protocol_timeouts.feature +0 -63
  163. data/features/work_in_progress.feature +0 -156
  164. data/fixtures/json/features/pystring.feature +0 -8
  165. data/fixtures/self_test/features/background/background_tagged_before_on_outline.feature +0 -12
  166. data/fixtures/self_test/features/background/background_with_name.feature +0 -7
  167. data/fixtures/self_test/features/background/failing_background.feature +0 -12
  168. data/fixtures/self_test/features/background/failing_background_after_success.feature +0 -11
  169. data/fixtures/self_test/features/background/multiline_args_background.feature +0 -32
  170. data/fixtures/self_test/features/background/passing_background.feature +0 -10
  171. data/fixtures/self_test/features/background/pending_background.feature +0 -10
  172. data/fixtures/self_test/features/background/scenario_outline_failing_background.feature +0 -16
  173. data/fixtures/self_test/features/background/scenario_outline_passing_background.feature +0 -16
  174. data/gem_tasks/features.rake +0 -14
  175. data/gem_tasks/sdoc.rake +0 -12
  176. data/lib/cucumber/ast/py_string.rb +0 -80
  177. data/lib/cucumber/formatter/color_io.rb +0 -23
  178. data/lib/cucumber/formatter/tag_cloud.rb +0 -35
  179. data/spec/cucumber/ast/py_string_spec.rb +0 -40
  180. data/spec/cucumber/formatter/color_io_spec.rb +0 -29
  181. data/spec/cucumber/step_mother_spec.rb +0 -302
@@ -1,10 +1,13 @@
1
+ require 'yaml'
2
+ require 'erb'
3
+
1
4
  module Cucumber
2
5
  module WireSupport
3
6
  class Configuration
4
7
  attr_reader :host, :port
5
8
 
6
9
  def initialize(wire_file)
7
- params = YAML.load_file(wire_file)
10
+ params = YAML.load(ERB.new(File.read(wire_file)).result)
8
11
  @host = params['host']
9
12
  @port = params['port']
10
13
  @timeouts = default_timeouts.merge(params['timeout'] || {})
@@ -1,12 +1,5 @@
1
1
  require 'socket'
2
- begin
3
- require 'json'
4
- rescue LoadError
5
- STDERR.puts <<-EOM
6
- You must gem install #{defined?(JRUBY_VERSION) ? 'json_pure' : 'json'} before you can use the wire support.
7
- EOM
8
- exit(1)
9
- end
2
+ require 'json'
10
3
  require 'cucumber/wire_support/connection'
11
4
  require 'cucumber/wire_support/configuration'
12
5
  require 'cucumber/wire_support/wire_packet'
@@ -33,9 +26,9 @@ module Cucumber
33
26
  @connections << Connection.new(config)
34
27
  end
35
28
 
36
- def snippet_text(step_keyword, step_name, multiline_arg_class)
29
+ def snippet_text(code_keyword, step_name, multiline_arg_class)
37
30
  snippets = @connections.map do |remote|
38
- remote.snippet_text(step_keyword, step_name, multiline_arg_class.to_s)
31
+ remote.snippet_text(code_keyword, step_name, multiline_arg_class.to_s)
39
32
  end
40
33
  snippets.flatten.join("\n")
41
34
  end
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
1
+ require 'spec_helper'
2
2
  require 'cucumber/ast'
3
3
  require 'cucumber/rb_support/rb_language'
4
4
 
@@ -8,8 +8,8 @@ module Cucumber
8
8
 
9
9
  before do
10
10
  extend(Cucumber::RbSupport::RbDsl)
11
- @step_mother = Cucumber::StepMother.new
12
- @rb = @step_mother.load_programming_language('rb')
11
+ @runtime = Cucumber::Runtime.new
12
+ @rb = @runtime.load_programming_language('rb')
13
13
 
14
14
  $x = $y = nil
15
15
  Before do
@@ -19,7 +19,7 @@ module Cucumber
19
19
  $y = $x * n.to_i
20
20
  end
21
21
 
22
- @visitor = TreeWalker.new(@step_mother)
22
+ @visitor = TreeWalker.new(@runtime)
23
23
 
24
24
  @feature = mock('feature', :visit? => true).as_null_object
25
25
  end
@@ -29,7 +29,8 @@ module Cucumber
29
29
  comment=Comment.new(''),
30
30
  line=2,
31
31
  keyword="",
32
- name="",
32
+ title="",
33
+ description="",
33
34
  steps=[
34
35
  Step.new(7, "Given", "y is 5")
35
36
  ])
@@ -40,7 +41,8 @@ module Cucumber
40
41
  tags=Tags.new(98,[]),
41
42
  line=99,
42
43
  keyword="",
43
- name="",
44
+ title="",
45
+ description="",
44
46
  steps=[]
45
47
  )
46
48
  background.feature = @feature
@@ -48,6 +50,66 @@ module Cucumber
48
50
  $x.should == 2
49
51
  $y.should == 10
50
52
  end
53
+
54
+ describe "should respond to #name" do
55
+ it "with a value" do
56
+ background = Background.new(
57
+ comment=Comment.new(''),
58
+ line=2,
59
+ keyword="",
60
+ title="background name",
61
+ description="",
62
+ steps=[])
63
+ lambda{ background.name }.should_not raise_error
64
+ background.name.should == 'background name'
65
+ end
66
+ it "without a value" do
67
+ background = Background.new(
68
+ comment=Comment.new(''),
69
+ line=2,
70
+ keyword="",
71
+ title="",
72
+ description="",
73
+ steps=[])
74
+ lambda{ background.name }.should_not raise_error
75
+ end
76
+ end
77
+
78
+ describe "failures in a Before hook" do
79
+
80
+ before do
81
+ Before do
82
+ raise Exception, "Exception from Before hook"
83
+ end
84
+ end
85
+
86
+ it "should state that the background has failed" do
87
+ # Assign
88
+ background = Background.new(
89
+ comment=Comment.new(''),
90
+ line=2,
91
+ keyword="",
92
+ title="",
93
+ description="",
94
+ steps=[
95
+ Step.new(7, "Given", "y is 5")
96
+ ])
97
+ background.feature = @feature
98
+
99
+ # Expect
100
+ @visitor.should_receive( :visit_exception ) do |exception, status|
101
+ exception.should be_instance_of( Exception )
102
+ exception.message.should == "Exception from Before hook"
103
+ status.should == :failed
104
+ end
105
+
106
+ # Assert
107
+ lambda{ @visitor.visit_background(background) }.should_not raise_error
108
+ background.should be_failed
109
+ end
110
+
111
+ end
51
112
  end
113
+
52
114
  end
53
115
  end
@@ -24,9 +24,9 @@ module Cucumber
24
24
  %w{1 22 333},
25
25
  %w{4444 55555 666666}
26
26
  ])
27
- py_string = Ast::PyString.new(%{\n I like\nCucumber sandwich\n})
27
+ doc_string = Ast::DocString.new(%{\n I like\nCucumber sandwich\n})
28
28
 
29
- background = Ast::Background.new(Ast::Comment.new(""), 2, "Background:", "",
29
+ background = Ast::Background.new(Ast::Comment.new(""), 2, "Background:", "", "",
30
30
  [
31
31
  Step.new(3, "Given", "a passing step")
32
32
  ]
@@ -38,15 +38,16 @@ module Cucumber
38
38
  Ast::Tags.new(6, ['one', 'two']),
39
39
  "Feature",
40
40
  "Pretty printing",
41
+ "",
41
42
  [Ast::Scenario.new(
42
43
  background,
43
44
  Ast::Comment.new(" # My scenario comment \n# On two lines \n"),
44
45
  Ast::Tags.new(8, ['three', 'four']),
45
46
  9,
46
- "Scenario:", "A Scenario",
47
+ "Scenario:", "A Scenario", "",
47
48
  [
48
49
  Step.new(10, "Given", "a passing step with an inline arg:", table),
49
- Step.new(11, "Given", "a happy step with an inline arg:", py_string),
50
+ Step.new(11, "Given", "a happy step with an inline arg:", doc_string),
50
51
  Step.new(12, "Given", "a failing step")
51
52
  ]
52
53
  )]
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
1
+ require 'spec_helper'
2
2
  require 'cucumber/ast/feature_factory'
3
3
 
4
4
  module Cucumber
@@ -7,7 +7,7 @@ module Cucumber
7
7
  include FeatureFactory
8
8
 
9
9
  it "should convert to sexp" do
10
- step_mother = Cucumber::StepMother.new
10
+ step_mother = Cucumber::Runtime.new
11
11
  step_mother.load_programming_language('rb')
12
12
  dsl = Object.new
13
13
  dsl.extend Cucumber::RbSupport::RbDsl
@@ -40,12 +40,12 @@ module Cucumber
40
40
  [:row, -1,
41
41
  [:cell, "4444"], [:cell, "55555"], [:cell, "666666"]]]],
42
42
  [:step_invocation, 11, "Given", "a happy step with an inline arg:",
43
- [:py_string, "\n I like\nCucumber sandwich\n"]],
43
+ [:doc_string, "\n I like\nCucumber sandwich\n"]],
44
44
  [:step_invocation, 12, "Given", "a failing step"]]]
45
45
  end
46
46
 
47
47
  it "should store OS specific file paths" do
48
- step_mother = Cucumber::StepMother.new
48
+ step_mother = Cucumber::Runtime.new
49
49
  step_mother.load_programming_language('rb')
50
50
  dsl = Object.new
51
51
  dsl.extend Cucumber::RbSupport::RbDsl
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
1
+ require 'spec_helper'
2
2
 
3
3
  module Cucumber::Ast
4
4
  describe OutlineTable do
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
1
+ require 'spec_helper'
2
2
  require 'cucumber/step_mother'
3
3
  require 'cucumber/ast'
4
4
  require 'cucumber/core_ext/string'
@@ -8,7 +8,7 @@ module Cucumber
8
8
  module Ast
9
9
  describe ScenarioOutline do
10
10
  before do
11
- @step_mother = Cucumber::StepMother.new
11
+ @step_mother = Cucumber::Runtime.new
12
12
  @step_mother.load_programming_language('rb')
13
13
  @dsl = Object.new
14
14
  @dsl.extend(Cucumber::RbSupport::RbDsl)
@@ -31,7 +31,7 @@ module Cucumber
31
31
  Comment.new(""),
32
32
  Tags.new(18, []),
33
33
  19,
34
- "Scenario:", "My outline",
34
+ "Scenario:", "My outline", "",
35
35
  [
36
36
  Step.new(20, 'Given', 'there are <start> cucumbers'),
37
37
  Step.new(21, 'When', 'I eat <eat> cucumbers'),
@@ -40,15 +40,19 @@ module Cucumber
40
40
  ],
41
41
  [
42
42
  [
43
- Comment.new("#Mmmm... cucumbers\n"),
44
- 24,
45
- 'Examples:',
46
- 'First table',
47
43
  [
48
- %w{start eat left},
49
- %w{12 5 7},
50
- %w{20 6 14}
51
- ]
44
+ Comment.new("#Mmmm... cucumbers\n"),
45
+ 24,
46
+ 'Examples:',
47
+ 'First table',
48
+ '',
49
+ [
50
+ %w{start eat left},
51
+ %w{12 5 7},
52
+ %w{20 6 14}
53
+ ]
54
+ ],
55
+ Gherkin::Formatter::Model::Examples.new(nil, nil, nil, nil, nil, nil)
52
56
  ]
53
57
  ]
54
58
 
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
1
+ require 'spec_helper'
2
2
  require 'cucumber/step_mother'
3
3
  require 'cucumber/ast'
4
4
  require 'cucumber/rb_support/rb_language'
@@ -7,7 +7,7 @@ module Cucumber
7
7
  module Ast
8
8
  describe Scenario do
9
9
  before do
10
- @step_mother = Cucumber::StepMother.new
10
+ @step_mother = Cucumber::Runtime.new
11
11
  @step_mother.load_programming_language('rb')
12
12
  @dsl = Object.new
13
13
  @dsl.extend(Cucumber::RbSupport::RbDsl)
@@ -17,7 +17,6 @@ module Cucumber
17
17
  $y = n.to_i
18
18
  end
19
19
  @visitor = TreeWalker.new(@step_mother)
20
- @visitor.options = {}
21
20
  end
22
21
 
23
22
  it "should skip steps when previous is not passed" do
@@ -27,7 +26,8 @@ module Cucumber
27
26
  tags=Tags.new(98, []),
28
27
  line=99,
29
28
  keyword="",
30
- name="",
29
+ title="",
30
+ description="",
31
31
  steps=[
32
32
  Step.new(7, "Given", "this is missing"),
33
33
  Step.new(8, "Given", "y is 5")
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
1
+ require 'spec_helper'
2
2
  require 'cucumber/step_mother'
3
3
  require 'cucumber/ast'
4
4
  require 'cucumber/core_ext/string'
@@ -48,9 +48,9 @@ module Cucumber
48
48
  end
49
49
 
50
50
  it "should replace arguments in py string arg" do
51
- py_string = PyString.new('taste_<taste> color_<color>')
51
+ doc_string = DocString.new('taste_<taste> color_<color>')
52
52
 
53
- step = Step.new(1, 'Given', 'a <color> cucumber', py_string)
53
+ step = Step.new(1, 'Given', 'a <color> cucumber', doc_string)
54
54
 
55
55
  invocation_table = Table.new([
56
56
  %w{color taste},
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+ require 'spec_helper'
3
3
  require 'cucumber/ast/table'
4
4
 
5
5
  module Cucumber
@@ -45,11 +45,26 @@ module Cucumber
45
45
  @table.hashes.first[:one].should == '4444'
46
46
  end
47
47
 
48
- it "should allow map'ing columns" do
48
+ it "should allow mapping columns" do
49
49
  @table.map_column!('one') { |v| v.to_i }
50
50
  @table.hashes.first['one'].should == 4444
51
51
  end
52
52
 
53
+ it "should allow mapping columns and take a symbol as the column name" do
54
+ @table.map_column!(:one) { |v| v.to_i }
55
+ @table.hashes.first['one'].should == 4444
56
+ end
57
+
58
+ it "should allow mapping columns and modify the rows as well" do
59
+ @table.map_column!(:one) { |v| v.to_i }
60
+ @table.rows.first.should include(4444)
61
+ @table.rows.first.should_not include('4444')
62
+ end
63
+
64
+ it "should return the row values in order" do
65
+ @table.rows.first.should == %w{4444 55555 666666}
66
+ end
67
+
53
68
  it "should pass silently if a mapped column does not exist in non-strict mode" do
54
69
  lambda {
55
70
  @table.map_column!('two', false) { |v| v.to_i }
@@ -62,6 +77,10 @@ module Cucumber
62
77
  }.should raise_error('The column named "two" does not exist')
63
78
  end
64
79
 
80
+ it "should return the table" do
81
+ (@table.map_column!(:one) { |v| v.to_i }).should == @table
82
+ end
83
+
65
84
  describe "#match" do
66
85
  before(:each) do
67
86
  @table = Table.new([
@@ -335,6 +354,23 @@ module Cucumber
335
354
  }
336
355
  end
337
356
 
357
+ it "should detect seemingly identical tables as different" do
358
+ t1 = Table.new([
359
+ ['X', 'Y'],
360
+ ['2', '1']
361
+ ])
362
+ t2 = Table.new([
363
+ ['X', 'Y'],
364
+ [2, 1]
365
+ ])
366
+ lambda{t1.diff!(t2)}.should raise_error
367
+ t1.to_s(:indent => 12, :color => false).should == %{
368
+ | X | Y |
369
+ | (-) (i) "2" | (-) (i) "1" |
370
+ | (+) (i) 2 | (+) (i) 1 |
371
+ }
372
+ end
373
+
338
374
  it "should not allow mappings that match more than 1 column" do
339
375
  t1 = Table.new([
340
376
  ['Cuke', 'Duke'],
@@ -1,9 +1,9 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
1
+ require 'spec_helper'
2
2
 
3
3
  module Cucumber::Ast
4
4
  describe TreeWalker do
5
5
  it "should visit features" do
6
- tw = TreeWalker.new(nil, [mock('listener', :before_visit_features => nil)], {})
6
+ tw = TreeWalker.new(nil, [mock('listener', :before_visit_features => nil)])
7
7
  tw.should_not_receive(:warn)
8
8
  tw.visit_features(mock('features', :accept => nil))
9
9
  end
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
1
+ require 'spec_helper'
2
2
 
3
3
  module Cucumber
4
4
  describe Broadcaster do
@@ -1,9 +1,12 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
1
+ require '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
7
10
 
8
11
  def given_cucumber_yml_defined_as(hash_or_string)
9
12
  File.stub!(:exist?).and_return(true)
@@ -23,7 +26,7 @@ module Cli
23
26
  end
24
27
 
25
28
  def config
26
- @config ||= Configuration.new(@out = StringIO.new, @error = StringIO.new)
29
+ @config ||= Configuration.new(@out = StringIO.new, @error = StringIO.new).extend(ExposesOptions)
27
30
  end
28
31
 
29
32
  def reset_config
@@ -287,17 +290,17 @@ END_OF_MESSAGE
287
290
 
288
291
  it "should accept --out option" do
289
292
  config.parse!(%w{--out jalla.txt})
290
- config.options[:formats].should == [['pretty', 'jalla.txt']]
293
+ config.formats.should == [['pretty', 'jalla.txt']]
291
294
  end
292
295
 
293
296
  it "should accept multiple --out options" do
294
297
  config.parse!(%w{--format progress --out file1 --out file2})
295
- config.options[:formats].should == [['progress', 'file2']]
298
+ config.formats.should == [['progress', 'file2']]
296
299
  end
297
300
 
298
301
  it "should accept multiple --format options and put the STDOUT one first so progress is seen" do
299
302
  config.parse!(%w{--format pretty --out pretty.txt --format progress})
300
- config.options[:formats].should == [['progress', out], ['pretty', 'pretty.txt']]
303
+ config.formats.should == [['progress', out], ['pretty', 'pretty.txt']]
301
304
  end
302
305
 
303
306
  it "should not accept multiple --format options when both use implicit STDOUT" do
@@ -314,7 +317,7 @@ END_OF_MESSAGE
314
317
 
315
318
  it "should associate --out to previous --format" do
316
319
  config.parse!(%w{--format progress --out file1 --format profile --out file2})
317
- config.options[:formats].should == [["progress", "file1"], ["profile" ,"file2"]]
320
+ config.formats.should == [["progress", "file1"], ["profile" ,"file2"]]
318
321
  end
319
322
 
320
323
  it "should accept --color option" do
@@ -399,7 +402,30 @@ END_OF_MESSAGE
399
402
  ENV["RAILS_ENV"].should == "selenium"
400
403
  config.feature_files.should_not include('RAILS_ENV=selenium')
401
404
  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
402
411
 
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
403
429
  end
404
430
  end
405
431
  end