Sha256: cea28ca16ddb532db9445f207943e6038f092e2cb54f299f011f8bf11e463e20

Contents?: true

Size: 1.03 KB

Versions: 26

Compression:

Stored size: 1.03 KB

Contents

require 'rspec/expectations/version'

# @!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_started).to run_too_long }
#       it { expect(last_command_started).not_to run_too_long }
#       it { expect(last_command_started).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

    next false unless @old_actual.respond_to? :timed_out?

    @old_actual.stop

    @old_actual.timed_out? == false
  end
end

if RSpec::Expectations::Version::STRING >= '3.1'
  RSpec::Matchers.define_negated_matcher :run_too_long, :have_finished_in_time
end

Version data entries

26 entries across 26 versions & 3 rubygems

Version Path
aruba-0.14.14 lib/aruba/matchers/command/have_finished_in_time.rb
aruba-0.14.13 lib/aruba/matchers/command/have_finished_in_time.rb
honeybadger-4.5.3 vendor/bundle/ruby/2.6.0/gems/aruba-0.14.12/lib/aruba/matchers/command/have_finished_in_time.rb
aruba-0.14.12 lib/aruba/matchers/command/have_finished_in_time.rb
aruba-0.14.11 lib/aruba/matchers/command/have_finished_in_time.rb
aruba-0.14.10 lib/aruba/matchers/command/have_finished_in_time.rb
aruba-0.14.9 lib/aruba/matchers/command/have_finished_in_time.rb
aruba-0.14.8 lib/aruba/matchers/command/have_finished_in_time.rb
aruba-0.14.7 lib/aruba/matchers/command/have_finished_in_time.rb
aruba-0.14.6 lib/aruba/matchers/command/have_finished_in_time.rb
aruba-0.14.5 lib/aruba/matchers/command/have_finished_in_time.rb
aruba-0.14.4 lib/aruba/matchers/command/have_finished_in_time.rb
aruba-0.14.3 lib/aruba/matchers/command/have_finished_in_time.rb
aruba-1.0.0.pre.alpha.2 lib/aruba/matchers/command/have_finished_in_time.rb
aruba-1.0.0.pre.alpha.1 lib/aruba/matchers/command/have_finished_in_time.rb
aruba-win-fix-0.14.2 lib/aruba/matchers/command/have_finished_in_time.rb
aruba-0.14.2 lib/aruba/matchers/command/have_finished_in_time.rb
aruba-0.14.1 lib/aruba/matchers/command/have_finished_in_time.rb
aruba-0.14.0 lib/aruba/matchers/command/have_finished_in_time.rb
aruba-0.13.0 lib/aruba/matchers/command/have_finished_in_time.rb