Sha256: 26f7774699979f1ee060e8da7927e118927de1d9a9b8334f6b5614c7bddd6f8d

Contents?: true

Size: 1.18 KB

Versions: 2

Compression:

Stored size: 1.18 KB

Contents

# @!method run_too_long
#   This matchers checks if <command> run too long. Say the timeout is 10
#   seconds and it takes <command> to finish in 15. This matchers will succeed.
#
#   @return [TrueClass, FalseClass] The result
#
#     false:
#     * if command not to run too long
#     true:
#     * if command run too long
#
#   @example Use matcher
#
#     RSpec.describe do
#       it { expect(last_command).to run_too_long }
#       it { expect(last_command).not_to run_too_long }
#       it { expect(last_command).to finish_its_run_in_time }
#     end
# RSpec::Matchers.define :run_too_long do
RSpec::Matchers.define :have_finished_in_time do
  match do |actual|
    @old_actual = actual
    @actual     = @old_actual.commandline

    @announcer ||= Aruba::Announcer.new(
      self,
      :stdout => @announce_stdout,
      :stderr => @announce_stderr,
      :dir    => @announce_dir,
      :cmd    => @announce_cmd,
      :env    => @announce_env
    )

    @old_actual.stop(@announcer) unless @old_actual.stopped?

    next false unless @old_actual.respond_to? :timed_out?

    @old_actual.timed_out? == false
  end
end

RSpec::Matchers.define_negated_matcher :run_too_long, :have_finished_in_time

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
aruba-0.8.0.pre2 lib/aruba/matchers/command/have_finished_in_time.rb
aruba-0.8.0.pre lib/aruba/matchers/command/have_finished_in_time.rb