square-cucumber 0.3.12.2 → 0.3.93.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. data/History.txt +117 -4
  2. data/Manifest.txt +11 -0
  3. data/Rakefile +1 -1
  4. data/config/hoe.rb +3 -2
  5. data/cucumber.yml +2 -2
  6. data/examples/i18n/ko/features/addition.feature +5 -5
  7. data/examples/i18n/ko/features/step_definitons/calculator_steps.rb +1 -1
  8. data/examples/i18n/no/features/step_definitons/kalkulator_steps.rb +1 -1
  9. data/examples/i18n/pt/features/adicao.feature +4 -4
  10. data/examples/self_test/features/support/env.rb +2 -1
  11. data/examples/sinatra/features/support/env.rb +7 -1
  12. data/examples/steps_library/features/step_definitions/steps_lib1.rb +8 -0
  13. data/examples/steps_library/features/step_definitions/steps_lib2.rb +8 -0
  14. data/examples/tickets/features/step_definitons/tickets_steps.rb +15 -0
  15. data/examples/tickets/features/table_diffing.feature +13 -0
  16. data/examples/watir/features/step_definitons/search_steps.rb +5 -1
  17. data/features/cucumber_cli_diff_disabled.feature +2 -1
  18. data/features/html_formatter/a.html +5 -7
  19. data/features/junit_formatter.feature +21 -14
  20. data/features/profiles.feature +99 -0
  21. data/features/rake_task.feature +28 -0
  22. data/features/step_definitions/cucumber_steps.rb +28 -15
  23. data/features/steps_formatter.feature +25 -0
  24. data/features/support/env.rb +9 -5
  25. data/features/table_diffing.feature +45 -0
  26. data/features/unicode_table.feature +35 -0
  27. data/features/work_in_progress.feature +1 -0
  28. data/gem_tasks/contributors.rake +4 -0
  29. data/lib/cucumber/ast/background.rb +1 -0
  30. data/lib/cucumber/ast/comment.rb +1 -0
  31. data/lib/cucumber/ast/examples.rb +1 -0
  32. data/lib/cucumber/ast/feature.rb +10 -0
  33. data/lib/cucumber/ast/features.rb +6 -1
  34. data/lib/cucumber/ast/outline_table.rb +4 -1
  35. data/lib/cucumber/ast/py_string.rb +1 -1
  36. data/lib/cucumber/ast/scenario.rb +1 -0
  37. data/lib/cucumber/ast/scenario_outline.rb +2 -0
  38. data/lib/cucumber/ast/step.rb +5 -1
  39. data/lib/cucumber/ast/step_collection.rb +1 -0
  40. data/lib/cucumber/ast/step_invocation.rb +1 -0
  41. data/lib/cucumber/ast/table.rb +306 -52
  42. data/lib/cucumber/ast/tags.rb +1 -0
  43. data/lib/cucumber/ast/visitor.rb +2 -1
  44. data/lib/cucumber/cli/configuration.rb +28 -278
  45. data/lib/cucumber/cli/drb_client.rb +3 -1
  46. data/lib/cucumber/cli/language_help_formatter.rb +9 -7
  47. data/lib/cucumber/cli/main.rb +16 -2
  48. data/lib/cucumber/cli/options.rb +370 -0
  49. data/lib/cucumber/cli/profile_loader.rb +65 -0
  50. data/lib/cucumber/core_ext/instance_exec.rb +8 -5
  51. data/lib/cucumber/feature_file.rb +7 -1
  52. data/lib/cucumber/filter.rb +2 -2
  53. data/lib/cucumber/formatter/ansicolor.rb +42 -9
  54. data/lib/cucumber/formatter/console.rb +1 -1
  55. data/lib/cucumber/formatter/html.rb +12 -10
  56. data/lib/cucumber/formatter/junit.rb +63 -26
  57. data/lib/cucumber/formatter/pretty.rb +20 -5
  58. data/lib/cucumber/formatter/progress.rb +1 -1
  59. data/lib/cucumber/formatter/steps.rb +49 -0
  60. data/lib/cucumber/languages.yml +6 -6
  61. data/lib/cucumber/parser/feature.rb +90 -63
  62. data/lib/cucumber/parser/feature.tt +28 -1
  63. data/lib/cucumber/parser/i18n/language.rb +12 -5
  64. data/lib/cucumber/parser/table.rb +25 -25
  65. data/lib/cucumber/rake/task.rb +9 -3
  66. data/lib/cucumber/step_definition.rb +1 -1
  67. data/lib/cucumber/step_match.rb +1 -1
  68. data/lib/cucumber/step_mother.rb +3 -1
  69. data/lib/cucumber/version.rb +2 -2
  70. data/lib/cucumber/webrat/table_locator.rb +66 -0
  71. data/rails_generators/cucumber/cucumber_generator.rb +5 -1
  72. data/rails_generators/cucumber/templates/cucumber +3 -2
  73. data/rails_generators/cucumber/templates/cucumber.rake +18 -6
  74. data/rails_generators/cucumber/templates/cucumber_environment.rb +7 -4
  75. data/rails_generators/cucumber/templates/env.rb +1 -0
  76. data/rails_generators/cucumber/templates/spork_env.rb +1 -0
  77. data/rails_generators/cucumber/templates/webrat_steps.rb +22 -0
  78. data/rails_generators/feature/templates/feature.erb +1 -1
  79. data/rails_generators/feature/templates/steps.erb +2 -8
  80. data/spec/cucumber/ast/table_spec.rb +169 -0
  81. data/spec/cucumber/cli/configuration_spec.rb +144 -101
  82. data/spec/cucumber/cli/main_spec.rb +14 -5
  83. data/spec/cucumber/cli/options_spec.rb +311 -0
  84. data/spec/cucumber/cli/profile_loader_spec.rb +10 -0
  85. data/spec/cucumber/core_ext/proc_spec.rb +16 -2
  86. data/spec/cucumber/formatter/html_spec.rb +18 -0
  87. data/spec/cucumber/formatter/progress_spec.rb +2 -2
  88. data/spec/cucumber/parser/table_parser_spec.rb +1 -1
  89. data/spec/spec.opts +3 -1
  90. metadata +18 -4
  91. data/lib/cucumber/webrat/mechanize_world.rb +0 -82
