File: duration_matcher.rb

package info (click to toggle)
ruby-cucumber-core 1.5.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 580 kB
  • sloc: ruby: 5,763; makefile: 2
file content (19 lines) | stat: -rw-r--r-- 524 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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.tap { |duration| @nanoseconds = duration.nanoseconds }
      @nanoseconds == expected
    end
  end

  RSpec::Matchers.define :an_unknown_duration do
    match do |actual|
      actual.tap { raise "#tap block was executed, not an UnknownDuration" } 
      expect(actual).to respond_to(:nanoseconds)
    end
  end
end