add specs for regex

This commit is contained in:
Matthew Lehner 2012-12-13 16:27:16 -08:00
parent 706d158328
commit 0c5d9bc06b
1 changed files with 17 additions and 0 deletions

View File

@ -223,5 +223,22 @@ describe Rack::LiveReload do
it { should be_bad_browser(user_agent) } it { should be_bad_browser(user_agent) }
end end
describe 'head tag regex' do
let(:regex) { described_class::HEAD_TAG_REGEX }
subject { regex }
it { should be_kind_of(Regexp) }
it 'only picks a valid <head> tag' do
regex.match("<head></head>").to_s.should eq('<head>')
regex.match("<head><title></title></head>").to_s.should eq('<head>')
regex.match("<head attribute='something'><title></title></head>").to_s.should eq("<head attribute='something'>")
end
it 'responds false when no head tag' do
regex.match("<header></header>").should be_false
end
end
end end