Skip to content

Commit

Permalink
Use past tense in event names, see cucumber/cucumber-ruby#1166.
Browse files Browse the repository at this point in the history
Rename events xStarting -> xStarted.
  • Loading branch information
brasmusson committed Aug 2, 2017
1 parent 4a9ca11 commit 1aa0140
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
1 change: 1 addition & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
### Bugfixes
### Removed Features
### Refactoring
* Use past tense in event names (`xStarting` -> `xStarted`) (see [cucumber/cucumber-ruby#1166](https://github.com/cucumber/cucumber-ruby/issues/1166) @brasmusson).

## [3.0.0.pre.2](https://github.com/cucumber/cucumber-ruby-core/compare/v2.0.0...3.0.0.pre.2) (2017-07-26)

Expand Down
8 changes: 4 additions & 4 deletions lib/cucumber/core/events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ module Core
module Events

# Signals that a {Test::Case} is about to be executed
class TestCaseStarting < Event.new(:test_case)
class TestCaseStarted < Event.new(:test_case)

# @return [Test::Case] the test case to be executed
attr_reader :test_case

end

# Signals that a {Test::Step} is about to be executed
class TestStepStarting < Event.new(:test_step)
class TestStepStarted < Event.new(:test_step)

# @return [Test::Step] the test step to be executed
attr_reader :test_step
Expand Down Expand Up @@ -47,8 +47,8 @@ class TestCaseFinished < Event.new(:test_case, :result)
# that will be used by the {EventBus} by default.
def self.registry
build_registry(
TestCaseStarting,
TestStepStarting,
TestCaseStarted,
TestStepStarted,
TestStepFinished,
TestCaseFinished,
)
Expand Down
4 changes: 2 additions & 2 deletions lib/cucumber/core/test/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ def initialize(event_bus)
def test_case(test_case, &descend)
@running_test_case = RunningTestCase.new
@running_test_step = nil
event_bus.test_case_starting(test_case)
event_bus.test_case_started(test_case)
descend.call(self)
event_bus.test_case_finished(test_case, running_test_case.result)
self
end

def test_step(test_step)
@running_test_step = test_step
event_bus.test_step_starting test_step
event_bus.test_step_started test_step
step_result = running_test_case.execute(test_step)
event_bus.test_step_finished test_step, step_result
@running_test_step = nil
Expand Down
6 changes: 3 additions & 3 deletions spec/cucumber/core/test/runner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module Cucumber::Core::Test
let(:exception) { StandardError.new('test error') }

before do
allow(event_bus).to receive(:test_case_starting)
allow(event_bus).to receive(:test_case_started)
allow(source).to receive(:location)
end

Expand Down Expand Up @@ -66,8 +66,8 @@ module Cucumber::Core::Test
context "without steps" do
let(:test_steps) { [] }

it "emits a test_case_starting event before running the test case" do
expect(event_bus).to receive(:test_case_starting).with(test_case)
it "emits a test_case_started event before running the test case" do
expect(event_bus).to receive(:test_case_started).with(test_case)
test_case.describe_to runner
end

Expand Down
22 changes: 11 additions & 11 deletions spec/cucumber/core_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,17 @@ module Cucumber

observed_events = []
execute [gherkin], [Core::Test::Filters::ActivateStepsForSelfTest.new] do |event_bus|
event_bus.on(:test_case_starting) do |event|
event_bus.on(:test_case_started) do |event|
test_case = event.test_case
observed_events << [:test_case_starting, test_case.name]
observed_events << [:test_case_started, test_case.name]
end
event_bus.on(:test_case_finished) do |event|
test_case, result = *event.attributes
observed_events << [:test_case_finished, test_case.name, result.to_sym]
end
event_bus.on(:test_step_starting) do |event|
event_bus.on(:test_step_started) do |event|
test_step = event.test_step
observed_events << [:test_step_starting, test_step.name]
observed_events << [:test_step_started, test_step.name]
end
event_bus.on(:test_step_finished) do |event|
test_step, result = *event.attributes
Expand All @@ -118,18 +118,18 @@ module Cucumber
end

expect(observed_events).to eq [
[:test_case_starting, 'The one that passes'],
[:test_step_starting, 'passing'],
[:test_case_started, 'The one that passes'],
[:test_step_started, 'passing'],
[:test_step_finished, 'passing', :passed],
[:test_case_finished, 'The one that passes', :passed],
[:test_case_starting, 'The one that fails'],
[:test_step_starting, 'passing'],
[:test_case_started, 'The one that fails'],
[:test_step_started, 'passing'],
[:test_step_finished, 'passing', :passed],
[:test_step_starting, 'failing'],
[:test_step_started, 'failing'],
[:test_step_finished, 'failing', :failed],
[:test_step_starting, 'passing'],
[:test_step_started, 'passing'],
[:test_step_finished, 'passing', :skipped],
[:test_step_starting, 'undefined'],
[:test_step_started, 'undefined'],
[:test_step_finished, 'undefined', :undefined],
[:test_case_finished, 'The one that fails', :failed],
]
Expand Down

0 comments on commit 1aa0140

Please sign in to comment.