| 1 |
|
| 2 |
|
| 3 |
RSpec.describe Kernel do |
| 4 |
describe ".RE2" do |
| 5 |
it "returns an RE2::Regexp instance given a pattern" do |
| 6 |
expect(RE2('w(o)(o)')).to be_a(RE2::Regexp) |
| 7 |
end |
| 8 |
|
| 9 |
it "returns an RE2::Regexp instance given a pattern and options" do |
| 10 |
re = RE2('w(o)(o)', case_sensitive: false) |
| 11 |
|
| 12 |
expect(re).not_to be_case_sensitive |
| 13 |
end |
| 14 |
|
| 15 |
it "accepts patterns containing null bytes" do |
| 16 |
re = RE2("a\0b") |
| 17 |
|
| 18 |
expect(re.pattern).to eq("a\0b") |
| 19 |
end |
| 20 |
|
| 21 |
it "raises an error if given an inappropriate type" do |
| 22 |
expect { RE2(nil) }.to raise_error(TypeError) |
| 23 |
end |
| 24 |
|
| 25 |
it "allows invalid patterns to be created" do |
| 26 |
re = RE2('???', log_errors: false) |
| 27 |
|
| 28 |
expect(re).to be_a(RE2::Regexp) |
| 29 |
end |
| 30 |
|
| 31 |
it "supports passing something that can be coerced to a String as input" do |
| 32 |
re = RE2(StringLike.new('w(o)(o)')) |
| 33 |
|
| 34 |
expect(re).to be_a(RE2::Regexp) |
| 35 |
end |
| 36 |
end |
| 37 |
end |