diff --git a/lib/cucumber/core/compiler.rb b/lib/cucumber/core/compiler.rb index 9ce2a0e8..e6ac4255 100644 --- a/lib/cucumber/core/compiler.rb +++ b/lib/cucumber/core/compiler.rb @@ -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 diff --git a/spec/cucumber/core/compiler_spec.rb b/spec/cucumber/core/compiler_spec.rb index 2331303a..3c620aab 100644 --- a/spec/cucumber/core/compiler_spec.rb +++ b/spec/cucumber/core/compiler_spec.rb @@ -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) } diff --git a/spec/cucumber/core/test/case_spec.rb b/spec/cucumber/core/test/case_spec.rb index 8db7bce7..25352898 100644 --- a/spec/cucumber/core/test/case_spec.rb +++ b/spec/cucumber/core/test/case_spec.rb @@ -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| diff --git a/spec/cucumber/core/test/filters/locations_filter_spec.rb b/spec/cucumber/core/test/filters/locations_filter_spec.rb index 9240c122..b58f7e82 100644 --- a/spec/cucumber/core/test/filters/locations_filter_spec.rb +++ b/spec/cucumber/core/test/filters/locations_filter_spec.rb @@ -96,8 +96,6 @@ module Cucumber::Core Given a table | a | b | | 1 | 2 | - - Scenario: empty END end @@ -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)