Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/cucumber/core/compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def on_step(source)
end

def on_test_case(source)
Test::Case.new(test_steps, source).describe_to(receiver)
Test::Case.new(test_steps, source).describe_to(receiver) if test_steps.count > 0
@test_steps = nil
self
end
Expand Down
17 changes: 17 additions & 0 deletions spec/cucumber/core/compiler_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,23 @@ def self.stubs(*names)
end
end

context 'empty scenarios' do
it 'does not create test cases for them' do
gherkin_documents = [
gherkin do
feature do
scenario do
end
end
end
]
compile(gherkin_documents) do |visitor|
expect( visitor ).to receive(:test_case).never
expect( visitor ).to receive(:done).once.ordered
end
end
end

describe Compiler::FeatureCompiler do
let(:receiver) { double('receiver') }
let(:compiler) { Compiler::FeatureCompiler.new(receiver) }
Expand Down
2 changes: 1 addition & 1 deletion spec/cucumber/core/test/case_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ module Test
gherkin = Gherkin::Document.new('features/treasure.feature', %{# language: en-pirate
Ahoy matey!: Treasure map
Heave to: Find the treasure
Gangway!: a map
Gangway! a map
})
receiver = double.as_null_object
expect( receiver ).to receive(:test_case) do |test_case|
Expand Down
9 changes: 0 additions & 9 deletions spec/cucumber/core/test/filters/locations_filter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@ module Cucumber::Core
Given a table
| a | b |
| 1 | 2 |

Scenario: empty
END
end

Expand All @@ -112,13 +110,6 @@ def test_case_named(name)
expect(receiver.test_case_locations).to eq [test_case_named('two').location]
end

it 'matches the precise location of an empty scenario' do
location = test_case_named('empty').location
filter = Test::LocationsFilter.new([location])
compile [doc], receiver, [filter]
expect(receiver.test_case_locations).to eq [test_case_named('empty').location]
end

it 'matches multiple locations' do
good_location = Ast::Location.new(file, 8)
bad_location = Ast::Location.new(file, 5)
Expand Down