From 5166ae2c267b3fe6e3df94608136fdf5076fbda8 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Fri, 2 Dec 2011 06:58:06 -0500 Subject: [PATCH] fix bug when path was nil --- lib/rack/livereload.rb | 2 +- spec/rack/livereload_spec.rb | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/lib/rack/livereload.rb b/lib/rack/livereload.rb index 85605a9..1f6837a 100644 --- a/lib/rack/livereload.rb +++ b/lib/rack/livereload.rb @@ -48,7 +48,7 @@ module Rack else status, headers, body = @app.call(env) - if !@options[:ignore] || !@options[:ignore].any? { |filter| path[filter] } + if !@options[:ignore] || !@options[:ignore].any? { |filter| env['PATH_INFO'][filter] } case headers['Content-Type'] when %r{text/html} content_length = 0 diff --git a/spec/rack/livereload_spec.rb b/spec/rack/livereload_spec.rb index ee0cbff..e36e154 100644 --- a/spec/rack/livereload_spec.rb +++ b/spec/rack/livereload_spec.rb @@ -135,10 +135,21 @@ describe Rack::LiveReload do context 'ignored' do let(:options) { { :ignore => [ %r{file} ] } } - let(:env) { { 'PATH_INFO' => 'this/file' } } - it 'should have no change' do - body.should_not include('script') + context 'not root' do + let(:env) { { 'PATH_INFO' => '/this/file' } } + + it 'should have no change' do + body.should_not include('script') + end + end + + context 'root' do + let(:env) { { 'PATH_INFO' => '/' } } + + it 'should have script' do + body.should include('script') + end end end end