Skip to content
Browse files

Directly creating a Table meant the scenario table header was never s…

…et which was causing a formatter error
  • Loading branch information...
1 parent 1670682 commit 88650dd0f413082ca62d46c5e111b58e1bd0f1b9 Joseph Wilk committed Nov 15, 2008
Showing with 30 additions and 7 deletions.
  1. +1 −0 History.txt
  2. +2 −1 lib/cucumber/tree/feature.rb
  3. +27 −6 spec/cucumber/tree/feature_spec.rb
View
1 History.txt
@@ -7,6 +7,7 @@ Blurb
=== Bugfixes
* Features written using Ruby where breaking due to missing a line number (#91 Joseph Wilk)
+* Directly creating a Table meant the scenario table header was never set which was causing a formatter error (#91 Joseph Wilk)
=== Removed features
* Step definition without a block being treated as pending (#64 Joseph Wilk)
View
3 lib/cucumber/tree/feature.rb
@@ -34,14 +34,15 @@ def padding_length
end
def Scenario(name, &proc)
- _, line, _ = *caller[0].split(':')
+ line = caller[0] =~ /:(\d+)$/ ? $1 : nil
add_scenario(name, line, &proc)
end
def Table(matrix = [], &proc)
table = Table.new(matrix)
proc.call(table)
template_scenario = @scenarios.last
+ template_scenario.table_header = matrix[0]
matrix[1..-1].each do |row|
add_row_scenario(template_scenario, row, row.line)
end
View
33 spec/cucumber/tree/feature_spec.rb
@@ -9,14 +9,35 @@ module Tree
feature.padding_length.should == 2
end
- it "should create a new scenario for a feature" do
- feature = Feature.new('header')
-
- Scenario.should_receive(:new).with(feature, 'test scenario', "17")
-
- feature.Scenario('test scenario') {}
+ describe "creating a Scenario" do
+
+ it "should create a new scenario for a feature" do
+ feature = Feature.new('header')
+
+ Scenario.should_receive(:new).with(feature, 'test scenario', "19")
+
+ feature.Scenario('test scenario') {}
+ end
+
end
+ describe "creating a Table" do
+
+ it "should set the table header of the template scenario" do
+ feature = Feature.new('header')
+ mock_scenario = mock("scenario", :update_table_column_widths => nil)
+ Scenario.stub!(:new).and_return(mock_scenario)
+ feature.add_scenario('scenario', 5)
+
+ mock_scenario.should_receive(:table_header=).with(["input_1", "input_2"])
+
+ feature.Table do |t|
+ t | "input_1" | "input_2" | t
+ t | 1 | 2 | t
+ end
+ end
+
+ end
end
end
end

0 comments on commit 88650dd

Please sign in to comment.
Something went wrong with that request. Please try again.