@@ -21,7 +21,11 @@ module Cucumber
21
21
  def has_tags?(tag_names)
22
22
  tags.has_tags?(tag_names)
23
23
  end
24
-
24
+
25
+ def has_all_tags?(tag_names)
26
+ tags.has_all_tags?(tag_names)
27
+ end
28
+
25
29
  def build(filter)
26
30
  if(filter.nil? || feature_elements.accept?(filter) || (!bg.empty? && filter.accept?(bg)))
27
31
  background = bg.respond_to?(:build) ? bg.build : nil
@@ -47,6 +51,10 @@ module Cucumber
47
51
  (tag_names & tags).any?
48
52
  end
49
53
 
54
+ def has_all_tags?(tags)
55
+ (tags & tag_names) == tags
56
+ end
57
+
50
58
  def build
51
59
  Ast::Tags.new(ts.line, tag_names)
52
60
  end
@@ -89,6 +97,11 @@ module Cucumber
89
97
  feature_tags.has_tags?(tag_names)
90
98
  end
91
99
 
100
+ def has_all_tags?(tag_names)
101
+ feature_tags = self.parent.tags
102
+ feature_tags.has_all_tags?(tag_names)
103
+ end
104
+
92
105
  def build
93
106
  Ast::Background.new(
94
107
  comment.build,
@@ -130,6 +143,11 @@ module Cucumber
130
143
  tags.has_tags?(tag_names) || feature_tags.has_tags?(tag_names)
131
144
  end
132
145
 
146
+ def has_all_tags?(tag_names)
147
+ feature_tags = self.parent.parent.tags
148
+ tags.has_all_tags?(tag_names) || feature_tags.has_all_tags?(tag_names)
149
+ end
150
+
133
151
  def matches_name?(regexp_to_match)
134
152
  name.build =~ regexp_to_match
135
153
  end
@@ -166,6 +184,11 @@ module Cucumber
166
184
  tags.has_tags?(tag_names) || feature_tags.has_tags?(tag_names)
167
185
  end
168
186
 
187
+ def has_all_tags?(tag_names)
188
+ feature_tags = self.parent.parent.tags
189
+ tags.has_all_tags?(tag_names) || feature_tags.has_all_tags?(tag_names)
190
+ end
191
+
169
192
  def matches_name?(regexp_to_match)
170
193
  outline_matches_name?(regexp_to_match) || examples_sections.matches_name?(regexp_to_match)
171
194
  end
@@ -249,6 +272,10 @@ module Cucumber
249
272
  true
250
273
  end
251
274
 
275
+ def has_all_tags?(tag_names)
276
+ true
277
+ end
278
+
252
279
  def outline_at_line?(line)
253
280
  true
254
281
  end
@@ -32,34 +32,41 @@ module Cucumber
32
32
 
33
33
  alias_step_definitions(Cucumber::LANGUAGES['en'])
34
34
 
35
- attr_reader :parser
36
-
37
35
  def initialize(lang)
38
36
  @keywords = Cucumber::LANGUAGES[lang]
39
37
  raise "Language not supported: #{lang.inspect}" if @keywords.nil?
40
38
  @keywords['grammar_name'] = @keywords['name'].gsub(/\s/, '')
39
+ end
40
+
41
+ def parser
42
+ return @parser if @parser
41
43
  i18n_tt = File.expand_path(File.dirname(__FILE__) + '/../i18n.tt')
42
44
  template = File.open(i18n_tt, Cucumber.file_mode('r')).read
43
45
  erb = ERB.new(template)
44
46
  grammar = erb.result(binding)
45
47
  Treetop.load_from_string(grammar)
46
- @parser = Parser::I18n.const_get("#{@keywords['grammar_name']}Parser").new
47
48
  self.class.alias_step_definitions(@keywords)
49
+ @parser = Parser::I18n.const_get("#{@keywords['grammar_name']}Parser").new
50
+ def @parser.inspect
51
+ "#<#{self.class.name}>"
52
+ end
53
+ @parser
48
54
  end
49
55
 
50
56
  def parse(source, path, filter)
51
- feature = @parser.parse_or_fail(source, path, filter)
57
+ feature = parser.parse_or_fail(source, path, filter)
52
58
  feature.language = self if feature
53
59
  feature
54
60
  end
55
61
 
56
62
  def keywords(key, raw=false)
57
63
  return @keywords[key] if raw
64
+ return nil unless @keywords[key]
58
65
  values = @keywords[key].split('|')
59
66
  values.map{|value| "'#{value}'"}.join(" / ")
60
67
  end
61
68
 
62
- def language_incomplete?
69
+ def incomplete?
63
70
  KEYWORD_KEYS.detect{|key| @keywords[key].nil?}
64
71
  end
65
72
 
@@ -49,7 +49,7 @@ module Cucumber
49
49
  end
50
50
  end
51
51
  if s0.empty?
52
- self.index = i0
52
+ @index = i0
53
53
  r0 = nil
54
54
  else
55
55
  r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
@@ -58,7 +58,7 @@ module Cucumber
58
58
 
59
59
  node_cache[:table][start_index] = r0
60
60
 
61
- return r0
61
+ r0
62
62
  end
63
63
 
64
64
  module TableRow0
@@ -116,7 +116,7 @@ module Cucumber
116
116
  r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
117
117
  s0 << r1
118
118
  if r1
119
- if input.index('|', index) == index
119
+ if has_terminal?('|', false, index)
120
120
  r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
121
121
  @index += 1
122
122
  else
@@ -131,7 +131,7 @@ module Cucumber
131
131
  r6 = _nt_cell
132
132
  s5 << r6
133
133
  if r6
134
- if input.index('|', index) == index
134
+ if has_terminal?('|', false, index)
135
135
  r7 = instantiate_node(SyntaxNode,input, index...(index + 1))
136
136
  @index += 1
137
137
  else
@@ -144,7 +144,7 @@ module Cucumber
144
144
  r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
145
145
  r5.extend(TableRow0)
146
146
  else
147
- self.index = i5
147
+ @index = i5
148
148
  r5 = nil
149
149
  end
150
150
  if r5
@@ -154,7 +154,7 @@ module Cucumber
154
154
  end
155
155
  end
156
156
  if s4.empty?
157
- self.index = i4
157
+ @index = i4
158
158
  r4 = nil
159
159
  else
160
160
  r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
@@ -184,7 +184,7 @@ module Cucumber
184
184
  end
185
185
  end
186
186
  if s11.empty?
187
- self.index = i11
187
+ @index = i11
188
188
  r11 = nil
189
189
  else
190
190
  r11 = instantiate_node(SyntaxNode,input, i11...index, s11)
@@ -196,7 +196,7 @@ module Cucumber
196
196
  if r13
197
197
  r10 = r13
198
198
  else
199
- self.index = i10
199
+ @index = i10
200
200
  r10 = nil
201
201
  end
202
202
  end
@@ -210,13 +210,13 @@ module Cucumber
210
210
  r0.extend(TableRow1)
211
211
  r0.extend(TableRow2)
212
212
  else
213
- self.index = i0
213
+ @index = i0
214
214
  r0 = nil
215
215
  end
216
216
 
217
217
  node_cache[:table_row][start_index] = r0
218
218
 
219
- return r0
219
+ r0
220
220
  end
221
221
 
222
222
  module Cell0
@@ -235,7 +235,7 @@ module Cucumber
235
235
  i1, s1 = index, []
236
236
  i2 = index
237
237
  i3 = index
238
- if input.index('|', index) == index
238
+ if has_terminal?('|', false, index)
239
239
  r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
240
240
  @index += 1
241
241
  else
@@ -249,14 +249,14 @@ module Cucumber
249
249
  if r5
250
250
  r3 = r5
251
251
  else
252
- self.index = i3
252
+ @index = i3
253
253
  r3 = nil
254
254
  end
255
255
  end
256
256
  if r3
257
257
  r2 = nil
258
258
  else
259
- self.index = i2
259
+ @index = i2
260
260
  r2 = instantiate_node(SyntaxNode,input, index...index)
261
261
  end
262
262
  s1 << r2
@@ -274,7 +274,7 @@ module Cucumber
274
274
  r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
275
275
  r1.extend(Cell0)
276
276
  else
277
- self.index = i1
277
+ @index = i1
278
278
  r1 = nil
279
279
  end
280
280
  if r1
@@ -287,7 +287,7 @@ module Cucumber
287
287
 
288
288
  node_cache[:cell][start_index] = r0
289
289
 
290
- return r0
290
+ r0
291
291
  end
292
292
 
293
293
  def _nt_space
@@ -298,7 +298,7 @@ module Cucumber
298
298
  return cached
299
299
  end
300
300
 
301
- if input.index(Regexp.new('[ \\t]'), index) == index
301
+ if has_terminal?('\G[ \\t]', true, index)
302
302
  r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
303
303
  @index += 1
304
304
  else
@@ -307,7 +307,7 @@ module Cucumber
307
307
 
308
308
  node_cache[:space][start_index] = r0
309
309
 
310
- return r0
310
+ r0
311
311
  end
312
312
 
313
313
  module Eol0
@@ -322,7 +322,7 @@ module Cucumber
322
322
  end
323
323
 
324
324
  i0 = index
325
- if input.index("\n", index) == index
325
+ if has_terminal?("\n", false, index)
326
326
  r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
327
327
  @index += 1
328
328
  else
@@ -333,7 +333,7 @@ module Cucumber
333
333
  r0 = r1
334
334
  else
335
335
  i2, s2 = index, []
336
- if input.index("\r", index) == index
336
+ if has_terminal?("\r", false, index)
337
337
  r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
338
338
  @index += 1
339
339
  else
@@ -342,7 +342,7 @@ module Cucumber
342
342
  end
343
343
  s2 << r3
344
344
  if r3
345
- if input.index("\n", index) == index
345
+ if has_terminal?("\n", false, index)
346
346
  r5 = instantiate_node(SyntaxNode,input, index...(index + 1))
347
347
  @index += 1
348
348
  else
@@ -360,20 +360,20 @@ module Cucumber
360
360
  r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
361
361
  r2.extend(Eol0)
362
362
  else
363
- self.index = i2
363
+ @index = i2
364
364
  r2 = nil
365
365
  end
366
366
  if r2
367
367
  r0 = r2
368
368
  else
369
- self.index = i0
369
+ @index = i0
370
370
  r0 = nil
371
371
  end
372
372
  end
373
373
 
374
374
  node_cache[:eol][start_index] = r0
375
375
 
376
- return r0
376
+ r0
377
377
  end
378
378
 
379
379
  def _nt_eof
@@ -395,13 +395,13 @@ module Cucumber
395
395
  if r1
396
396
  r0 = nil
397
397
  else
398
- self.index = i0
398
+ @index = i0
399
399
  r0 = instantiate_node(SyntaxNode,input, index...index)
400
400
  end
401
401
 
402
402
  node_cache[:eof][start_index] = r0
403
403
 
404
- return r0
404
+ r0
405
405
  end
406
406
 
407
407
  end
@@ -8,8 +8,8 @@ module Cucumber
8
8
  #
9
9
  # Cucumber::Rake::Task.new
10
10
  #
11
- # This will create a task named 'features' described as 'Run Features with
12
- # Cucumber'. It will use steps from 'features/**/*.rb' and features in 'features/**/*.feature'.
11
+ # This will create a task named 'cucumber' described as 'Run Cucumber features'.
12
+ # It will use steps from 'features/**/*.rb' and features in 'features/**/*.feature'.
13
13
  #
14
14
  # To further configure the task, you can pass a block:
15
15
  #
@@ -148,7 +148,7 @@ module Cucumber
148
148
  end
149
149
 
150
150
  # Define Cucumber Rake task
151
- def initialize(task_name = "features", desc = "Run Features with Cucumber")
151
+ def initialize(task_name = "cucumber", desc = "Run Cucumber features")
152
152
  @task_name, @desc = task_name, desc
153
153
  @fork = true
154
154
  @libs = ['lib']
@@ -194,6 +194,7 @@ module Cucumber
194
194
  result = []
195
195
  result += feature_list.to_a if feature_list
196
196
  result += FileList[feature_pattern].to_a if feature_pattern
197
+ result = make_command_line_safe(result)
197
198
  FileList[result]
198
199
  end
199
200
  end
@@ -208,6 +209,11 @@ module Cucumber
208
209
  FileList[result]
209
210
  end
210
211
  end
212
+
213
+ private
214
+ def make_command_line_safe(list)
215
+ list.map{|string| string.gsub(' ', '\ ')}
216
+ end
211
217
  end
212
218
 
213
219
  class FeatureTask < Task
@@ -86,7 +86,7 @@ module Cucumber
86
86
 
87
87
  include StepDefinitionMethods
88
88
 
89
- attr_reader :regexp, :proc
89
+ attr_reader :proc
90
90
 
91
91
  def initialize(pattern, &proc)
92
92
  raise MissingProc if proc.nil?
@@ -34,7 +34,7 @@ module Cucumber
34
34
  end
35
35
 
36
36
  class NoStepMatch
37
- attr_reader :step_definition
37
+ attr_reader :step_definition, :name
38
38
 
39
39
  def initialize(step, name)
40
40
  @step = step
@@ -127,7 +127,9 @@ module Cucumber
127
127
  end
128
128
 
129
129
  # Registers a new StepDefinition. This method is aliased
130
- # to <tt>Given</tt>, <tt>When</tt> and <tt>Then</tt>.
130
+ # to <tt>Given</tt>, <tt>When</tt> and <tt>Then</tt>, and
131
+ # also to the i18n translations whenever a feature of a
132
+ # new language is loaded.
131
133
  #
132
134
  # See Cucumber#alias_steps for details on how to
133
135
  # create your own aliases.
@@ -2,8 +2,8 @@ module Cucumber #:nodoc:
2
2
  class VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 3
5
- TINY = 11
6
- PATCH = 6 # Set to nil for official release
5
+ TINY = 93
6
+ PATCH = 1 # Set to nil for official release
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, PATCH].compact.join('.')
9
9
  end
