3 ########################################################################
4 # Backward compatibility for Jenkins outdated environment.
8 alias_method :to, :should unless method_defined? :to
9 alias_method :to_not, :should_not unless method_defined? :to_not
10 alias_method :not_to, :should_not unless method_defined? :not_to
16 ########################################################################
18 RSpec::Matchers.define :have_matching_element do |expected|
20 actual.any? { |item| item =~ expected }
25 RSpec::Matchers.define :exit_with do |expected|
30 rescue SystemExit => e
33 actual and actual == expected
35 failure_message_for_should do |block|
36 "expected exit with code #{expected} but " +
37 (actual.nil? ? " exit was not called" : "we exited with #{actual} instead")
39 failure_message_for_should_not do |block|
40 "expected that exit would not be called with #{expected}"
43 "expect exit with #{expected}"
48 RSpec::Matchers.define :have_printed do |expected|
50 $stderr = $stdout = StringIO.new
56 @actual = $stdout.read
65 @actual.include? expected
67 expected.match @actual
69 raise ArgumentError, "No idea how to match a #{@actual.class.name}"
74 failure_message_for_should do |actual|
76 "expected #{expected.inspect}, but nothing was printed"
78 "expected #{expected.inspect} to be printed; got:\n#{actual}"
83 "expect #{expected.inspect} to be printed"