1
1
module RSpecHelpers
2
- def expect_no_deprecation
3
- expect ( RSpec . configuration . reporter ) . not_to receive ( :deprecation )
4
- end
5
-
6
2
def expect_deprecation_with_call_site ( file , line , snippet = // )
7
- expect ( RSpec . configuration . reporter ) . to receive ( :deprecation ) do |options |
8
- expect ( options [ :call_site ] ) . to include ( [ file , line ] . join ( ':' ) )
9
- expect ( options [ :deprecated ] ) . to match ( snippet )
10
- end
3
+ expect ( RSpec . configuration . reporter ) . to receive ( :deprecation ) .
4
+ with ( include ( :deprecated => match ( snippet ) , :call_site => include ( [ file , line ] . join ( ':' ) ) ) )
11
5
end
12
6
13
7
def expect_deprecation_without_call_site ( snippet = // )
14
- expect ( RSpec . configuration . reporter ) . to receive ( :deprecation ) do |options |
15
- expect ( options [ :call_site ] ) . to eq nil
16
- expect ( options [ :deprecated ] ) . to match ( snippet )
17
- end
8
+ expect ( RSpec . configuration . reporter ) . to receive ( :deprecation ) .
9
+ with ( include ( :deprecated => match ( snippet ) , :call_site => eq ( nil ) ) )
18
10
end
19
11
20
12
def expect_warn_deprecation_with_call_site ( file , line , snippet = // )
21
- expect ( RSpec . configuration . reporter ) . to receive ( :deprecation ) do |options |
22
- message = options [ :message ]
23
- expect ( message ) . to match ( snippet )
24
- expect ( message ) . to include ( [ file , line ] . join ( ':' ) )
25
- end
13
+ expect ( RSpec . configuration . reporter ) . to receive ( :deprecation ) .
14
+ with ( include ( :message => match ( snippet ) , :call_site => include ( [ file , line ] . join ( ':' ) ) ) )
26
15
end
27
16
28
17
def expect_warn_deprecation ( snippet = // )
29
- expect ( RSpec . configuration . reporter ) . to receive ( :deprecation ) do |options |
30
- message = options [ :message ]
31
- expect ( message ) . to match ( snippet )
32
- end
18
+ expect ( RSpec . configuration . reporter ) . to receive ( :deprecation ) .
19
+ with ( include ( :message => match ( snippet ) ) )
33
20
end
34
21
35
22
def allow_deprecation
@@ -39,19 +26,16 @@ def allow_deprecation
39
26
def expect_no_deprecations
40
27
expect ( RSpec . configuration . reporter ) . not_to receive ( :deprecation )
41
28
end
29
+ alias expect_no_deprecation expect_no_deprecations
42
30
43
31
def expect_warning_without_call_site ( expected = // )
44
- expect ( ::Kernel ) . to receive ( :warn ) do |message |
45
- expect ( message ) . to match expected
46
- expect ( message ) . to_not match ( /Called from/ )
47
- end
32
+ expect ( ::Kernel ) . to receive ( :warn ) .
33
+ with ( match ( expected ) . and ( satisfy { |message | !message . match? ( /Called from/ ) } ) )
48
34
end
49
35
50
36
def expect_warning_with_call_site ( file , line , expected = // )
51
- expect ( ::Kernel ) . to receive ( :warn ) do |message |
52
- expect ( message ) . to match expected
53
- expect ( message ) . to match ( /Called from #{ file } :#{ line } / )
54
- end
37
+ expect ( ::Kernel ) . to receive ( :warn ) .
38
+ with ( match ( expected ) . and ( match ( /Called from #{ file } :#{ line } / ) ) )
55
39
end
56
40
57
41
def expect_no_warnings
0 commit comments