aslakhellesoy-cucumber 0.3.0.1 → 0.3.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 (33) hide show
  1. data/History.txt +10 -2
  2. data/Manifest.txt +5 -0
  3. data/examples/self_test/features/background/failing_background.feature +1 -0
  4. data/examples/self_test/features/step_definitions/sample_steps.rb +3 -2
  5. data/examples/tickets/features/236.feature +9 -9
  6. data/examples/tickets/features/301/filter_background_tagged_hooks.feature +6 -0
  7. data/examples/tickets/features/301/filter_background_tagged_hooks_steps.rb +12 -0
  8. data/examples/tickets/features/306/only_background.feature +4 -0
  9. data/features/background.feature +2 -1
  10. data/features/cucumber_cli.feature +58 -12
  11. data/features/cucumber_cli_outlines.feature +32 -0
  12. data/features/custom_formatter.feature +2 -2
  13. data/features/usage.feature +9 -4
  14. data/lib/cucumber/ast/background.rb +9 -9
  15. data/lib/cucumber/ast/feature.rb +5 -0
  16. data/lib/cucumber/ast/feature_element.rb +6 -4
  17. data/lib/cucumber/ast/py_string.rb +5 -1
  18. data/lib/cucumber/ast/scenario.rb +1 -5
  19. data/lib/cucumber/ast/scenario_outline.rb +0 -5
  20. data/lib/cucumber/ast/step.rb +2 -1
  21. data/lib/cucumber/ast/table.rb +4 -0
  22. data/lib/cucumber/ast/visitor.rb +2 -2
  23. data/lib/cucumber/cli/configuration.rb +15 -14
  24. data/lib/cucumber/parser/feature.rb +20 -6
  25. data/lib/cucumber/parser/feature.tt +21 -7
  26. data/lib/cucumber/parser/treetop_ext.rb +3 -3
  27. data/lib/cucumber/rails/world.rb +1 -1
  28. data/lib/cucumber/version.rb +2 -2
  29. data/spec/cucumber/ast/feature_element_spec.rb +5 -0
  30. data/spec/cucumber/ast/py_string_spec.rb +4 -0
  31. data/spec/cucumber/ast/table_spec.rb +14 -2
  32. data/spec/cucumber/cli/configuration_spec.rb +4 -4
  33. metadata +4 -1
data/History.txt CHANGED
@@ -1,6 +1,7 @@
1
- == 0.3.x (In Git)
1
+ == 0.3.1 2009-04-26
2
2
 
3
- With the addition of Latvian and Hungarian Cucumber now supports 32(!!) languages.
3
+ This release has several minor bug fixes and new features. With the addition of Latvian and Hungarian Cucumber
4
+ now supports 32(!!) languages.
4
5
 
5
6
  === New features
