-
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce a Duration object in Cucumber::Core::Test::Result
For results which do not have an actual duration (skipped, undefined and pending) instead hold an null object. Client can either use the "null duration" (0), or check if it is an actual duration or an null duration.
- Loading branch information
1 parent
6ed926d
commit 3e39c8d
Showing
5 changed files
with
87 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# -*- encoding: utf-8 -*- | ||
require 'cucumber/core/test/result' | ||
require 'rspec/expectations' | ||
|
||
module Cucumber::Core::Test | ||
RSpec::Matchers.define :be_duration do |expected| | ||
match do |actual| | ||
actual.exist? and actual.duration == expected | ||
end | ||
end | ||
|
||
RSpec::Matchers.alias_matcher :a_duration_of, :be_duration | ||
|
||
RSpec::Matchers.define :an_unknown_duration do | ||
match do |actual| | ||
not actual.exist? and expect(actual).to respond_to(:duration) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3e39c8d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@brasmusson looks good.
I wonder if we can have Core::Test::Timer return a Duration object?
We could then set the default Duration on line 84 to UnknownDuration, and pass in an actual Duration where we have one.