|
72 | 72 | it "raises ArgumentError if the arguments include conflicting ASCII-incompatible Strings" do
|
73 | 73 | -> {
|
74 | 74 | Regexp.union("a".encode("UTF-16LE"), "b".encode("UTF-16BE"))
|
75 |
| - }.should raise_error(ArgumentError) |
| 75 | + }.should raise_error(ArgumentError, 'incompatible encodings: UTF-16LE and UTF-16BE') |
76 | 76 | end
|
77 | 77 |
|
78 | 78 | it "raises ArgumentError if the arguments include conflicting ASCII-incompatible Regexps" do
|
79 | 79 | -> {
|
80 | 80 | Regexp.union(Regexp.new("a".encode("UTF-16LE")),
|
81 | 81 | Regexp.new("b".encode("UTF-16BE")))
|
82 |
| - }.should raise_error(ArgumentError) |
| 82 | + }.should raise_error(ArgumentError, 'incompatible encodings: UTF-16LE and UTF-16BE') |
83 | 83 | end
|
84 | 84 |
|
85 | 85 | it "raises ArgumentError if the arguments include conflicting fixed encoding Regexps" do
|
86 | 86 | -> {
|
87 | 87 | Regexp.union(Regexp.new("a".encode("UTF-8"), Regexp::FIXEDENCODING),
|
88 | 88 | Regexp.new("b".encode("US-ASCII"), Regexp::FIXEDENCODING))
|
89 |
| - }.should raise_error(ArgumentError) |
| 89 | + }.should raise_error(ArgumentError, 'incompatible encodings: UTF-8 and US-ASCII') |
90 | 90 | end
|
91 | 91 |
|
92 | 92 | it "raises ArgumentError if the arguments include a fixed encoding Regexp and a String containing non-ASCII-compatible characters in a different encoding" do
|
93 | 93 | -> {
|
94 | 94 | Regexp.union(Regexp.new("a".encode("UTF-8"), Regexp::FIXEDENCODING),
|
95 | 95 | "\u00A9".encode("ISO-8859-1"))
|
96 |
| - }.should raise_error(ArgumentError) |
| 96 | + }.should raise_error(ArgumentError, 'incompatible encodings: UTF-8 and ISO-8859-1') |
97 | 97 | end
|
98 | 98 |
|
99 | 99 | it "raises ArgumentError if the arguments include a String containing non-ASCII-compatible characters and a fixed encoding Regexp in a different encoding" do
|
100 | 100 | -> {
|
101 | 101 | Regexp.union("\u00A9".encode("ISO-8859-1"),
|
102 | 102 | Regexp.new("a".encode("UTF-8"), Regexp::FIXEDENCODING))
|
103 |
| - }.should raise_error(ArgumentError) |
| 103 | + }.should raise_error(ArgumentError, 'incompatible encodings: ISO-8859-1 and UTF-8') |
104 | 104 | end
|
105 | 105 |
|
106 | 106 | it "raises ArgumentError if the arguments include an ASCII-incompatible String and an ASCII-only String" do
|
107 | 107 | -> {
|
108 | 108 | Regexp.union("a".encode("UTF-16LE"), "b".encode("UTF-8"))
|
109 |
| - }.should raise_error(ArgumentError) |
| 109 | + }.should raise_error(ArgumentError, /ASCII incompatible encoding: UTF-16LE|incompatible encodings: UTF-16LE and US-ASCII/) |
110 | 110 | end
|
111 | 111 |
|
112 | 112 | it "raises ArgumentError if the arguments include an ASCII-incompatible Regexp and an ASCII-only String" do
|
113 | 113 | -> {
|
114 | 114 | Regexp.union(Regexp.new("a".encode("UTF-16LE")), "b".encode("UTF-8"))
|
115 |
| - }.should raise_error(ArgumentError) |
| 115 | + }.should raise_error(ArgumentError, /ASCII incompatible encoding: UTF-16LE|incompatible encodings: UTF-16LE and US-ASCII/) |
116 | 116 | end
|
117 | 117 |
|
118 | 118 | it "raises ArgumentError if the arguments include an ASCII-incompatible String and an ASCII-only Regexp" do
|
119 | 119 | -> {
|
120 | 120 | Regexp.union("a".encode("UTF-16LE"), Regexp.new("b".encode("UTF-8")))
|
121 |
| - }.should raise_error(ArgumentError) |
| 121 | + }.should raise_error(ArgumentError, /ASCII incompatible encoding: UTF-16LE|incompatible encodings: UTF-16LE and US-ASCII/) |
122 | 122 | end
|
123 | 123 |
|
124 | 124 | it "raises ArgumentError if the arguments include an ASCII-incompatible Regexp and an ASCII-only Regexp" do
|
125 | 125 | -> {
|
126 | 126 | Regexp.union(Regexp.new("a".encode("UTF-16LE")), Regexp.new("b".encode("UTF-8")))
|
127 |
| - }.should raise_error(ArgumentError) |
| 127 | + }.should raise_error(ArgumentError, /ASCII incompatible encoding: UTF-16LE|incompatible encodings: UTF-16LE and US-ASCII/) |
128 | 128 | end
|
129 | 129 |
|
130 | 130 | it "raises ArgumentError if the arguments include an ASCII-incompatible String and a String containing non-ASCII-compatible characters in a different encoding" do
|
131 | 131 | -> {
|
132 | 132 | Regexp.union("a".encode("UTF-16LE"), "\u00A9".encode("ISO-8859-1"))
|
133 |
| - }.should raise_error(ArgumentError) |
| 133 | + }.should raise_error(ArgumentError, 'incompatible encodings: UTF-16LE and ISO-8859-1') |
134 | 134 | end
|
135 | 135 |
|
136 | 136 | it "raises ArgumentError if the arguments include an ASCII-incompatible Regexp and a String containing non-ASCII-compatible characters in a different encoding" do
|
137 | 137 | -> {
|
138 | 138 | Regexp.union(Regexp.new("a".encode("UTF-16LE")), "\u00A9".encode("ISO-8859-1"))
|
139 |
| - }.should raise_error(ArgumentError) |
| 139 | + }.should raise_error(ArgumentError, 'incompatible encodings: UTF-16LE and ISO-8859-1') |
140 | 140 | end
|
141 | 141 |
|
142 | 142 | it "raises ArgumentError if the arguments include an ASCII-incompatible String and a Regexp containing non-ASCII-compatible characters in a different encoding" do
|
143 | 143 | -> {
|
144 | 144 | Regexp.union("a".encode("UTF-16LE"), Regexp.new("\u00A9".encode("ISO-8859-1")))
|
145 |
| - }.should raise_error(ArgumentError) |
| 145 | + }.should raise_error(ArgumentError, 'incompatible encodings: UTF-16LE and ISO-8859-1') |
146 | 146 | end
|
147 | 147 |
|
148 | 148 | it "raises ArgumentError if the arguments include an ASCII-incompatible Regexp and a Regexp containing non-ASCII-compatible characters in a different encoding" do
|
149 | 149 | -> {
|
150 | 150 | Regexp.union(Regexp.new("a".encode("UTF-16LE")), Regexp.new("\u00A9".encode("ISO-8859-1")))
|
151 |
| - }.should raise_error(ArgumentError) |
| 151 | + }.should raise_error(ArgumentError, 'incompatible encodings: UTF-16LE and ISO-8859-1') |
152 | 152 | end
|
153 | 153 |
|
154 | 154 | it "uses to_str to convert arguments (if not Regexp)" do
|
|
172 | 172 | not_supported_on :opal do
|
173 | 173 | Regexp.union([/dogs/, /cats/i]).should == /(?-mix:dogs)|(?i-mx:cats)/
|
174 | 174 | end
|
175 |
| - ->{Regexp.union(["skiing", "sledding"], [/dogs/, /cats/i])}.should raise_error(TypeError) |
| 175 | + -> { |
| 176 | + Regexp.union(["skiing", "sledding"], [/dogs/, /cats/i]) |
| 177 | + }.should raise_error(TypeError, 'no implicit conversion of Array into String') |
176 | 178 | end
|
177 | 179 | end
|
0 commit comments