Sha256: a6695604e95ddac8290bc9addbb1d4d0816e092763239682c10c928be7b7c1bf
Contents?: true
Size: 1.99 KB
Versions: 1
Compression:
Stored size: 1.99 KB
Contents
describe RegXing::Regex do describe "#to_s" do let(:exp) { described_class.new(/.*/) } it "converts to a string" do expect(exp.to_s).to be_a String end it "removes the slashes" do expect(exp.to_s).to eql ".*" end end describe "#split" do context "basic case" do let(:exp) { described_class.new(/\d/) } it "returns the expression as an array" do expect(exp.split).to eql [ '\d' ] end end context "multiple items" do let(:exp) { described_class.new(/\d\w/) } it "returns an array of character classes" do expect(exp.split).to eql [ '\d', '\w' ] end end context "with symbols" do let(:exp) { described_class.new(/.\d+/) } it "handles the symbols properly" do expect(exp.split).to eql [ '.', '\d', '+' ] end end context "with escaped characters" do let(:exp) { described_class.new(/\d+\.\d+/) } it "captures the escape" do expect(exp.split).to eql [ '\d', '+', '\.', '\d', '+' ] end end context "with ranges" do context "with minimum" do let(:exp) { described_class.new(/\w{2,}/) } it "captures the expression in the curly braces" do expect(exp.split).to eql [ '\w', '{2,}' ] end end context "with maximum" do let(:exp) { described_class.new(/\w{,3}/) } it "captures the expression in the curly braces" do expect(exp.split).to eql [ '\w', '{,3}' ] end end context "with minimum and maximum" do let(:exp) { described_class.new(/\s{2,3}/) } it "captures the expression in the curly braces" do expect(exp.split).to eql [ '\s', '{2,3}' ] end end context "with literals" do let(:exp) { described_class.new(/Jan-\d{2}-2016/) } it "captures the literals" do expect(exp.split).to eql [ 'J', 'a', 'n', '-', '\d', '{2}', '-', '2', '0', '1', '6' ] end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
regxing-0.0.1.beta | spec/lib/regxing/regex_spec.rb |