a few more fixes

This commit is contained in:
John Bintz 2011-11-07 08:49:42 -05:00
parent fde86b211b
commit 17d4bed4eb
2 changed files with 8 additions and 17 deletions

View File

@ -3,19 +3,7 @@
guard 'rspec', :version => 2 do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }
# Rails example
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
watch('spec/spec_helper.rb') { "spec" }
watch('config/routes.rb') { "spec/routing" }
watch('app/controllers/application_controller.rb') { "spec/controllers" }
# Capybara request specs
watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
end

View File

@ -16,19 +16,22 @@ module Rack
case headers['Content-Type']
when %r{text/html}
content_length = 0
body.each do |line|
if line['</head>']
if !headers['X-Rack-LiveReload'] && line['</head>']
src = LIVERELOAD_JS_PATH.dup
src << "?host=#{env['HTTP_HOST'].gsub(%r{:.*}, '')}" if env['HTTP_HOST']
line.gsub!('</head>', %{<script type="text/javascript" src="#{src}"></script></head>})
headers["X-Rack-LiveReload"] = '1'
break
end
end
headers['Content-Length'] = body.join.length.to_s
content_length += line.length
end
headers['Content-Length'] = content_length.to_s
end
[ status, headers, body ]