spec/regexp-examples_spec.rb in regexp-examples-0.5.1 vs spec/regexp-examples_spec.rb in regexp-examples-0.5.2
- old
+ new
@@ -229,10 +229,17 @@
/[^\d\D]{2}/,
/[^\d\D]word/
)
end
+ context "comment group" do
+ examples_exist_and_match(
+ /a(?#comment)b/,
+ /a(?#ugly backslashy\ comment\\\))b/
+ )
+ end
+
context "exact examples match" do
# More rigorous tests to assert that ALL examples are being listed
context "default config options" do
# Simple examples
it { expect(/[ab]{2}/.examples).to eq ["aa", "ab", "ba", "bb"] }
@@ -280,9 +287,22 @@
/
line1 #comment
line2 #comment
/x.examples
).to eq %w(line1line2)
+ end
+ end
+
+ context "options toggling" do
+ context "rest of string" do
+ it { expect(/a(?i)b(?-i)c/.examples).to eq %w{abc aBc}}
+ it { expect(/a(?x) b(?-x) c/.examples).to eq %w{ab\ c}}
+ it { expect(/(?m)./.examples(max_group_results: 999)).to include "\n" }
+ end
+ context "subexpression" do
+ it { expect(/a(?i:b)c/.examples).to eq %w{abc aBc}}
+ it { expect(/a(?i:b(?-i:c))/.examples).to eq %w{abc aBc}}
+ it { expect(/a(?-i:b)c/i.examples).to eq %w{abc abC Abc AbC}}
end
end
end
end