spec/rack/livereload_spec.rb in rack-livereload-0.3.9 vs spec/rack/livereload_spec.rb in rack-livereload-0.3.10
- old
+ new
@@ -105,10 +105,21 @@
body_dom.at_css("script:eq(4)")[:src].should include(described_class::LIVERELOAD_JS_PATH)
body_dom.at_css("script:last-child")[:insert].should == "before"
end
end
+ context 'in header tags' do
+ let(:page_html) { "<header class='hero'><h1>Just a normal header tag</h1></header>" }
+
+ let(:body_dom) { Nokogiri::XML(body) }
+
+ it 'should not add the livereload js' do
+ body_dom.at_css("header")[:class].should == 'hero'
+ body_dom.css('script').should be_empty
+ end
+ end
+
context 'not vendored' do
before do
middleware.stubs(:use_vendored?).returns(false)
end
@@ -209,8 +220,25 @@
describe '#bad_browser?' do
let(:user_agent) { described_class::BAD_USER_AGENTS.first.source }
it { should be_bad_browser(user_agent) }
+ 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