Skip to content

Commit

Permalink
Directly creating a Table meant the scenario table header was never s…
Browse files Browse the repository at this point in the history
…et which was causing a formatter error
  • Loading branch information
Joseph Wilk committed Nov 15, 2008
1 parent 1670682 commit 88650dd
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
1 change: 1 addition & 0 deletions History.txt
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion lib/cucumber/tree/feature.rb
Expand Up @@ -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
Expand Down
33 changes: 27 additions & 6 deletions spec/cucumber/tree/feature_spec.rb
Expand Up @@ -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.