1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

enables the evented monitor in new applications

This commit is contained in:
Xavier Noria 2016-02-10 00:18:25 +01:00
parent b5eb2423b6
commit de6ad5665d
5 changed files with 35 additions and 1 deletions

View file

@ -1,3 +1,8 @@
* New applications are generated with the evented file system monitor enabled
on Linux and Mac OS X.
*Xavier Noria*
* Add dummy files for apple-touch-icon.png and apple-touch-icon.png. GH#23427
*Alexey Zabelin*

View file

@ -390,6 +390,10 @@ module Rails
!options[:skip_spring] && !options.dev? && Process.respond_to?(:fork) && !RUBY_PLATFORM.include?("cygwin")
end
def os_supports_listen_out_of_the_box?
RbConfig::CONFIG['host_os'] =~ /darwin|linux/
end
def run_bundle
bundle_command('install') if bundle_install?
end

View file

@ -38,6 +38,9 @@ group :development do
gem 'web-console', '~> 3.0'
<%- end -%>
<%- end -%>
<% if os_supports_listen_out_of_the_box? -%>
gem 'listen', '~> 3.0.5'
<% end -%>
<% if spring_install? -%>
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'

View file

@ -58,5 +58,5 @@ Rails.application.configure do
# Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem.
# config.file_watcher = ActiveSupport::EventedFileUpdateChecker
<%= '# ' unless os_supports_listen_out_of_the_box? %>config.file_watcher = ActiveSupport::EventedFileUpdateChecker
end

View file

@ -479,6 +479,28 @@ class AppGeneratorTest < Rails::Generators::TestCase
end
end
def test_inclusion_of_listen_related_gems
run_generator
if RbConfig::CONFIG['host_os'] =~ /darwin|linux/
assert_gem 'listen'
else
assert_file 'Gemfile' do |content|
assert_no_match(/listen/, content)
end
end
end
def test_evented_file_update_checker_config
run_generator
assert_file 'config/environments/development.rb' do |content|
if RbConfig::CONFIG['host_os'] =~ /darwin|linux/
assert_match(/^\s*config.file_watcher = ActiveSupport::EventedFileUpdateChecker/, content)
else
assert_match(/^\s*# config.file_watcher = ActiveSupport::EventedFileUpdateChecker/, content)
end
end
end
def test_template_from_dir_pwd
FileUtils.cd(Rails.root)
assert_match(/It works from file!/, run_generator([destination_root, "-m", "lib/template.rb"]))