6
7
  * Support multiline names for Scenarios, Scenario Outlines, Backgrounds, Examples (#231 Joseph Wilk)
@@ -10,11 +11,18 @@ With the addition of Latvian and Hungarian Cucumber now supports 32(!!) language
10
11
  * Pick up failure on after hook (#272 Aslak Hellesøy)
11
12
 
12
13
  === Bugfixes
14
+ * Pretty formatter not colouring Examples tables correctly (#304 Aslak Hellesøy)
15
+ * Problem using --scenario and Scenario Outline (#298 Aslak Hellesøy)
16
+ * Tag Hook gets executed always there is a background (#301 Aslak Hellesøy)
17
+ * Feature which only has a Background with steps causes an exception (#306 Aslak Hellesøy)
13
18
  * Gem no longer depends on Hoe (Aslak Hellesøy)
14
19
  * Span html tags appear on HTML results with 0.3.0 (#299 Aslak Hellesøy)
15
20
  * Fixed incorrect colours in pretty formatter's table headers for outline tables (Aslak Hellesøy)
16
21
  * Exceptions from steps called within hooks are now reraised. (#294 Ben Mabey)
17
22
 
23
+ === Removed/changed features
24
+ * --scenario handle has been removed and replaced with --name which supports partial matches, regexp special characters, running named backgrounds (#295 Joseph Wilk)
25
+
18
26
  == 0.3.0 2009-04-14
19
27
 
20
28
  This release has some minor changes to the APIs, but big enough that a new major release is in order.
data/Manifest.txt CHANGED
@@ -172,6 +172,7 @@ examples/self_test/features/lots_of_undefined.feature
172
172
  examples/self_test/features/multiline_name.feature
173
173
  examples/self_test/features/outline_sample.feature
174
174
  examples/self_test/features/sample.feature
175
+ examples/self_test/features/search_sample.feature
175
176
  examples/self_test/features/step_definitions/sample_steps.rb
176
177
  examples/self_test/features/support/env.rb
177
178
  examples/self_test/features/support/tag_count_formatter.rb
@@ -206,6 +207,9 @@ examples/tickets/features/272/hooks_steps.rb
206
207
  examples/tickets/features/279/py_string_indent.feature
207
208
  examples/tickets/features/279/py_string_indent.steps.rb
208
209
  examples/tickets/features/279/wrong.feature_
210
+ examples/tickets/features/301/filter_background_tagged_hooks.feature
211
+ examples/tickets/features/301/filter_background_tagged_hooks_steps.rb
212
+ examples/tickets/features/306/only_background.feature
209
213
  examples/tickets/features/lib/eatting_machine.rb
210
214
  examples/tickets/features/lib/pantry.rb
211
215
  examples/tickets/features/scenario_outline.feature
@@ -324,6 +328,7 @@ spec/cucumber/ast/scenario_spec.rb
324
328
  spec/cucumber/ast/step_collection_spec.rb
325
329
  spec/cucumber/ast/step_spec.rb
326
330
  spec/cucumber/ast/table_spec.rb
331
+ spec/cucumber/ast/visitor_spec.rb
327
332
  spec/cucumber/broadcaster_spec.rb
328
333
  spec/cucumber/cli/configuration_spec.rb
329
334
  spec/cucumber/cli/main_spec.rb
@@ -1,3 +1,4 @@
1
+ @after_file
1
2
  Feature: Failing background sample
2
3
 
3
4
  Background:
@@ -69,12 +69,13 @@ end
69
69
  Given /^another unused$/ do
70
70
  end
71
71
 
72
- after_file = File.dirname(__FILE__) + '/../../tmp/after.txt'
72
+ after_file = File.expand_path(File.dirname(__FILE__) + '/../../tmp/after.txt')
73
73
 
74
- Before('@after_file') do
74
+ Before do
75
75
  FileUtils.rm(after_file) if File.exist?(after_file)
76
76
  end
77
77
 
78
78
  After('@after_file') do
79
+ FileUtils.mkdir_p(File.dirname(after_file))
79
80
  FileUtils.touch(after_file)
80
81
  end
@@ -1,13 +1,13 @@
1
1
  Feature: Unsubstituted argument placeholder
2
2
 
3
3
  Scenario Outline: See Annual Leave Details (as Management & Human Resource)
4
- Given the following users exist in the system
5
- | name | email | role_assignments | group_memberships |
6
- | Jane | jane@fmail.com | <role> | Sales (manager) |
7
- | Max | max@fmail.com | | Sales (member) |
8
- | Carol | carol@fmail.com | | Sales (member) |
9
- | Cat | cat@fmail.com | | |
4
+ Given the following users exist in the system
5
+ | name | email | role_assignments | group_memberships |
6
+ | Jane | jane@fmail.com | <role> | Sales (manager) |
7
+ | Max | max@fmail.com | | Sales (member) |
8
+ | Carol | carol@fmail.com | | Sales (member) |
9
+ | Cat | cat@fmail.com | | |
10
10
 
11
- Examples:
12
- | role |
13
- | HUMAN RESOURCE |
11
+ Examples:
12
+ | role |
13
+ | HUMAN RESOURCE |
@@ -0,0 +1,6 @@
1
+ Feature https://rspec.lighthouseapp.com/projects/16211/tickets/301
2
+ Background: A background
3
+ Given whatever
4
+
5
+ Scenario: VB is not cool
6
+ Then VB should not be cool
@@ -0,0 +1,12 @@
1
+ require 'spec/expectations'
2
+
3
+ Before('@nothing_has_this_tag') do
4
+ @vb = :cool
5
+ end
6
+
7
+ Given /^whatever$/ do
8
+ end
9
+
10
+ Then /^VB should not be cool$/ do
11
+ @vb.should_not == :cool
12
+ end
@@ -0,0 +1,4 @@
1
+ Feature: woo yeah
2
+
3
+ Background:
4
+ Given passing step without a table
@@ -72,6 +72,7 @@ Feature: backgrounds
72
72
  When I run cucumber -q features/background/failing_background.feature --require features
73
73
  Then it should fail with
74
74
  """
75
+ @after_file
75
76
  Feature: Failing background sample
76
77
 
77
78
  Background:
@@ -79,7 +80,7 @@ Feature: backgrounds
79
80
  FAIL (RuntimeError)
80
81
  ./features/step_definitions/sample_steps.rb:2:in `flunker'
81
82
  ./features/step_definitions/sample_steps.rb:16:in `/^failing without a table$/'
82
- features/background/failing_background.feature:4:in `Given failing without a table'
83
+ features/background/failing_background.feature:5:in `Given failing without a table'
83
84
  And '10' cukes
84
85
 
85
86
  Scenario: failing background
@@ -259,6 +259,31 @@ Feature: Cucumber command line
259
259
  hello
260
260
  \"\"\"
261
261
 
262
+ Feature: search examples
263
+
264
+ Background: Hantu Pisang background match
265
+ Given passing without a table
266
+
267
+ Scenario: should match Hantu Pisang
268
+ Given passing without a table
269
+
270
+ Scenario: Ignore me
271
+ Given failing without a table
272
+
273
+ Scenario Outline: Ignore me
274
+ Given <state> without a table
275
+
276
+ Examples:
277
+ | state |
278
+ | failing |
279
+
280
+ Scenario Outline: Hantu Pisang match
281
+ Given <state> without a table
282
+
283
+ Examples:
284
+ | state |
285
+ | passing |
286
+
262
287
  Feature: undefined multiline args
263
288
 
264
289
  Scenario: pystring
@@ -272,8 +297,8 @@ Feature: Cucumber command line
272
297
  | table |
273
298
  | example |
274
299
 
275
- 17 scenarios
276
- 18 skipped steps
300
+ 21 scenarios
301
+ 26 skipped steps
277
302
  9 undefined steps
278
303
 
279
304
  """
@@ -304,24 +329,45 @@ Feature: Cucumber command line
304
329
 
305
330
  """
306
331
 
307
- Scenario: Run scenario specified by name using --scenario
308
- When I run cucumber --scenario Passing -q features
332
+ Scenario: Run feature elements which matches a name using --name
333
+ When I run cucumber --name Pisang -q features/
309
334
  Then it should pass with
310
335
  """
311
- @one
312
- Feature: Sample
336
+ Feature: search examples
313
337
 
314
- @three
315
- Scenario: Passing
316
- Given passing
317
- | a | b |
318
- | c | d |
338
+ Background: Hantu Pisang background match
339
+ Given passing without a table
319
340
 
320
- 1 scenario
341
+ Scenario: should match Hantu Pisang
342
+ Given passing without a table
343
+
344
+ Scenario Outline: Hantu Pisang match
345
+ Given <state> without a table
346
+
347
+ Examples:
348
+ | state |
349
+ | passing |
350
+
351
+ 2 scenarios
352
+ 4 passed steps
353
+
354
+ """
355
+
356
+ Scenario: Run a single background which matches a name using --name
357
+ When I run cucumber --name 'Hantu Pisang background' -q features/
358
+ Then it should pass with
359
+ """
360
+ Feature: search examples
361
+
362
+ Background: Hantu Pisang background match
363
+ Given passing without a table
364
+
365
+ 0 scenarios
321
366
  1 passed step
322
367
 
323
368
  """
324
369
 
370
+
325
371
  Scenario: Run with a tag that exists on 2 scenarios
326
372
  When I run cucumber -q features --tags three
327
373
  Then it should pass with
@@ -2,6 +2,38 @@ Feature: Cucumber command line
2
2
  In order to write better software
3
3
  Developers should be able to execute requirements as tests
4
4
 
5
+ Scenario: Run scenario outline with filtering on outline name
6
+ When I run cucumber -q features --name "Test state"
7
+ Then it should fail with
8
+ """
9
+ Feature: Outline Sample
10
+
11
+ Scenario Outline: Test state
12
+ Given <state> without a table
13
+ Given <other_state> without a table
14
+
15
+ Examples: Rainbow colours
16
+ | state | other_state |
17
+ | missing | passing |
18
+ | passing | passing |
19
+ | failing | passing |
20
+ FAIL (RuntimeError)
21
+ ./features/step_definitions/sample_steps.rb:2:in `flunker'
22
+ ./features/step_definitions/sample_steps.rb:16:in `/^failing without a table$/'
23
+ features/outline_sample.feature:6:in `Given <state> without a table'
24
+
25
+ Examples: Only passing
26
+ | state | other_state |
27
+ | passing | passing |
28
+
29
+ 4 scenarios
30
+ 1 failed step
31
+ 2 skipped steps
32
+ 1 undefined step
33
+ 4 passed steps
34
+
35
+ """
36
+
5
37
  Scenario: Run scenario outline steps only
6
38
  When I run cucumber -q features/outline_sample.feature:7
7
39
  Then it should fail with
@@ -4,8 +4,8 @@ Feature: Custom Formatter
4
4
  When I run cucumber --format Tag::Count features
5
5
  Then it should fail with
6
6
  """
7
- | four | lots | one | three | two |
8
- | 1 | 1 | 1 | 2 | 1 |
7
+ | after_file | four | lots | one | three | two |
8
+ | 1 | 1 | 1 | 1 | 2 | 1 |
9
9
 
10
10
  """
11
11
 
@@ -15,16 +15,21 @@ Feature: Cucumber command line
15
15
  Given <state> without a table # features/multiline_name.feature:22
16
16
  Given <state> without a table # features/outline_sample.feature:6
17
17
  Given <other_state> without a table # features/outline_sample.feature:7
18
+ Given passing without a table # features/search_sample.feature:4
19
+ Given passing without a table # features/search_sample.feature:7
20
+ Given <state> without a table # features/search_sample.feature:19
18
21
  /^failing without a table$/ # features/step_definitions/sample_steps.rb:15
19
- Given failing without a table # features/background/failing_background.feature:4
22
+ Given failing without a table # features/background/failing_background.feature:5
20
23
  Given failing without a table # features/background/scenario_outline_failing_background.feature:4
24
+ Given failing without a table # features/search_sample.feature:10
25
+ Given <state> without a table # features/search_sample.feature:13
21
26
  /^a step definition that calls an undefined step$/ # features/step_definitions/sample_steps.rb:19
22
27
  Given a step definition that calls an undefined step # features/call_undefined_step_from_step_def.feature:4
23
28
  /^call step "(.*)"$/ # features/step_definitions/sample_steps.rb:23
24
29
  Given call step "a step definition that calls an undefined step" # features/call_undefined_step_from_step_def.feature:7
25
30
  /^'(.+)' cukes$/ # features/step_definitions/sample_steps.rb:27
26
31
  Given '10' cukes # features/background/background_with_name.feature:4
27
- And '10' cukes # features/background/failing_background.feature:5
32
+ And '10' cukes # features/background/failing_background.feature:6
28
33
  Given '10' cukes # features/background/passing_background.feature:4
29
34
  Given '10' cukes # features/background/scenario_outline_passing_background.feature:4
30
35
  Given '2' cukes # features/tons_of_cukes.feature:4
@@ -78,8 +83,8 @@ Feature: Cucumber command line
78
83
  Given '2' cukes # features/tons_of_cukes.feature:52
79
84
  /^I should have '(.+)' cukes$/ # features/step_definitions/sample_steps.rb:31
80
85
  Then I should have '10' cukes # features/background/background_with_name.feature:7
81
- Then I should have '10' cukes # features/background/failing_background.feature:8
82
- Then I should have '10' cukes # features/background/failing_background.feature:11
86
+ Then I should have '10' cukes # features/background/failing_background.feature:9
87
+ Then I should have '10' cukes # features/background/failing_background.feature:12
83
88
  Then I should have '10' cukes # features/background/passing_background.feature:7
84
89
  Then I should have '10' cukes # features/background/passing_background.feature:10
85
90
  Then I should have '10' cukes # features/background/pending_background.feature:7
@@ -4,12 +4,13 @@ module Cucumber
4
4
  module Ast
5
5
  class Background
6
6
  include FeatureElement
7
- attr_writer :feature
7
+ attr_reader :feature_elements
8
8
 
9
9
  def initialize(comment, line, keyword, name, steps)
10
10
  @comment, @line, @keyword, @name, @steps = comment, line, keyword, name, StepCollection.new(steps)
11
11
  attach_steps(steps)
12
12
  @step_invocations = @steps.step_invocations(true)
13
+ @feature_elements = []
13
14
  end
14
15
 
15
16
  def step_collection(step_invocations)
@@ -24,25 +25,24 @@ module Cucumber
24
25
  def accept(visitor)
25
26
  visitor.visit_comment(@comment)
26
27
  visitor.visit_background_name(@keyword, @name, file_colon_line(@line), source_indent(first_line_length))
27
- visitor.step_mother.before(self)
28
+ visitor.step_mother.before(hook_context)
28
29
  visitor.visit_steps(@step_invocations)
29
30
  @failed = @step_invocations.detect{|step_invocation| step_invocation.exception}
30
- visitor.step_mother.after(self) if @failed
31
+ visitor.step_mother.after(hook_context) if @failed
31
32
  end
32
33
 
33
34
  def accept_hook?(hook)
34
- # TODO: When background is involved - no tag based hook filtering is occurring with
35
- # the current implementation. All hooks will be executed. This is because of the line
36
- # visitor.step_mother.before(self)
37
- # in the #accept method above. Instead, we should really be passing the first scenario
38
- # here. We currently don't have access to that, so a refactoring is in order to make that happen.
39
- true
35
+ false
40
36
  end
41
37
 
42
38
  def failed?
43
39
  @failed
44
40
  end
45
41
 
42
+ def hook_context
43
+ @feature_elements.first || self
44
+ end
45
+
46
46
  def to_sexp
47
47
  sexp = [:background, @line, @keyword]
48
48
  sexp += [@name] unless @name.empty?
@@ -8,6 +8,7 @@ module Cucumber
8
8
  def initialize(background, comment, tags, name, feature_elements)
9
9
  @background, @comment, @tags, @name, @feature_elements = background, comment, tags, name, feature_elements
10
10
 
11
+ background.feature = self if background
11
12
  @feature_elements.each do |feature_element|
12
13
  feature_element.feature = self
13
14
  end
@@ -23,6 +24,10 @@ module Cucumber
23
24
  end
24
25
  end
25
26
 
27
+ def accept_hook?(hook)
28
+ @tags.accept_hook?(hook)
29
+ end
30
+
26
31
  def next_feature_element(feature_element, &proc)
27
32
  index = @feature_elements.index(feature_element)
28
33
  next_one = @feature_elements[index+1]
@@ -2,6 +2,8 @@ require 'enumerator'
2
2
 
3
3
  module Cucumber
4
4
  module FeatureElement
5
+ attr_writer :feature
6
+
5
7
  def attach_steps(steps)
6
8
  steps.each {|step| step.feature_element = self}
7
9
  end
@@ -28,9 +30,9 @@ module Cucumber
28
30
  end
29
31
  end
30
32
 
31
- def matches_scenario_names?(scenario_names)
32
- scenario_names.detect{|name| name == @name}
33
- end
33
+ def matches_scenario_names?(scenario_name_regexps)
34
+ scenario_name_regexps.detect{|name| name =~ @name}
35
+ end
34
36
 
35
37
  def backtrace_line(name = "#{@keyword} #{@name}", line = @line)
36
38
  @feature.backtrace_line(name, line) if @feature
@@ -45,7 +47,7 @@ module Cucumber
45
47
  end
46
48
 
47
49
  def accept_hook?(hook)
48
- @tags.accept_hook?(hook)
50
+ @tags.accept_hook?(hook) || @feature.accept_hook?(hook)
49
51
  end
50
52
  end
51
53
  end
@@ -43,7 +43,11 @@ module Cucumber
43
43
  end
44
44
  PyString.new(@start_line, @end_line, string, @quotes_indent)
45
45
  end
46
-
46
+
47
+ def has_text?(text)
48
+ @string.index(text)
49
+ end
50
+
47
51
  # For testing only
48
52
  def to_sexp #:nodoc:
49
53
  [:py_string, to_s]
@@ -12,16 +12,12 @@ module Cucumber
12
12
  step_invocations = steps.map{|step| step.step_invocation}
13
13
  if @background
14
14
  @steps = @background.step_collection(step_invocations)
15
+ @background.feature_elements << self
15
16
  else
16
17
  @steps = StepCollection.new(step_invocations)
17
18
  end
18
19
  end
19
20
 
20
- def feature=(feature)
21
- @feature = feature
22
- @background.feature = feature if @background
23
- end
24
-
25
21
  def accept(visitor)
26
22
  visitor.visit_comment(@comment)
27
23
  visitor.visit_tags(@tags)
@@ -25,11 +25,6 @@ module Cucumber
25
25
  end
26
26
  end
27
27
 
28
- def feature=(feature)
29
- @feature = feature
30
- @background.feature = feature if @background
31
- end
32
-
33
28
  def accept(visitor)
34
29
  visitor.visit_comment(@comment)
35
30
  visitor.visit_tags(@tags)
@@ -82,7 +82,8 @@ module Cucumber
82
82
 
83
83
  def matched_cells(cells)
84
84
  cells.select do |cell|
85
- @name.index(delimited(cell.header_cell.value))
85
+ delimited = delimited(cell.header_cell.value)
86
+ @name.index(delimited) || (@multiline_arg && @multiline_arg.has_text?(delimited))
86
87
  end
87
88
  end
88
89
 
@@ -191,6 +191,10 @@ module Cucumber
191
191
  Table.new(raw_with_replaced_args)
192
192
  end
193
193
 
194
+ def has_text?(text)
195
+ raw.flatten.detect{|cell_value| cell_value.index(text)}
196
+ end
197
+
194
198
  def cells_rows
195
199
  @rows ||= cell_matrix.map do |cell_row|
196
200
  @cells_class.new(self, cell_row)
@@ -11,8 +11,8 @@ module Cucumber
11
11
  end
12
12
 
13
13
  def matches_scenario_names?(node)
14
- scenario_names = options[:scenario_names] || []
15
- scenario_names.empty? || node.matches_scenario_names?(scenario_names)
14
+ scenario_name_regexps = options[:name_regexps] || []
15
+ scenario_name_regexps.empty? || node.matches_scenario_names?(scenario_name_regexps)
16
16
  end
17
17
 
18
18
  def visit_features(features)
@@ -78,10 +78,11 @@ module Cucumber
78
78
  "with or without the @ prefix.") do |v|
79
79
  @options[:include_tags], @options[:exclude_tags] = *parse_tags(v)
80
80
  end
81
- opts.on("-s SCENARIO", "--scenario SCENARIO",
82
- "Only execute the scenario with the given name. If this option",
83
- "is given more than once, run all the specified scenarios.") do |v|
84
- @options[:scenario_names] << v
81
+ opts.on("-n NAME", "--name NAME",
82
+ "Only execute the feature elements which match part of the given name.",
83
+ "If this option is given more than once, it will match against all the",
84
+ "given names.") do |v|
85
+ @options[:name_regexps] << /#{v}/
85
86
  end
86
87
  opts.on("-e", "--exclude PATTERN", "Don't run feature files matching PATTERN") do |v|
87
88
  @options[:excludes] << v
@@ -334,16 +335,16 @@ Defined profiles in cucumber.yml:
334
335
 
335
336
  def default_options
336
337
  {
337
- :strict => false,
338
- :require => nil,
339
- :lang => 'en',
340
- :dry_run => false,
341
- :formats => {},
342
- :excludes => [],
343
- :include_tags => [],
344
- :exclude_tags => [],
345
- :scenario_names => [],
346
- :diff_enabled => true
338
+ :strict => false,
339
+ :require => nil,
340
+ :lang => 'en',
341
+ :dry_run => false,
342
+ :formats => {},
343
+ :excludes => [],
344
+ :include_tags => [],
345
+ :exclude_tags => [],
346
+ :name_regexps => [],
347
+ :diff_enabled => true
347
348
  }
348
349
  end
349
350
 
@@ -61,8 +61,8 @@ module Cucumber
61
61
  end
62
62
 
63
63
  def build(filter)
64
- if(filter.nil? || feature_elements.accept?(filter))
65
- background = bg.respond_to?(:build) ? bg.build : nil
64
+ if(filter.nil? || feature_elements.accept?(filter) || (!bg.empty? && filter.accept?(bg)))
65
+ background = bg.respond_to?(:build) ? bg.build : nil
66
66
  Ast::Feature.new(
67
67
  background,
68
68
  comment.build,
@@ -481,6 +481,16 @@ module Cucumber
481
481
  end
482
482
 
483
483
  module Background1
484
+
485
+ def matches_name?(regexp_to_match)
486
+ name.build =~ regexp_to_match
487
+ end
488
+
489
+ def has_tags?(tag_names)
490
+ feature_tags = self.parent.tags
491
+ feature_tags.has_tags?(tag_names)
492
+ end
493
+
484
494
  def build
485
495
  Ast::Background.new(
486
496
  comment.build,
@@ -678,8 +688,8 @@ module Cucumber
678
688
  tags.has_tags?(tag_names) || feature_tags.has_tags?(tag_names)
679
689
  end
680
690
 
681
- def matches_name?(name_to_match)
682
- name.build == name_to_match
691
+ def matches_name?(regexp_to_match)
692
+ name.build =~ regexp_to_match
683
693
  end
684
694
 
685
695
  def build(background, filter)
@@ -816,8 +826,8 @@ module Cucumber
816
826
  tags.has_tags?(tag_names) || feature_tags.has_tags?(tag_names)
817
827
  end
818
828
 
819
- def matches_name?(name_to_match)
820
- name.build == name_to_match
829
+ def matches_name?(regexp_to_match)
830
+ name.build =~ regexp_to_match
821
831
  end
822
832
 
823
833
  def build(background, filter)
@@ -1148,6 +1158,10 @@ module Cucumber
1148
1158
  true
1149
1159
  end
1150
1160
 
1161
+ def matches_name?(regexp_to_match)
1162
+ name.build =~ regexp_to_match
1163
+ end
1164
+
1151
1165
  def build(filter, scenario_outline)
1152
1166
  [examples_keyword.line, examples_keyword.text_value, name.build, table.raw(filter, scenario_outline)]
1153
1167
  end
@@ -25,8 +25,8 @@ module Cucumber
25
25
  end
26
26
 
27
27
  def build(filter)
28
- if(filter.nil? || feature_elements.accept?(filter))
29
- background = bg.respond_to?(:build) ? bg.build : nil
28
+ if(filter.nil? || feature_elements.accept?(filter) || (!bg.empty? && filter.accept?(bg)))
29
+ background = bg.respond_to?(:build) ? bg.build : nil
30
30
  Ast::Feature.new(
31
31
  background,
32
32
  comment.build,
@@ -77,6 +77,16 @@ module Cucumber
77
77
 
78
78
  rule background
79
79
  comment white background_keyword space* name:lines_to_keyword? (eol+ / eof) steps {
80
+
81
+ def matches_name?(regexp_to_match)
82
+ name.build =~ regexp_to_match
83
+ end
84
+
85
+ def has_tags?(tag_names)
86
+ feature_tags = self.parent.tags
87
+ feature_tags.has_tags?(tag_names)
88
+ end
89
+
80
90
  def build
81
91
  Ast::Background.new(
82
92
  comment.build,
@@ -118,8 +128,8 @@ module Cucumber
118
128
  tags.has_tags?(tag_names) || feature_tags.has_tags?(tag_names)
119
129
  end
120
130
 
121
- def matches_name?(name_to_match)
122
- name.build == name_to_match
131
+ def matches_name?(regexp_to_match)
132
+ name.build =~ regexp_to_match
123
133
  end
124
134
 
125
135
  def build(background, filter)
@@ -154,8 +164,8 @@ module Cucumber
154
164
  tags.has_tags?(tag_names) || feature_tags.has_tags?(tag_names)
155
165
  end
156
166
 
157
- def matches_name?(name_to_match)
158
- name.build == name_to_match
167
+ def matches_name?(regexp_to_match)
168
+ name.build =~ regexp_to_match
159
169
  end
160
170
 
161
171
  def build(background, filter)
@@ -233,6 +243,10 @@ module Cucumber
233
243
  true
234
244
  end
235
245
 
246
+ def matches_name?(regexp_to_match)
247
+ name.build =~ regexp_to_match
248
+ end
249
+
236
250
  def build(filter, scenario_outline)
237
251
  [examples_keyword.line, examples_keyword.text_value, name.build, table.raw(filter, scenario_outline)]
238
252
  end
@@ -252,7 +266,7 @@ module Cucumber
252
266
  def build
253
267
  text.text_value.strip
254
268
  end
255
- }
269
+ }
256
270
  end
257
271
 
258
272
  rule lines_to_keyword
@@ -17,7 +17,7 @@ module Cucumber
17
17
  @lines = lines
18
18
  @include_tags = options[:include_tags] || []
19
19
  @exclude_tags = options[:exclude_tags] || []
20
- @names = options[:scenario_names] || []
20
+ @name_regexps = options[:name_regexps] || []
21
21
  end
22
22
 
23
23
  def accept?(syntax_node)
@@ -48,7 +48,7 @@ module Cucumber
48
48
  end
49
49
 
50
50
  def matches_names?(syntax_node)
51
- @names.nil? || @names.empty? || @names.detect{|name| syntax_node.matches_name?(name)}
51
+ @name_regexps.nil? || @name_regexps.empty? || @name_regexps.detect{|name_regexp| syntax_node.matches_name?(name_regexp)}
52
52
  end
53
53
  end
54
54
 
@@ -111,4 +111,4 @@ module Treetop
111
111
  include Cucumber::Parser::TreetopExt
112
112
  end
113
113
  end
114
- end
114
+ end
@@ -33,7 +33,7 @@ module Cucumber #:nodoc:
33
33
  def self.use_transactional_fixtures
34
34
 
35
35
  unless ::Rails.configuration.cache_classes
36
- warn "WARNING: You have set Rail's config.cache_classes to false (most likely in config/environments/test.rb). This setting is known to break Cucumber's use_transactional_fixtures method. Set config.cache_classes to true if you want to use transactional fixtures. For more information see https://rspec.lighthouseapp.com/projects/16211/tickets/165."
36
+ warn "WARNING: You have set Rails' config.cache_classes to false (most likely in config/environments/test.rb). This setting is known to break Cucumber's use_transactional_fixtures method. Set config.cache_classes to true if you want to use transactional fixtures. For more information see https://rspec.lighthouseapp.com/projects/16211/tickets/165."
37
37
  end
38
38
 
39
39
  World.use_transactional_fixtures = true
@@ -2,8 +2,8 @@ module Cucumber #:nodoc:
2
2
  class VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 3
5
- TINY = 0
6
- PATCH = 1 # Set to nil for official release
5
+ TINY = 1
6
+ PATCH = nil # Set to nil for official release
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, PATCH].compact.join('.')
9
9
  end
@@ -29,6 +29,11 @@ module Cucumber
29
29
  text_length.should == 3
30
30
  end
31
31
  end
32
+
33
+ it "should support checking if its name matches a list of regexps" do
34
+ @name = 'test'
35
+ matches_scenario_names?([/es/]).should be_true
36
+ end
32
37
 
33
38
  end
34
39
  end
@@ -40,6 +40,10 @@ module Cucumber
40
40
  py_string_with_replaced_arg.to_s.should == "''"
41
41
  end
42
42
 
43
+ it "should recognise when just a subset of a cell is delimited" do
44
+ @ps.should have_text('<qty>')
45
+ end
46
+
43
47
  end
44
48
 
45
49
  end
@@ -109,10 +109,10 @@ module Cucumber
109
109
  describe "replacing arguments" do
110
110
 
111
111
  before(:each) do
112
- @table = table = Table.new([
112
+ @table = Table.new([
113
113
  %w{qty book},
114
114
  %w{<qty> <book>}
115
- ])
115
+ ])
116
116
  end
117
117
 
118
118
  it "should return a new table with arguments replaced with values" do
@@ -122,6 +122,18 @@ module Cucumber
122
122
  table_with_replaced_args.hashes[0]['qty'].should == '5'
123
123
  end
124
124
 
125
+ it "should recognise when entire cell is delimited" do
126
+ @table.should have_text('<book>')
127
+ end
128
+
129
+ it "should recognise when just a subset of a cell is delimited" do
130
+ table = Table.new([
131
+ %w{qty book},
132
+ ['<qty>', "This is <who>'s book"]
133
+ ])
134
+ table.should have_text('<who>')
135
+ end
136
+
125
137
  it "should replace nil values with nil" do
126
138
  table_with_replaced_args = @table.arguments_replaced({'<book>' => nil})
127
139
 
@@ -255,12 +255,12 @@ END_OF_MESSAGE
255
255
 
256
256
  end
257
257
 
258
- it "should accept multiple --scenario options" do
258
+ it "should accept multiple --name options" do
259
259
  config = Configuration.new
260
- config.parse!(['--scenario', "User logs in", '--scenario', "User signs up"])
260
+ config.parse!(['--name', "User logs in", '--name', "User signs up"])
261
261
 
262
- config.options[:scenario_names].should include("User logs in")
263
- config.options[:scenario_names].should include("User signs up")
262
+ config.options[:name_regexps].should include(/User logs in/)
263
+ config.options[:name_regexps].should include(/User signs up/)
264
264
  end
265
265
 
266
266
  it "should search for all features in the specified directory" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aslakhellesoy-cucumber
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0.1
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Aslak Helles\xC3\xB8y"
@@ -283,6 +283,9 @@ files:
283
283
  - examples/tickets/features/279/py_string_indent.feature
284
284
  - examples/tickets/features/279/py_string_indent.steps.rb
285
285
  - examples/tickets/features/279/wrong.feature_
286
+ - examples/tickets/features/301/filter_background_tagged_hooks.feature
287
+ - examples/tickets/features/301/filter_background_tagged_hooks_steps.rb
288
+ - examples/tickets/features/306/only_background.feature
286
289
  - examples/tickets/features/lib/eatting_machine.rb
287
290
  - examples/tickets/features/lib/pantry.rb
288
291
  - examples/tickets/features/scenario_outline.feature