File: expectations_spec.rb

package info (click to toggle)
ruby-rspec 3.13.0c0e0m0s1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,856 kB
  • sloc: ruby: 70,868; sh: 1,423; makefile: 99
file content (26 lines) | stat: -rw-r--r-- 932 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
require 'rspec/support/spec/library_wide_checks'

RSpec.describe "RSpec::Expectations" do
  allowed_loaded_features = [
    /stringio/, # Used by `output` matcher. Can't be easily avoided.
    /rbconfig/  # required by rspec-support
  ]

  # Truffleruby cext files
  allowed_loaded_features << /\/truffle\/cext/ if RSpec::Support::Ruby.truffleruby?

  it_behaves_like "library wide checks", "rspec-expectations",
    :preamble_for_lib => [
      # We define minitest constants because rspec/expectations/minitest_integration
      # expects these constants to already be defined.
      "module Minitest; class Assertion; end; module Test; end; end",
      'require "rspec/expectations"'
    ],
    :allowed_loaded_feature_regexps => allowed_loaded_features

  it 'does not allow expectation failures to be caught by a bare rescue' do
    expect {
      expect(2).to eq(3) rescue nil
    }.to fail_including("expected: 3")
  end
end