@@ -0,0 +1,66 @@
1
+ module Webrat
2
+ class Table < Element
3
+ def self.xpath_search
4
+ ".//table"
5
+ end
6
+
7
+ # Converts this Table element into an Array of Array of String where each cell
8
+ # represents the inner_html of the <td> and <th> elements. The number of columns is
9
+ # determined by the number of cells in the first row.
10
+ def to_a
11
+ col_count = nil
12
+ Webrat::XML.css_search(@element, 'tr').map do |row|
13
+ cols = Webrat::XML.css_search(row, 'th,td')
14
+ col_count ||= cols.length
15
+ cols[0...col_count].map do |col|
16
+ col.inner_html
17
+ end
18
+ end
19
+ end
20
+ end
21
+
22
+ module Locators
23
+ class TableLocator < Locator
24
+ def locate
25
+ Table.load(@session, table_element)
26
+ end
27
+
28
+ def table_element
29
+ table_elements.detect do |table_element|
30
+ matches_id?(table_element) ||
31
+ matches_css_selector?(table_element)
32
+ end
33
+ end
34
+
35
+ def matches_id?(table_element)
36
+ Webrat::XML.attribute(table_element, "id") == @value.to_s
37
+ end
38
+
39
+ def matches_css_selector?(table_element)
40
+ Webrat::XML.css_at(@dom, @value)
41
+ end
42
+
43
+ def table_elements
44
+ Webrat::XML.xpath_search(@dom, *Table.xpath_search)
45
+ end
46
+
47
+ def error_message
48
+ "Could not find table matching '#{@value}'"
49
+ end
50
+ end
51
+
52
+ # Returns a Table element located by +id_or_selector+, which can
53
+ # be a DOM id or a CSS selector.
54
+ def table_at(id_or_selector)
55
+ TableLocator.new(@session, dom, id_or_selector).locate!
56
+ end
57
+ end
58
+
59
+ module Methods
60
+ delegate_to_session :table_at
61
+ end
62
+
63
+ class Session
64
+ def_delegators :current_scope, :table_at
65
+ end
66
+ end