This repository was archived by the owner on Nov 30, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change
1
+ # # encoding: utf-8
2
+ require 'spec_helper'
3
+ require 'rspec/core/notifications'
4
+
5
+ RSpec . describe "FailedExampleNotification" do
6
+ break unless String . method_defined? ( :encoding )
7
+
8
+ include FormatterSupport
9
+
10
+ let ( :notification ) { ::RSpec ::Core ::Notifications ::FailedExampleNotification . new ( example ) }
11
+
12
+ before do
13
+ allow ( example ) . to receive ( :file_path ) { __FILE__ }
14
+ end
15
+
16
+ describe '#message_lines' do
17
+ let ( :message_with_invalid_byte_sequence ) do
18
+ "\xEF \255 \xAD " . force_encoding ( Encoding ::UTF_8 )
19
+ end
20
+ let ( :exception ) do
21
+ instance_double (
22
+ Exception ,
23
+ :backtrace => [ "#{ __FILE__ } :#{ __LINE__ } " ] ,
24
+ :message => message_with_invalid_byte_sequence ,
25
+ )
26
+ end
27
+ let ( :example_group ) do
28
+ class_double (
29
+ RSpec ::Core ::ExampleGroup ,
30
+ :metadata => { } ,
31
+ :parent_groups => [ ] ,
32
+ :location => "#{ __FILE__ } :#{ __LINE__ } "
33
+ )
34
+ end
35
+
36
+ before do
37
+ allow ( example ) . to receive ( :example_group ) { example_group }
38
+ end
39
+
40
+ context "when failure_lines contains an invalid byte sequence" do
41
+ it "raises an ArgumentError" do
42
+ expect { lines = notification . message_lines } . to raise_error ( ArgumentError )
43
+ end
44
+ end
45
+
46
+ end
47
+ end
You can’t perform that action at this time.
0 commit comments