Permalink
Browse files

Support description string for Backgrounds

  • Loading branch information...
1 parent b436d78 commit bbc5a32556382488efca9363c0eaf2a7c2ce94bb @josephwilk josephwilk committed Apr 1, 2009
View
@@ -3,6 +3,7 @@
=== New features
* Allow Step Definitions to use |*varargs|, but only on Ruby 1.9. (Aslak Hellesøy)
* Snippets for steps that use Step Tables or Pystrings include block param and object type hint comment (#247 Joseph Wilk)
+* Support description string for Backgrounds (#271 Joseph Wilk)
== 0.2.3 2009-03-30
@@ -0,0 +1,7 @@
+Feature: background with name
+
+ Background: I'm a background and I'm ok
+ Given '10' cukes
+
+ Scenario: example
+ Then I should have '10' cukes
@@ -217,5 +217,22 @@ Feature: backgrounds
"""
+ Scenario: background with name
+ When I run cucumber -q features/background/background_with_name.feature --require features
+ Then it should pass with
+ """
+ Feature: background with name
+
+ Background: I'm a background and I'm ok
+ Given '10' cukes
+
+ Scenario: example
+ Then I should have '10' cukes
+
+ 1 scenario
+ 2 passed steps
+
+ """
+
@josephwilk
Scenario: run a scenario showing explicit background steps --explicit-background
View
@@ -19,6 +19,7 @@ Feature: Cucumber command line
/^call step "(.*)"$/ # features/step_definitions/sample_steps.rb:23
Given call step "a step definition that calls an undefined step" # features/call_undefined_step_from_step_def.feature:7
/^'(.+)' cukes$/ # features/step_definitions/sample_steps.rb:27
+ Given '10' cukes # features/background/background_with_name.feature:4
And '10' cukes # features/background/failing_background.feature:5
Given '10' cukes # features/background/passing_background.feature:4
Given '10' cukes # features/background/scenario_outline_passing_background.feature:4
@@ -72,6 +73,7 @@ Feature: Cucumber command line
Given '2' cukes # features/tons_of_cukes.feature:51
Given '2' cukes # features/tons_of_cukes.feature:52
/^I should have '(.+)' cukes$/ # features/step_definitions/sample_steps.rb:31
+ Then I should have '10' cukes # features/background/background_with_name.feature:7
Then I should have '10' cukes # features/background/failing_background.feature:8
Then I should have '10' cukes # features/background/failing_background.feature:11
Then I should have '10' cukes # features/background/passing_background.feature:7
@@ -6,8 +6,8 @@ class Background
include FeatureElement
attr_writer :feature
- def initialize(comment, line, keyword, steps)
- @comment, @line, @keyword, @steps = comment, line, keyword, StepCollection.new(steps)
+ def initialize(comment, line, keyword, name, steps)
+ @comment, @line, @keyword, @name, @steps = comment, line, keyword, name, StepCollection.new(steps)
attach_steps(steps)
@step_invocations = @steps.step_invocations(true)
end
@@ -23,7 +23,7 @@ def step_collection(step_invocations)
def accept(visitor)
visitor.visit_comment(@comment)
- visitor.visit_background_name(@keyword, "", file_colon_line(@line), source_indent(text_length))
+ visitor.visit_background_name(@keyword, @name, file_colon_line(@line), source_indent(text_length))
visitor.step_mother.before_and_after(self)
visitor.visit_steps(@step_invocations)
@failed = @step_invocations.detect{|step_invocation| step_invocation.exception}
@@ -59,12 +59,13 @@ module Cucumber
end
rule background
- comment white background_keyword space* (eol+ / eof) steps {
+ comment white background_keyword space* name:line_to_eol? (eol+ / eof) steps {
def build
Ast::Background.new(
comment.build,
background_keyword.line,
- background_keyword.text_value,
+ background_keyword.text_value,
+ name.text_value,
steps.build
)
end
@@ -26,6 +26,7 @@ module Ast
comment=Comment.new(''),
line=2,
keyword="",
+ name="",
steps=[
Step.new(7, "Given", "y is 5")
])
@@ -30,7 +30,7 @@ def create_feature(step_mother)
Cucumber sandwich
}, 10)
- background = Ast::Background.new(Ast::Comment.new(""), 2, "Background:",
+ background = Ast::Background.new(Ast::Comment.new(""), 2, "Background:", "",
[
Step.new(3, "Given", "a passing step")
]

0 comments on commit bbc5a32

Please sign in to comment.