Last active
July 11, 2017 13:19
-
-
Save KamiKillertO/12bd7910350a50a7da5928a8dfe250dd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
# /$$ /$$ | |
# | $$ |__/ | |
# /$$$$$$$ /$$$$$$ /$$$$$$ /$$ /$$$$$$$ /$$$$$$ | |
# /$$_____/|_ $$_/ /$$__ $$| $$| $$__ $$ /$$__ $$ | |
# | $$$$$$ | $$ | $$ \__/| $$| $$ \ $$| $$ \ $$ | |
# \____ $$ | $$ /$$| $$ | $$| $$ | $$| $$ | $$ | |
# /$$$$$$$/ | $$$$/| $$ | $$| $$ | $$| $$$$$$$ | |
# |_______/ \___/ |__/ |__/|__/ |__/ \____ $$ | |
# /$$ \ $$ | |
# | $$$$$$/ | |
# \______/ | |
describe //, 'LVL 1' do | |
it { should match 'cat' } | |
it { should match 'CAT' } | |
it { should match 'cate' } | |
it { should match 'Cate' } | |
it { should_not match 'ct' } | |
it { should_not match '1' } | |
it { should_not match '' } | |
it { should_not match nil } | |
end | |
describe //, 'LVL 2' do | |
it { should match 'cat' } | |
it { should match 'CAT' } | |
it { should match 'Cat' } | |
it { should match 'aCat' } | |
it { should_not match 'cate' } | |
it { should_not match 'Cate' } | |
it { should_not match 'ct' } | |
it { should_not match '1' } | |
it { should_not match '' } | |
it { should_not match nil } | |
end | |
describe //, 'LVL 3' do | |
it { should match 'cat' } | |
it { should match 'CAT' } | |
it { should match 'Cat' } | |
it { should_not match 'aCat' } | |
it { should_not match 'cate' } | |
it { should_not match 'Cate' } | |
it { should_not match 'ct' } | |
it { should_not match '1' } | |
it { should_not match '' } | |
it { should_not match nil } | |
end | |
describe //, 'LVL 4' do | |
it { should match 'cat' } | |
it { should match 'caaaaaaaaaaaat' } | |
it { should match 'CAT' } | |
it { should match 'Cat' } | |
it { should_not match 'aCat' } | |
it { should_not match 'cate' } | |
it { should_not match 'Cate' } | |
it { should_not match 'ct' } | |
it { should_not match '1' } | |
it { should_not match '' } | |
it { should_not match nil } | |
end | |
# max five a | |
describe //, 'LVL 5' do | |
it { should match 'cat' } | |
it { should match 'caaaaat' } | |
it { should match 'CAT' } | |
it { should match 'Cat' } | |
it { should_not match 'aCat' } | |
it { should_not match 'caaaaaaaaaaaat' } | |
it { should_not match 'cate' } | |
it { should_not match 'Cate' } | |
it { should_not match 'ct' } | |
it { should_not match '1' } | |
it { should_not match 'h' } | |
it { should_not match 'caht' } | |
it { should_not match '' } | |
it { should_not match nil } | |
end | |
describe //, 'LVL 6' do | |
it { should match 'cat' } | |
it { should match 'chat' } | |
it { should match 'caaaaaaaaaaaat' } | |
it { should match 'chaaaaaaaaaaaat' } | |
it { should match 'CAT' } | |
it { should match 'Cat' } | |
it { should_not match 'aCat' } | |
it { should_not match 'cate' } | |
it { should_not match 'Cate' } | |
it { should_not match 'ct' } | |
it { should_not match '1' } | |
it { should_not match 'h' } | |
it { should_not match 'caht' } | |
it { should_not match '' } | |
it { should_not match nil } | |
end | |
# /$$ | |
# | $$ | |
# /$$$$$$$ /$$ /$$ /$$$$$$/$$$$ | $$$$$$$ /$$$$$$ /$$$$$$ | |
# | $$__ $$| $$ | $$| $$_ $$_ $$| $$__ $$ /$$__ $$ /$$__ $$ | |
# | $$ \ $$| $$ | $$| $$ \ $$ \ $$| $$ \ $$| $$$$$$$$| $$ \__/ | |
# | $$ | $$| $$ | $$| $$ | $$ | $$| $$ | $$| $$_____/| $$ | |
# | $$ | $$| $$$$$$/| $$ | $$ | $$| $$$$$$$/| $$$$$$$| $$ | |
# |__/ |__/ \______/ |__/ |__/ |__/|_______/ \_______/|__/ | |
describe //, 'LVL 7' do | |
it { should match '1' } | |
it { should match '10' } | |
it { should match '1000' } | |
it { should match '2310' } | |
it { should_not match '' } | |
it { should_not match '1.2' } | |
it { should_not match 'a' } | |
it { should_not match 'chat' } | |
it { should_not match nil } | |
end | |
describe //, 'LVL 8' do | |
it { should match '1' } | |
it { should match '10' } | |
it { should match '1000' } | |
it { should match '1.2' } | |
it { should match '1000.20301' } | |
it { should_not match '' } | |
it { should_not match '100.' } | |
it { should_not match 'a' } | |
it { should_not match 'chat' } | |
it { should_not match nil } | |
end | |
describe //, 'LVL 9' do | |
it { should match '1' } | |
it { should match '10' } | |
it { should match '1 000' } | |
it { should match '1.2' } | |
it { should match '1 000.20301' } | |
it { should_not match '1000' } | |
it { should_not match '100.' } | |
it { should_not match '10.1 000' } | |
it { should_not match '' } | |
it { should_not match nil } | |
end | |
describe //, 'LVL 10' do | |
it { should match '1' } | |
it { should match '0' } | |
it { should match '0.0' } | |
it { should match '1.0' } | |
it { should match '0.2' } | |
it { should match '.2' } | |
it { should_not match 'a' } | |
it { should_not match '' } | |
it { should_not match '10' } | |
it { should_not match 'a' } | |
it { should_not match '1.2' } | |
it { should_not match '.' } | |
end | |
# /$$ /$$ | |
# | $$ | $$ | |
# /$$$$$$ /$$$$$$ | $$$$$$$ /$$$$$$ /$$$$$$ | |
# /$$__ $$|_ $$_/ | $$__ $$ /$$__ $$ /$$__ $$ | |
# | $$ \ $$ | $$ | $$ \ $$| $$$$$$$$| $$ \__/ | |
# | $$ | $$ | $$ /$$| $$ | $$| $$_____/| $$ | |
# | $$$$$$/ | $$$$/| $$ | $$| $$$$$$$| $$ | |
# \______/ \___/ |__/ |__/ \_______/|__/ | |
# Simple email [email protected] or [email protected] | |
describe //, 'LVL 11' do | |
it { should match '[email protected]' } | |
it { should match '[email protected]' } | |
it { should match '[email protected]' } | |
it { should_not match '@m.fr' } | |
it { should_not match '[email protected]' } | |
it { should_not match 'jb@mail' } | |
it { should_not match '' } | |
it { should_not match '@mail' } | |
it { should_not match '@mail.fr' } | |
it { should_not match 'jb' } | |
it { should_not match 'j.b' } | |
end | |
# hexa colors from #000(000) to #fff(fff) | |
describe //, 'LVL 12' do | |
it { should match '#000' } | |
it { should match '#000000' } | |
it { should match '#FFF' } | |
it { should match '#fff' } | |
it { should match '#ffffff' } | |
it { should match '#fafcfb' } | |
it { should_not match '#ff' } | |
it { should_not match '#ffff' } | |
it { should_not match '#fffffff' } | |
it { should_not match '#' } | |
it { should_not match '#ffg' } | |
it { should_not match 'fff' } | |
end | |
describe //, 'LVL 13' do | |
it { should match 'http://monsite.fr' } | |
it { should match 'https://monsite.fr' } | |
it { should match 'http://mon-site.fr' } | |
it { should match 'http://mon.site.fr' } | |
it { should match 'http://monsite.fr/welcome' } | |
it { should match 'http://monsite.fr/welcome.php' } | |
it { should_not match 'http://monsite.fr/' } | |
it { should_not match 'http://monsite.fr/welcome!.php' } | |
it { should_not match 'http://@monsite.fr' } | |
it { should_not match 'http://#monsite.fr' } | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
# /$$ /$$ | |
# | $$ |__/ | |
# /$$$$$$$ /$$$$$$ /$$$$$$ /$$ /$$$$$$$ /$$$$$$ | |
# /$$_____/|_ $$_/ /$$__ $$| $$| $$__ $$ /$$__ $$ | |
# | $$$$$$ | $$ | $$ \__/| $$| $$ \ $$| $$ \ $$ | |
# \____ $$ | $$ /$$| $$ | $$| $$ | $$| $$ | $$ | |
# /$$$$$$$/ | $$$$/| $$ | $$| $$ | $$| $$$$$$$ | |
# |_______/ \___/ |__/ |__/|__/ |__/ \____ $$ | |
# /$$ \ $$ | |
# | $$$$$$/ | |
# \______/ | |
describe /cat/i, 'LVL 1' do | |
it { should match 'cat' } | |
it { should match 'CAT' } | |
it { should match 'cate' } | |
it { should match 'Cate' } | |
it { should_not match 'ct' } | |
it { should_not match '1' } | |
it { should_not match '' } | |
it { should_not match nil } | |
end | |
describe /cat$/i, 'LVL 2' do | |
it { should match 'cat' } | |
it { should match 'CAT' } | |
it { should match 'Cat' } | |
it { should match 'aCat' } | |
it { should_not match 'cate' } | |
it { should_not match 'Cate' } | |
it { should_not match 'ct' } | |
it { should_not match '1' } | |
it { should_not match '' } | |
it { should_not match nil } | |
end | |
describe /^cat$/i, 'LVL 3' do | |
it { should match 'cat' } | |
it { should match 'CAT' } | |
it { should match 'Cat' } | |
it { should_not match 'aCat' } | |
it { should_not match 'cate' } | |
it { should_not match 'Cate' } | |
it { should_not match 'ct' } | |
it { should_not match '1' } | |
it { should_not match '' } | |
it { should_not match nil } | |
end | |
describe /^ca+t$/i, 'LVL 4' do | |
it { should match 'cat' } | |
it { should match 'caaaaaaaaaaaat' } | |
it { should match 'CAT' } | |
it { should match 'Cat' } | |
it { should_not match 'aCat' } | |
it { should_not match 'cate' } | |
it { should_not match 'Cate' } | |
it { should_not match 'ct' } | |
it { should_not match '1' } | |
it { should_not match '' } | |
it { should_not match nil } | |
end | |
# max five a | |
describe /^ca{1,5}t$/i, 'LVL 5' do | |
it { should match 'cat' } | |
it { should match 'caaaaat' } | |
it { should match 'CAT' } | |
it { should match 'Cat' } | |
it { should_not match 'aCat' } | |
it { should_not match 'caaaaaaaaaaaat' } | |
it { should_not match 'cate' } | |
it { should_not match 'Cate' } | |
it { should_not match 'ct' } | |
it { should_not match '1' } | |
it { should_not match 'h' } | |
it { should_not match 'caht' } | |
it { should_not match '' } | |
it { should_not match nil } | |
end | |
describe /^ch?a+t$/i, 'LVL 6' do | |
it { should match 'cat' } | |
it { should match 'chat' } | |
it { should match 'caaaaaaaaaaaat' } | |
it { should match 'chaaaaaaaaaaaat' } | |
it { should match 'CAT' } | |
it { should match 'Cat' } | |
it { should_not match 'aCat' } | |
it { should_not match 'cate' } | |
it { should_not match 'Cate' } | |
it { should_not match 'ct' } | |
it { should_not match '1' } | |
it { should_not match 'h' } | |
it { should_not match 'caht' } | |
it { should_not match '' } | |
it { should_not match nil } | |
end | |
# /$$ | |
# | $$ | |
# /$$$$$$$ /$$ /$$ /$$$$$$/$$$$ | $$$$$$$ /$$$$$$ /$$$$$$ | |
# | $$__ $$| $$ | $$| $$_ $$_ $$| $$__ $$ /$$__ $$ /$$__ $$ | |
# | $$ \ $$| $$ | $$| $$ \ $$ \ $$| $$ \ $$| $$$$$$$$| $$ \__/ | |
# | $$ | $$| $$ | $$| $$ | $$ | $$| $$ | $$| $$_____/| $$ | |
# | $$ | $$| $$$$$$/| $$ | $$ | $$| $$$$$$$/| $$$$$$$| $$ | |
# |__/ |__/ \______/ |__/ |__/ |__/|_______/ \_______/|__/ | |
describe /^\d+$/, 'LVL 7' do | |
it { should match '1' } | |
it { should match '10' } | |
it { should match '1000' } | |
it { should match '2310' } | |
it { should_not match '' } | |
it { should_not match '1.2' } | |
it { should_not match 'a' } | |
it { should_not match 'chat' } | |
it { should_not match nil } | |
end | |
describe /^\d+(\.\d+)?$/, 'LVL 8' do | |
it { should match '1' } | |
it { should match '10' } | |
it { should match '1000' } | |
it { should match '1.2' } | |
it { should match '1000.20301' } | |
it { should_not match '' } | |
it { should_not match '100.' } | |
it { should_not match 'a' } | |
it { should_not match 'chat' } | |
it { should_not match nil } | |
end | |
describe /^\d{1,3}(?:\s\d{3})*(\.\d+)?$/, 'LVL 9' do | |
it { should match '1' } | |
it { should match '10' } | |
it { should match '1 000' } | |
it { should match '1.2' } | |
it { should_not match '1000' } | |
it { should_not match '100.' } | |
it { should_not match '10.1 000' } | |
it { should_not match '' } | |
it { should_not match nil } | |
end | |
describe /^(?:[0-1]|1\.0|0(?:\.\d+)?|(?:\.\d+))$/, 'LVL 10' do | |
it { should match '1' } | |
it { should match '0' } | |
it { should match '0.0' } | |
it { should match '1.0' } | |
it { should match '0.2' } | |
it { should match '.2' } | |
it { should_not match 'a' } | |
it { should_not match '' } | |
it { should_not match '10' } | |
it { should_not match 'a' } | |
it { should_not match '1.2' } | |
it { should_not match '.' } | |
end | |
# /$$ /$$ | |
# | $$ | $$ | |
# /$$$$$$ /$$$$$$ | $$$$$$$ /$$$$$$ /$$$$$$ | |
# /$$__ $$|_ $$_/ | $$__ $$ /$$__ $$ /$$__ $$ | |
# | $$ \ $$ | $$ | $$ \ $$| $$$$$$$$| $$ \__/ | |
# | $$ | $$ | $$ /$$| $$ | $$| $$_____/| $$ | |
# | $$$$$$/ | $$$$/| $$ | $$| $$$$$$$| $$ | |
# \______/ \___/ |__/ |__/ \_______/|__/ | |
# Simple email [email protected] or [email protected] | |
describe /\w+.?\w*@\w+\.\w+/, 'LVL 11' do | |
it { should match '[email protected]' } | |
it { should match '[email protected]' } | |
it { should match '[email protected]' } | |
it { should_not match '@m.fr' } | |
it { should_not match '[email protected]' } | |
it { should_not match 'jb@mail' } | |
it { should_not match '' } | |
it { should_not match '@mail' } | |
it { should_not match '@mail.fr' } | |
it { should_not match 'jb' } | |
it { should_not match 'j.b' } | |
end | |
# hexa colors from #000(000) to #fff(fff) | |
describe /^(#[\da-f]{3}|#[\da-f]{6})$/i, 'LVL 12' do | |
it { should match '#000' } | |
it { should match '#000000' } | |
it { should match '#FFF' } | |
it { should match '#fff' } | |
it { should match '#ffffff' } | |
it { should match '#fafcfb' } | |
it { should_not match '#ff' } | |
it { should_not match '#ffff' } | |
it { should_not match '#fffffff' } | |
it { should_not match '#' } | |
it { should_not match '#ffg' } | |
it { should_not match 'fff' } | |
end | |
describe /^https?:\/\/[\d\w\-_\.]+\.([a-z\.]{2,6})(\/[\d\w\-_\.]+)*$/, 'LVL 13' do | |
it { should match 'http://monsite.fr' } | |
it { should match 'https://monsite.fr' } | |
it { should match 'http://mon-site.fr' } | |
it { should match 'http://mon.site.fr' } | |
it { should match 'http://monsite.fr/welcome' } | |
it { should match 'http://monsite.fr/welcome.php' } | |
it { should_not match 'http://monsite.fr/' } | |
it { should_not match 'http://monsite.fr/welcome!.php' } | |
it { should_not match 'http://@monsite.fr' } | |
it { should_not match 'http://#monsite.fr' } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment