├── .gitignore ├── Gemfile ├── LICENSE ├── README.md ├── Rakefile ├── lib ├── require_reloader.rb └── require_reloader │ ├── helper.rb │ ├── railtie.rb │ └── version.rb ├── require_reloader.gemspec └── test ├── require_reloader └── helper_test.rb └── resources ├── Gemfile ├── rails30-app ├── .gitignore ├── Gemfile ├── README ├── Rakefile ├── app │ ├── controllers │ │ ├── application_controller.rb │ │ └── test_controller.rb │ ├── helpers │ │ └── application_helper.rb │ └── views │ │ └── layouts │ │ └── application.html.erb ├── config.ru ├── config │ ├── application.rb │ ├── boot.rb │ ├── database.yml │ ├── environment.rb │ ├── environments │ │ ├── development.rb │ │ ├── production.rb │ │ └── test.rb │ ├── initializers │ │ ├── backtrace_silencers.rb │ │ ├── inflections.rb │ │ ├── mime_types.rb │ │ ├── secret_token.rb │ │ └── session_store.rb │ ├── locales │ │ └── en.yml │ └── routes.rb ├── db │ ├── schema.rb │ └── seeds.rb ├── gems │ └── sample_gem1 │ │ ├── .gitignore │ │ ├── Gemfile │ │ ├── LICENSE.txt │ │ ├── README.md │ │ ├── Rakefile │ │ ├── lib │ │ ├── sample_gem1.modified.rb │ │ ├── sample_gem1.original.rb │ │ ├── sample_gem1.rb │ │ └── sample_gem1 │ │ │ ├── base.modified.rb │ │ │ ├── base.original.rb │ │ │ ├── base.rb │ │ │ └── version.rb │ │ └── sample_gem1.gemspec ├── lib │ ├── sample_gem2.modified.rb │ ├── sample_gem2.original.rb │ ├── sample_gem2.rb │ ├── sample_gem2 │ │ ├── base.modified.rb │ │ ├── base.original.rb │ │ └── base.rb │ └── tasks │ │ ├── .gitkeep │ │ └── test.rake ├── public │ ├── 404.html │ ├── 422.html │ ├── 500.html │ ├── favicon.ico │ ├── images │ │ └── rails.png │ ├── index.html │ ├── javascripts │ │ ├── application.js │ │ ├── controls.js │ │ ├── dragdrop.js │ │ ├── effects.js │ │ ├── prototype.js │ │ └── rails.js │ ├── robots.txt │ └── stylesheets │ │ └── .gitkeep ├── script │ └── rails ├── test │ ├── integration │ │ └── reload_require_files_test.rb │ ├── performance │ │ └── browsing_test.rb │ └── test_helper.rb └── vendor │ └── plugins │ └── .gitkeep ├── rails31-app ├── .gitignore ├── Gemfile ├── README ├── Rakefile ├── app │ ├── assets │ │ ├── images │ │ │ └── rails.png │ │ ├── javascripts │ │ │ └── application.js │ │ └── stylesheets │ │ │ └── application.css │ ├── controllers │ │ ├── application_controller.rb │ │ └── test_controller.rb │ ├── helpers │ │ └── application_helper.rb │ ├── mailers │ │ └── .gitkeep │ ├── models │ │ └── .gitkeep │ └── views │ │ └── layouts │ │ └── application.html.erb ├── config.ru ├── config │ ├── application.rb │ ├── boot.rb │ ├── database.yml │ ├── environment.rb │ ├── environments │ │ ├── development.rb │ │ ├── production.rb │ │ └── test.rb │ ├── initializers │ │ ├── backtrace_silencers.rb │ │ ├── inflections.rb │ │ ├── mime_types.rb │ │ ├── secret_token.rb │ │ ├── session_store.rb │ │ └── wrap_parameters.rb │ ├── locales │ │ └── en.yml │ └── routes.rb ├── db │ ├── schema.rb │ └── seeds.rb ├── gems │ └── sample_gem1 │ │ ├── .gitignore │ │ ├── Gemfile │ │ ├── LICENSE.txt │ │ ├── README.md │ │ ├── Rakefile │ │ ├── lib │ │ ├── sample_gem1.modified.rb │ │ ├── sample_gem1.original.rb │ │ ├── sample_gem1.rb │ │ └── sample_gem1 │ │ │ ├── base.modified.rb │ │ │ ├── base.original.rb │ │ │ ├── base.rb │ │ │ └── version.rb │ │ └── sample_gem1.gemspec ├── lib │ ├── assets │ │ └── .gitkeep │ ├── sample_gem2.modified.rb │ ├── sample_gem2.original.rb │ ├── sample_gem2.rb │ ├── sample_gem2 │ │ ├── base.modified.rb │ │ ├── base.original.rb │ │ └── base.rb │ └── tasks │ │ ├── .gitkeep │ │ └── test.rake ├── log │ └── .gitkeep ├── public │ ├── 404.html │ ├── 422.html │ ├── 500.html │ ├── favicon.ico │ ├── index.html │ └── robots.txt ├── script │ └── rails ├── test │ ├── fixtures │ │ └── .gitkeep │ ├── functional │ │ └── .gitkeep │ ├── integration │ │ ├── .gitkeep │ │ └── reload_require_files_test.rb │ ├── performance │ │ └── browsing_test.rb │ ├── test_helper.rb │ └── unit │ │ └── .gitkeep └── vendor │ ├── assets │ └── stylesheets │ │ └── .gitkeep │ └── plugins │ └── .gitkeep └── rails32-app ├── .gitignore ├── Gemfile ├── README.rdoc ├── Rakefile ├── app ├── assets │ ├── images │ │ └── rails.png │ ├── javascripts │ │ └── application.js │ └── stylesheets │ │ └── application.css ├── controllers │ ├── application_controller.rb │ └── test_controller.rb ├── helpers │ └── application_helper.rb ├── mailers │ └── .gitkeep ├── models │ └── .gitkeep └── views │ └── layouts │ └── application.html.erb ├── config.ru ├── config ├── application.rb ├── boot.rb ├── database.yml ├── environment.rb ├── environments │ ├── development.rb │ ├── production.rb │ └── test.rb ├── initializers │ ├── backtrace_silencers.rb │ ├── inflections.rb │ ├── mime_types.rb │ ├── secret_token.rb │ ├── session_store.rb │ └── wrap_parameters.rb ├── locales │ └── en.yml └── routes.rb ├── db ├── schema.rb └── seeds.rb ├── gems └── sample_gem1 │ ├── .gitignore │ ├── Gemfile │ ├── LICENSE.txt │ ├── README.md │ ├── Rakefile │ ├── lib │ ├── sample_gem1.modified.rb │ ├── sample_gem1.original.rb │ ├── sample_gem1.rb │ └── sample_gem1 │ │ ├── base.modified.rb │ │ ├── base.original.rb │ │ ├── base.rb │ │ └── version.rb │ └── sample_gem1.gemspec ├── lib ├── assets │ └── .gitkeep ├── sample_gem2.modified.rb ├── sample_gem2.original.rb ├── sample_gem2.rb ├── sample_gem2 │ ├── base.modified.rb │ ├── base.original.rb │ └── base.rb └── tasks │ ├── .gitkeep │ └── test.rake ├── log └── .gitkeep ├── public ├── 404.html ├── 422.html ├── 500.html ├── favicon.ico ├── index.html └── robots.txt ├── script └── rails ├── test ├── fixtures │ └── .gitkeep ├── functional │ └── .gitkeep ├── integration │ ├── .gitkeep │ └── reload_require_files_test.rb ├── performance │ └── browsing_test.rb ├── test_helper.rb └── unit │ └── .gitkeep └── vendor ├── assets ├── javascripts │ └── .gitkeep └── stylesheets │ └── .gitkeep ├── gems └── sample_gem3 │ ├── .gitignore │ ├── Gemfile │ ├── LICENSE.txt │ ├── README.md │ ├── Rakefile │ ├── lib │ ├── sample_gem3.modified.rb │ ├── sample_gem3.original.rb │ ├── sample_gem3.rb │ └── sample_gem3 │ │ ├── base.modified.rb │ │ ├── base.original.rb │ │ ├── base.rb │ │ └── version.rb │ └── sample_gem3.gemspec └── plugins └── .gitkeep /.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | *.rbc 3 | .bundle 4 | .config 5 | .yardoc 6 | Gemfile.lock 7 | InstalledFiles 8 | _yardoc 9 | coverage 10 | doc/ 11 | lib/bundler/man 12 | pkg 13 | rdoc 14 | spec/reports 15 | test/tmp 16 | test/version_tmp 17 | tmp 18 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | # Specify your gem's dependencies in gem_reloader.gemspec 4 | gemspec 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 Huiming Teo 2 | Copyright (c) 2012 Colin Young 3 | 4 | MIT License 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # RequireReloader 2 | 3 | [![Gem Version](https://badge.fury.io/rb/require_reloader.png)](http://badge.fury.io/rb/require_reloader) 4 | 5 | Auto-reload `require` files or local gems without restarting server 6 | during Rails development. 7 | 8 | Currently, it supports Rails 3+ and above, including 3.1 and 3.2. 9 | 10 | It uses `ActionDispatch::Callbacks.to_prepare` to reload the 11 | `require` files before each request. In Rails 3.2, it uses 12 | `watchable_dirs` to reload only when you modify a file. More details in [this blog post](http://teohm.github.com/blog/2013/01/10/reload-required-files-in-rails/). 13 | 14 | ## Usage 15 | 16 | Given a `Gemfile` 17 | 18 | # Gemfile 19 | gem 'my_gem', :path => '~/work/my_gem' 20 | gem 'my_gem2', :path => '~/fun/my_gem2', :module_name => 'MYGEM2' 21 | 22 | To reload all **local gems** (the ones with `:path` attribute, 23 | or using [local git repo](http://gembundler.com/v1.2/git.html#local)): 24 | 25 | # config/environments/development.rb 26 | YourApp::Application.configure do 27 | ... 28 | RequireReloader.watch_local_gems! 29 | end 30 | 31 | To reload a specific local gem: 32 | 33 | RequireReloader.watch :my_gem 34 | 35 | You can also **reload a `.rb` file in `lib`** or any directory: 36 | 37 | RequireReloader.watch :half_baked_gem # in lib dir 38 | RequireReloader.watch :foo, :path => 'app/models' 39 | 40 | The `:path` option is *optional*. In **Rails 3.2**, `:path` value is added into `watchable_dirs`. Rails 3.1 and 3.0 ignore this value. 41 | 42 | The `:module_name` option is *optional*. By default, it is assumed that the top-level module is a CamelCase version of the gem name. 43 | If this is not the case, you can pass this option, a String. This value will also be picked up if included in the metadata of the gemspec, 44 | as in `spec.metadata = {'module_name' => 'MYMOD'}`. 45 | 46 | RequireReloader adds `lib` into `watchable_dirs`. So, specify `:path` 47 | only if it is not specified in `Gemfile` and the file is located in other directory. 48 | 49 | RequireReloader.watch :foo, :callback => lambda { |gem| puts "#{gem} got reloaded" } 50 | 51 | You can supply a Proc with the *optional* `:callback` option. This proc gets called everytime after your gem got reloaded. 52 | 53 | ## Installation 54 | 55 | Add this line to your application's Gemfile: 56 | 57 | gem 'require_reloader' 58 | 59 | And then execute: 60 | 61 | $ bundle 62 | 63 | 64 | ## Contributing 65 | 66 | 1. Fork it 67 | 2. Create your feature branch (`git checkout -b my-new-feature`) 68 | 3. Commit your changes (`git commit -am 'Added some feature'`) 69 | 4. Push to the branch (`git push origin my-new-feature`) 70 | 5. Create new Pull Request 71 | 72 | ## Credits 73 | 74 | This gem is forked from Colin Young's [gem_reloader](https://github.com/colinyoung/gem_reloader), based on [a solution by Timothy Cardenas](http://timcardenas.com/automatically-reload-gems-in-rails-327-on-eve), inspired by [a post from Leitch](http://ileitch.github.com/2012/03/24/rails-32-code-reloading-from-lib.html). 75 | 76 | ### Contributors 77 | - @sven-winkler: trigger callback after gem reloaded (issue #2) 78 | - @aceofspades: support gem metadata :module_name in Gemfile (issue #4) 79 | 80 | ## Changelog 81 | - v0.2.1: Add Rails 5.1 support ([pull request](https://github.com/teohm/require_reloader/pull/7) from @kibenimatik) 82 | - v0.2.0: Support module_name option/spec-metadata 83 | - v0.1.6: RequireReloader::watch accepts :callback, runs it after gem reloaded ([pull request](https://github.com/teohm/require_reloader/pull/2) from @sven-winkler). 84 | - v0.1.5: properly guess top-level module name based on gem name 85 | pattern, only watch git repo if it's local. 86 | - v0.1.4: remove 'vendor/gems' from watchable_dirs & autoload_paths, as local gem path is already specified in Gemfile. 87 | - v0.1.3: Skip reload local gem if it's itself; added integration tests. 88 | - v0.1.2: Minor rephrase on gem's description and summary. 89 | - v0.1.1: Use Bundler to fetch local gems info, instead of parsing Gemfile by hand. 90 | - v0.1.0: Forked colinyoung/gem_reloader, renamed & major rewrite to support Rails 3.2 and new features. 91 | - v0.0.2: Added "vendor/gems" to the config.autoload_paths so the user doesn't have to. 92 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env rake 2 | require "bundler/gem_tasks" 3 | 4 | desc "run all integration tests" 5 | task :test do 6 | system "cd test/resources/rails32-app; bundle exec rake test:integration; cd -" 7 | system "cd test/resources/rails31-app; bundle exec rake test:integration; cd -" 8 | system "cd test/resources/rails30-app; bundle exec rake test:integration; cd -" 9 | end 10 | -------------------------------------------------------------------------------- /lib/require_reloader.rb: -------------------------------------------------------------------------------- 1 | require "require_reloader/version" 2 | require "require_reloader/railtie" 3 | require "require_reloader/helper" 4 | 5 | module RequireReloader 6 | class << self 7 | 8 | # Reload all local gems (that is, ones which have a :path attribute) 9 | # automatically on each request. 10 | # 11 | # To use it, add 'RequireReloader.watch_local_gems!' to 12 | # your config/environments/development.rb. 13 | # 14 | def watch_local_gems! 15 | local_gems.each do |gem| 16 | # never reload itself for now, causing error raised in integration test 17 | next if gem.name == 'require_reloader' 18 | 19 | watch gem.name, :path => gem.source.path.to_s, :module_name => gem.metadata['module_name'] 20 | end 21 | end 22 | 23 | # Propose to deprecate :watch_all! and reserve it for future usage. 24 | alias_method :watch_all!, :watch_local_gems! 25 | 26 | # Reload a specific gem or a gem-like .rb file 27 | # automatically on each request. 28 | # 29 | # In Rails 3.2+, reload happens only when a watchable file is modified. 30 | # 31 | # To use it, add 'RequireReloader.watch :my_gem' to 32 | # your config/environments/development.rb. 33 | # 34 | def watch(gem_name, opts={}) 35 | gem = gem_name.to_s 36 | watchable_dir = expanded_gem_path(gem, opts[:path]) 37 | watchable_exts = opts[:exts] ? Array(opts[:exts]) : [:rb] 38 | helper = Helper.new 39 | 40 | app = Object.const_get(Rails.application.class.parent_name) 41 | app::Application.configure do 42 | 43 | if watchable_dir && config.respond_to?(:watchable_dirs) 44 | config.watchable_dirs[watchable_dir] = watchable_exts 45 | end 46 | 47 | # based on Tim Cardenas's solution: 48 | # http://timcardenas.com/automatically-reload-gems-in-rails-327-on-eve 49 | helper.to_prepare do 50 | if opts[:module_name] 51 | helper.remove_module_if_defined(opts[:module_name]) 52 | else 53 | helper.remove_gem_module_if_defined(gem) 54 | end 55 | $".delete_if {|s| s.include?(gem)} 56 | require gem 57 | opts[:callback].call(gem) if opts[:callback] 58 | end 59 | end 60 | end 61 | 62 | private 63 | 64 | def expanded_gem_path(gem, preferred_path) 65 | return File.expand_path(preferred_path) if preferred_path 66 | local_gem = local_gems.find {|g| g.name == gem} 67 | local_gem ? File.expand_path(local_gem.source.path.to_s) : false 68 | end 69 | 70 | # returns only local gems, local git repo 71 | def local_gems 72 | Bundler.definition.specs. 73 | select{|s| s.source.is_a?(Bundler::Source::Path) }. 74 | delete_if{|s| s.source.is_a?(Bundler::Source::Git) && !s.source.send(:local?) } 75 | end 76 | end 77 | end 78 | -------------------------------------------------------------------------------- /lib/require_reloader/helper.rb: -------------------------------------------------------------------------------- 1 | module RequireReloader 2 | # Methods copied from latest ActiveSupport::Inflector to support 3 | # older Rails versions (e.g. 3.0) without these methods. 4 | module ActionPackInfectorMethods 5 | def deconstantize(path) 6 | path.to_s[0...(path.rindex('::') || 0)] # implementation based on the one in facets' Module#spacename 7 | end 8 | 9 | def constantize(camel_cased_word) 10 | names = camel_cased_word.split('::') 11 | names.shift if names.empty? || names.first.empty? 12 | 13 | constant = Object 14 | names.each do |name| 15 | constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name) 16 | end 17 | constant 18 | end 19 | 20 | def const_regexp(camel_cased_word) #:nodoc: 21 | parts = camel_cased_word.split("::") 22 | last = parts.pop 23 | 24 | parts.reverse.inject(last) do |acc, part| 25 | part.empty? ? acc : "#{part}(::#{acc})?" 26 | end 27 | end 28 | 29 | def demodulize(path) 30 | path = path.to_s 31 | if i = path.rindex('::') 32 | path[(i+2)..-1] 33 | else 34 | path 35 | end 36 | end 37 | 38 | def safe_constantize(camel_cased_word) 39 | begin 40 | constantize(camel_cased_word) 41 | rescue NameError => e 42 | raise unless e.message =~ /(uninitialized constant|wrong constant name) #{const_regexp(camel_cased_word)}$/ || 43 | e.name.to_s == camel_cased_word.to_s 44 | rescue ArgumentError => e 45 | raise unless e.message =~ /not missing constant #{const_regexp(camel_cased_word)}\!$/ 46 | end 47 | end 48 | end 49 | 50 | class Helper 51 | include ActionPackInfectorMethods 52 | 53 | def remove_gem_module_if_defined(gem_name) 54 | mod_name = full_qualified_name(gem_name) 55 | remove_module_if_defined(mod_name) 56 | end 57 | 58 | def remove_module_if_defined(mod_name) 59 | remove_module(mod_name) if module_defined?(mod_name) 60 | end 61 | 62 | def module_defined?(full_name) 63 | !!safe_constantize(full_name) 64 | end 65 | 66 | def remove_module(full_name) 67 | module_namespace = deconstantize(full_name) 68 | module_name = demodulize(full_name) 69 | parent_module = module_namespace == "" ? Object : constantize(module_namespace) 70 | parent_module.send(:remove_const, module_name) 71 | end 72 | 73 | def full_qualified_name(gem_name) 74 | return nil unless gem_name 75 | gem_name.split("-").map{|token| camelcase(token)}.join("::") 76 | end 77 | 78 | def camelcase(str) 79 | str.split("_").map{|token| token.capitalize }.join("") 80 | end 81 | 82 | def to_prepare(&block) 83 | if Rails::VERSION::MAJOR == 5 84 | ActiveSupport::Reloader.to_prepare(&block) 85 | else 86 | ActionDispatch::Callbacks.to_prepare(&block) 87 | end 88 | end 89 | end 90 | 91 | end 92 | -------------------------------------------------------------------------------- /lib/require_reloader/railtie.rb: -------------------------------------------------------------------------------- 1 | class RequireReloaderRailtie < Rails::Railtie 2 | 3 | initializer 'require_reloader.add_watchable_dirs', :before => :set_autoload_paths do |app| 4 | if app.config.respond_to?(:watchable_dirs) 5 | app.config.watchable_dirs['lib'] = [:rb] 6 | end 7 | end 8 | 9 | end 10 | -------------------------------------------------------------------------------- /lib/require_reloader/version.rb: -------------------------------------------------------------------------------- 1 | module RequireReloader 2 | VERSION = "0.2.1" 3 | end 4 | -------------------------------------------------------------------------------- /require_reloader.gemspec: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | require File.expand_path('../lib/require_reloader/version', __FILE__) 3 | 4 | Gem::Specification.new do |gem| 5 | gem.authors = ["Colin Young", "Huiming Teo"] 6 | gem.email = ["me@colinyoung.com", "teohuiming@gmail.com"] 7 | gem.description = %q{Auto-reload require files or local gems without restarting server during Rails development.} 8 | gem.summary = %q{Auto-reload require files or local gems without restarting Rails server.} 9 | gem.homepage = "https://github.com/teohm/require_reloader" 10 | 11 | gem.files = `git ls-files`.split($\).reject{|f| f =~ /^test/} 12 | gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) } 13 | gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) 14 | gem.name = "require_reloader" 15 | gem.require_paths = ["lib"] 16 | gem.version = RequireReloader::VERSION 17 | 18 | gem.add_development_dependency "minitest" 19 | end 20 | -------------------------------------------------------------------------------- /test/require_reloader/helper_test.rb: -------------------------------------------------------------------------------- 1 | require 'minitest/autorun' 2 | require 'require_reloader/helper' 3 | 4 | describe RequireReloader::Helper do 5 | 6 | it "converts gem name to class name based on RubyGem Consistent Naming" do 7 | c = RequireReloader::Helper.new 8 | c.full_qualified_name( 9 | "foo_bar_baz-bibi_baba-roo").must_equal "FooBarBaz::BibiBaba::Roo" 10 | end 11 | 12 | it "handles different permutations of gem name pattern" do 13 | SAMPLES = { 14 | nil => nil, 15 | "" => "", 16 | "haml-rails" => "Haml::Rails", 17 | "module1" => "Module1", 18 | "foo_bar" => "FooBar", 19 | "foo_bar_baz-bibi_baba-roo" => "FooBarBaz::BibiBaba::Roo" 20 | } 21 | c = RequireReloader::Helper.new 22 | 23 | SAMPLES.each do |gem_name, class_name| 24 | c.full_qualified_name(gem_name).must_equal( 25 | class_name, "gem_name: #{gem_name.inspect}") 26 | end 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /test/resources/Gemfile: -------------------------------------------------------------------------------- 1 | # A sample Gemfile 2 | source "https://rubygems.org" 3 | 4 | #gem "rails", "3.2" 5 | #gem "rails", "3.1" 6 | gem "rails", "3.0.9" 7 | -------------------------------------------------------------------------------- /test/resources/rails30-app/.gitignore: -------------------------------------------------------------------------------- 1 | .bundle 2 | db/*.sqlite3 3 | log/*.log 4 | tmp/ 5 | -------------------------------------------------------------------------------- /test/resources/rails30-app/Gemfile: -------------------------------------------------------------------------------- 1 | source 'http://rubygems.org' 2 | 3 | gem 'rails', '3.0.9' 4 | 5 | # Bundle edge Rails instead: 6 | # gem 'rails', :git => 'git://github.com/rails/rails.git' 7 | 8 | gem 'sqlite3' 9 | 10 | gem 'sample_gem1', :path => 'gems/sample_gem1' 11 | gem 'require_reloader', :path => '../../..' 12 | 13 | # Use unicorn as the web server 14 | # gem 'unicorn' 15 | 16 | # Deploy with Capistrano 17 | # gem 'capistrano' 18 | 19 | # To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+) 20 | # gem 'ruby-debug' 21 | # gem 'ruby-debug19', :require => 'ruby-debug' 22 | 23 | # Bundle the extra gems: 24 | # gem 'bj' 25 | # gem 'nokogiri' 26 | # gem 'sqlite3-ruby', :require => 'sqlite3' 27 | # gem 'aws-s3', :require => 'aws/s3' 28 | 29 | # Bundle gems for the local environment. Make sure to 30 | # put test-only gems in this group so their generators 31 | # and rake tasks are available in development mode: 32 | # group :development, :test do 33 | # gem 'webrat' 34 | # end 35 | -------------------------------------------------------------------------------- /test/resources/rails30-app/README: -------------------------------------------------------------------------------- 1 | == Welcome to Rails 2 | 3 | Rails is a web-application framework that includes everything needed to create 4 | database-backed web applications according to the Model-View-Control pattern. 5 | 6 | This pattern splits the view (also called the presentation) into "dumb" 7 | templates that are primarily responsible for inserting pre-built data in between 8 | HTML tags. The model contains the "smart" domain objects (such as Account, 9 | Product, Person, Post) that holds all the business logic and knows how to 10 | persist themselves to a database. The controller handles the incoming requests 11 | (such as Save New Account, Update Product, Show Post) by manipulating the model 12 | and directing data to the view. 13 | 14 | In Rails, the model is handled by what's called an object-relational mapping 15 | layer entitled Active Record. This layer allows you to present the data from 16 | database rows as objects and embellish these data objects with business logic 17 | methods. You can read more about Active Record in 18 | link:files/vendor/rails/activerecord/README.html. 19 | 20 | The controller and view are handled by the Action Pack, which handles both 21 | layers by its two parts: Action View and Action Controller. These two layers 22 | are bundled in a single package due to their heavy interdependence. This is 23 | unlike the relationship between the Active Record and Action Pack that is much 24 | more separate. Each of these packages can be used independently outside of 25 | Rails. You can read more about Action Pack in 26 | link:files/vendor/rails/actionpack/README.html. 27 | 28 | 29 | == Getting Started 30 | 31 | 1. At the command prompt, create a new Rails application: 32 | rails new myapp (where myapp is the application name) 33 | 34 | 2. Change directory to myapp and start the web server: 35 | cd myapp; rails server (run with --help for options) 36 | 37 | 3. Go to http://localhost:3000/ and you'll see: 38 | "Welcome aboard: You're riding Ruby on Rails!" 39 | 40 | 4. Follow the guidelines to start developing your application. You can find 41 | the following resources handy: 42 | 43 | * The Getting Started Guide: http://guides.rubyonrails.org/getting_started.html 44 | * Ruby on Rails Tutorial Book: http://www.railstutorial.org/ 45 | 46 | 47 | == Debugging Rails 48 | 49 | Sometimes your application goes wrong. Fortunately there are a lot of tools that 50 | will help you debug it and get it back on the rails. 51 | 52 | First area to check is the application log files. Have "tail -f" commands 53 | running on the server.log and development.log. Rails will automatically display 54 | debugging and runtime information to these files. Debugging info will also be 55 | shown in the browser on requests from 127.0.0.1. 56 | 57 | You can also log your own messages directly into the log file from your code 58 | using the Ruby logger class from inside your controllers. Example: 59 | 60 | class WeblogController < ActionController::Base 61 | def destroy 62 | @weblog = Weblog.find(params[:id]) 63 | @weblog.destroy 64 | logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!") 65 | end 66 | end 67 | 68 | The result will be a message in your log file along the lines of: 69 | 70 | Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1! 71 | 72 | More information on how to use the logger is at http://www.ruby-doc.org/core/ 73 | 74 | Also, Ruby documentation can be found at http://www.ruby-lang.org/. There are 75 | several books available online as well: 76 | 77 | * Programming Ruby: http://www.ruby-doc.org/docs/ProgrammingRuby/ (Pickaxe) 78 | * Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide) 79 | 80 | These two books will bring you up to speed on the Ruby language and also on 81 | programming in general. 82 | 83 | 84 | == Debugger 85 | 86 | Debugger support is available through the debugger command when you start your 87 | Mongrel or WEBrick server with --debugger. This means that you can break out of 88 | execution at any point in the code, investigate and change the model, and then, 89 | resume execution! You need to install ruby-debug to run the server in debugging 90 | mode. With gems, use sudo gem install ruby-debug. Example: 91 | 92 | class WeblogController < ActionController::Base 93 | def index 94 | @posts = Post.find(:all) 95 | debugger 96 | end 97 | end 98 | 99 | So the controller will accept the action, run the first line, then present you 100 | with a IRB prompt in the server window. Here you can do things like: 101 | 102 | >> @posts.inspect 103 | => "[#nil, "body"=>nil, "id"=>"1"}>, 105 | #"Rails", "body"=>"Only ten..", "id"=>"2"}>]" 107 | >> @posts.first.title = "hello from a debugger" 108 | => "hello from a debugger" 109 | 110 | ...and even better, you can examine how your runtime objects actually work: 111 | 112 | >> f = @posts.first 113 | => #nil, "body"=>nil, "id"=>"1"}> 114 | >> f. 115 | Display all 152 possibilities? (y or n) 116 | 117 | Finally, when you're ready to resume execution, you can enter "cont". 118 | 119 | 120 | == Console 121 | 122 | The console is a Ruby shell, which allows you to interact with your 123 | application's domain model. Here you'll have all parts of the application 124 | configured, just like it is when the application is running. You can inspect 125 | domain models, change values, and save to the database. Starting the script 126 | without arguments will launch it in the development environment. 127 | 128 | To start the console, run rails console from the application 129 | directory. 130 | 131 | Options: 132 | 133 | * Passing the -s, --sandbox argument will rollback any modifications 134 | made to the database. 135 | * Passing an environment name as an argument will load the corresponding 136 | environment. Example: rails console production. 137 | 138 | To reload your controllers and models after launching the console run 139 | reload! 140 | 141 | More information about irb can be found at: 142 | link:http://www.rubycentral.com/pickaxe/irb.html 143 | 144 | 145 | == dbconsole 146 | 147 | You can go to the command line of your database directly through rails 148 | dbconsole. You would be connected to the database with the credentials 149 | defined in database.yml. Starting the script without arguments will connect you 150 | to the development database. Passing an argument will connect you to a different 151 | database, like rails dbconsole production. Currently works for MySQL, 152 | PostgreSQL and SQLite 3. 153 | 154 | == Description of Contents 155 | 156 | The default directory structure of a generated Ruby on Rails application: 157 | 158 | |-- app 159 | | |-- controllers 160 | | |-- helpers 161 | | |-- mailers 162 | | |-- models 163 | | `-- views 164 | | `-- layouts 165 | |-- config 166 | | |-- environments 167 | | |-- initializers 168 | | `-- locales 169 | |-- db 170 | |-- doc 171 | |-- lib 172 | | `-- tasks 173 | |-- log 174 | |-- public 175 | | |-- images 176 | | |-- javascripts 177 | | `-- stylesheets 178 | |-- script 179 | |-- test 180 | | |-- fixtures 181 | | |-- functional 182 | | |-- integration 183 | | |-- performance 184 | | `-- unit 185 | |-- tmp 186 | | |-- cache 187 | | |-- pids 188 | | |-- sessions 189 | | `-- sockets 190 | `-- vendor 191 | `-- plugins 192 | 193 | app 194 | Holds all the code that's specific to this particular application. 195 | 196 | app/controllers 197 | Holds controllers that should be named like weblogs_controller.rb for 198 | automated URL mapping. All controllers should descend from 199 | ApplicationController which itself descends from ActionController::Base. 200 | 201 | app/models 202 | Holds models that should be named like post.rb. Models descend from 203 | ActiveRecord::Base by default. 204 | 205 | app/views 206 | Holds the template files for the view that should be named like 207 | weblogs/index.html.erb for the WeblogsController#index action. All views use 208 | eRuby syntax by default. 209 | 210 | app/views/layouts 211 | Holds the template files for layouts to be used with views. This models the 212 | common header/footer method of wrapping views. In your views, define a layout 213 | using the layout :default and create a file named default.html.erb. 214 | Inside default.html.erb, call <% yield %> to render the view using this 215 | layout. 216 | 217 | app/helpers 218 | Holds view helpers that should be named like weblogs_helper.rb. These are 219 | generated for you automatically when using generators for controllers. 220 | Helpers can be used to wrap functionality for your views into methods. 221 | 222 | config 223 | Configuration files for the Rails environment, the routing map, the database, 224 | and other dependencies. 225 | 226 | db 227 | Contains the database schema in schema.rb. db/migrate contains all the 228 | sequence of Migrations for your schema. 229 | 230 | doc 231 | This directory is where your application documentation will be stored when 232 | generated using rake doc:app 233 | 234 | lib 235 | Application specific libraries. Basically, any kind of custom code that 236 | doesn't belong under controllers, models, or helpers. This directory is in 237 | the load path. 238 | 239 | public 240 | The directory available for the web server. Contains subdirectories for 241 | images, stylesheets, and javascripts. Also contains the dispatchers and the 242 | default HTML files. This should be set as the DOCUMENT_ROOT of your web 243 | server. 244 | 245 | script 246 | Helper scripts for automation and generation. 247 | 248 | test 249 | Unit and functional tests along with fixtures. When using the rails generate 250 | command, template test files will be generated for you and placed in this 251 | directory. 252 | 253 | vendor 254 | External libraries that the application depends on. Also includes the plugins 255 | subdirectory. If the app has frozen rails, those gems also go here, under 256 | vendor/rails/. This directory is in the load path. 257 | -------------------------------------------------------------------------------- /test/resources/rails30-app/Rakefile: -------------------------------------------------------------------------------- 1 | # Add your own tasks in files placed in lib/tasks ending in .rake, 2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 3 | 4 | require File.expand_path('../config/application', __FILE__) 5 | require 'rake' 6 | 7 | Rails30App::Application.load_tasks 8 | -------------------------------------------------------------------------------- /test/resources/rails30-app/app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::Base 2 | protect_from_forgery 3 | end 4 | -------------------------------------------------------------------------------- /test/resources/rails30-app/app/controllers/test_controller.rb: -------------------------------------------------------------------------------- 1 | require 'sample_gem1' 2 | require 'sample_gem2' 3 | 4 | class TestController < ApplicationController 5 | def show 6 | messages = [ 7 | SampleGem1.test_message, 8 | SampleGem2.test_message 9 | ] 10 | 11 | render :text => messages.join("\n") 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /test/resources/rails30-app/app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | end 3 | -------------------------------------------------------------------------------- /test/resources/rails30-app/app/views/layouts/application.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Rails30App 5 | <%= stylesheet_link_tag :all %> 6 | <%= javascript_include_tag :defaults %> 7 | <%= csrf_meta_tag %> 8 | 9 | 10 | 11 | <%= yield %> 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /test/resources/rails30-app/config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require ::File.expand_path('../config/environment', __FILE__) 4 | run Rails30App::Application 5 | -------------------------------------------------------------------------------- /test/resources/rails30-app/config/application.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../boot', __FILE__) 2 | 3 | require 'rails/all' 4 | 5 | # If you have a Gemfile, require the gems listed there, including any gems 6 | # you've limited to :test, :development, or :production. 7 | Bundler.require(:default, Rails.env) if defined?(Bundler) 8 | 9 | module Rails30App 10 | class Application < Rails::Application 11 | # Settings in config/environments/* take precedence over those specified here. 12 | # Application configuration should go into files in config/initializers 13 | # -- all .rb files in that directory are automatically loaded. 14 | 15 | # Custom directories with classes and modules you want to be autoloadable. 16 | # config.autoload_paths += %W(#{config.root}/extras) 17 | 18 | # Only load the plugins named here, in the order given (default is alphabetical). 19 | # :all can be used as a placeholder for all plugins not explicitly named. 20 | # config.plugins = [ :exception_notification, :ssl_requirement, :all ] 21 | 22 | # Activate observers that should always be running. 23 | # config.active_record.observers = :cacher, :garbage_collector, :forum_observer 24 | 25 | # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. 26 | # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. 27 | # config.time_zone = 'Central Time (US & Canada)' 28 | 29 | # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. 30 | # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] 31 | # config.i18n.default_locale = :de 32 | 33 | # JavaScript files you want as :defaults (application.js is always included). 34 | # config.action_view.javascript_expansions[:defaults] = %w(jquery rails) 35 | 36 | # Configure the default encoding used in templates for Ruby 1.9. 37 | config.encoding = "utf-8" 38 | 39 | # Configure sensitive parameters which will be filtered from the log file. 40 | config.filter_parameters += [:password] 41 | end 42 | end 43 | -------------------------------------------------------------------------------- /test/resources/rails30-app/config/boot.rb: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | 3 | # Set up gems listed in the Gemfile. 4 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 5 | 6 | require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE']) 7 | -------------------------------------------------------------------------------- /test/resources/rails30-app/config/database.yml: -------------------------------------------------------------------------------- 1 | # SQLite version 3.x 2 | # gem install sqlite3 3 | development: 4 | adapter: sqlite3 5 | database: db/development.sqlite3 6 | pool: 5 7 | timeout: 5000 8 | 9 | # Warning: The database defined as "test" will be erased and 10 | # re-generated from your development database when you run "rake". 11 | # Do not set this db to the same as development or production. 12 | test: 13 | adapter: sqlite3 14 | database: db/test.sqlite3 15 | pool: 5 16 | timeout: 5000 17 | 18 | production: 19 | adapter: sqlite3 20 | database: db/production.sqlite3 21 | pool: 5 22 | timeout: 5000 23 | -------------------------------------------------------------------------------- /test/resources/rails30-app/config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the rails application 2 | require File.expand_path('../application', __FILE__) 3 | 4 | # Initialize the rails application 5 | Rails30App::Application.initialize! 6 | -------------------------------------------------------------------------------- /test/resources/rails30-app/config/environments/development.rb: -------------------------------------------------------------------------------- 1 | Rails30App::Application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb 3 | 4 | # In the development environment your application's code is reloaded on 5 | # every request. This slows down response time but is perfect for development 6 | # since you don't have to restart the webserver when you make code changes. 7 | config.cache_classes = false 8 | 9 | # Log error messages when you accidentally call methods on nil. 10 | config.whiny_nils = true 11 | 12 | # Show full error reports and disable caching 13 | config.consider_all_requests_local = true 14 | config.action_view.debug_rjs = true 15 | config.action_controller.perform_caching = false 16 | 17 | # Don't care if the mailer can't send 18 | config.action_mailer.raise_delivery_errors = false 19 | 20 | # Print deprecation notices to the Rails logger 21 | config.active_support.deprecation = :log 22 | 23 | # Only use best-standards-support built into browsers 24 | config.action_dispatch.best_standards_support = :builtin 25 | 26 | RequireReloader.watch_local_gems! 27 | RequireReloader.watch :sample_gem2 28 | 29 | end 30 | 31 | -------------------------------------------------------------------------------- /test/resources/rails30-app/config/environments/production.rb: -------------------------------------------------------------------------------- 1 | Rails30App::Application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb 3 | 4 | # The production environment is meant for finished, "live" apps. 5 | # Code is not reloaded between requests 6 | config.cache_classes = true 7 | 8 | # Full error reports are disabled and caching is turned on 9 | config.consider_all_requests_local = false 10 | config.action_controller.perform_caching = true 11 | 12 | # Specifies the header that your server uses for sending files 13 | config.action_dispatch.x_sendfile_header = "X-Sendfile" 14 | 15 | # For nginx: 16 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' 17 | 18 | # If you have no front-end server that supports something like X-Sendfile, 19 | # just comment this out and Rails will serve the files 20 | 21 | # See everything in the log (default is :info) 22 | # config.log_level = :debug 23 | 24 | # Use a different logger for distributed setups 25 | # config.logger = SyslogLogger.new 26 | 27 | # Use a different cache store in production 28 | # config.cache_store = :mem_cache_store 29 | 30 | # Disable Rails's static asset server 31 | # In production, Apache or nginx will already do this 32 | config.serve_static_assets = false 33 | 34 | # Enable serving of images, stylesheets, and javascripts from an asset server 35 | # config.action_controller.asset_host = "http://assets.example.com" 36 | 37 | # Disable delivery errors, bad email addresses will be ignored 38 | # config.action_mailer.raise_delivery_errors = false 39 | 40 | # Enable threaded mode 41 | # config.threadsafe! 42 | 43 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to 44 | # the I18n.default_locale when a translation can not be found) 45 | config.i18n.fallbacks = true 46 | 47 | # Send deprecation notices to registered listeners 48 | config.active_support.deprecation = :notify 49 | end 50 | -------------------------------------------------------------------------------- /test/resources/rails30-app/config/environments/test.rb: -------------------------------------------------------------------------------- 1 | Rails30App::Application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb 3 | 4 | # The test environment is used exclusively to run your application's 5 | # test suite. You never need to work with it otherwise. Remember that 6 | # your test database is "scratch space" for the test suite and is wiped 7 | # and recreated between test runs. Don't rely on the data there! 8 | config.cache_classes = true 9 | 10 | # Log error messages when you accidentally call methods on nil. 11 | config.whiny_nils = true 12 | 13 | # Show full error reports and disable caching 14 | config.consider_all_requests_local = true 15 | config.action_controller.perform_caching = false 16 | 17 | # Raise exceptions instead of rendering exception templates 18 | config.action_dispatch.show_exceptions = false 19 | 20 | # Disable request forgery protection in test environment 21 | config.action_controller.allow_forgery_protection = false 22 | 23 | # Tell Action Mailer not to deliver emails to the real world. 24 | # The :test delivery method accumulates sent emails in the 25 | # ActionMailer::Base.deliveries array. 26 | config.action_mailer.delivery_method = :test 27 | 28 | # Use SQL instead of Active Record's schema dumper when creating the test database. 29 | # This is necessary if your schema can't be completely dumped by the schema dumper, 30 | # like if you have constraints or database-specific column types 31 | # config.active_record.schema_format = :sql 32 | 33 | # Print deprecation notices to the stderr 34 | config.active_support.deprecation = :stderr 35 | end 36 | -------------------------------------------------------------------------------- /test/resources/rails30-app/config/initializers/backtrace_silencers.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. 4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } 5 | 6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. 7 | # Rails.backtrace_cleaner.remove_silencers! 8 | -------------------------------------------------------------------------------- /test/resources/rails30-app/config/initializers/inflections.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new inflection rules using the following format 4 | # (all these examples are active by default): 5 | # ActiveSupport::Inflector.inflections do |inflect| 6 | # inflect.plural /^(ox)$/i, '\1en' 7 | # inflect.singular /^(ox)en/i, '\1' 8 | # inflect.irregular 'person', 'people' 9 | # inflect.uncountable %w( fish sheep ) 10 | # end 11 | -------------------------------------------------------------------------------- /test/resources/rails30-app/config/initializers/mime_types.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new mime types for use in respond_to blocks: 4 | # Mime::Type.register "text/richtext", :rtf 5 | # Mime::Type.register_alias "text/html", :iphone 6 | -------------------------------------------------------------------------------- /test/resources/rails30-app/config/initializers/secret_token.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Your secret key for verifying the integrity of signed cookies. 4 | # If you change this key, all old signed cookies will become invalid! 5 | # Make sure the secret is at least 30 characters and all random, 6 | # no regular words or you'll be exposed to dictionary attacks. 7 | Rails30App::Application.config.secret_token = '4c45cb3bcc9c1059f340ed09e4848669baf8e33333731f7badc05e2e673680f07c51c98f254912fc9badc03006536af5aa9189e9e2522e1286d5a36a4a449ae7' 8 | -------------------------------------------------------------------------------- /test/resources/rails30-app/config/initializers/session_store.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails30App::Application.config.session_store :cookie_store, :key => '_rails30-app_session' 4 | 5 | # Use the database for sessions instead of the cookie-based default, 6 | # which shouldn't be used to store highly confidential information 7 | # (create the session table with "rails generate session_migration") 8 | # Rails30App::Application.config.session_store :active_record_store 9 | -------------------------------------------------------------------------------- /test/resources/rails30-app/config/locales/en.yml: -------------------------------------------------------------------------------- 1 | # Sample localization file for English. Add more files in this directory for other locales. 2 | # See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. 3 | 4 | en: 5 | hello: "Hello world" 6 | -------------------------------------------------------------------------------- /test/resources/rails30-app/config/routes.rb: -------------------------------------------------------------------------------- 1 | Rails30App::Application.routes.draw do 2 | match 'test' => 'test#show', :via => :get 3 | 4 | # The priority is based upon order of creation: 5 | # first created -> highest priority. 6 | 7 | # Sample of regular route: 8 | # match 'products/:id' => 'catalog#view' 9 | # Keep in mind you can assign values other than :controller and :action 10 | 11 | # Sample of named route: 12 | # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase 13 | # This route can be invoked with purchase_url(:id => product.id) 14 | 15 | # Sample resource route (maps HTTP verbs to controller actions automatically): 16 | # resources :products 17 | 18 | # Sample resource route with options: 19 | # resources :products do 20 | # member do 21 | # get 'short' 22 | # post 'toggle' 23 | # end 24 | # 25 | # collection do 26 | # get 'sold' 27 | # end 28 | # end 29 | 30 | # Sample resource route with sub-resources: 31 | # resources :products do 32 | # resources :comments, :sales 33 | # resource :seller 34 | # end 35 | 36 | # Sample resource route with more complex sub-resources 37 | # resources :products do 38 | # resources :comments 39 | # resources :sales do 40 | # get 'recent', :on => :collection 41 | # end 42 | # end 43 | 44 | # Sample resource route within a namespace: 45 | # namespace :admin do 46 | # # Directs /admin/products/* to Admin::ProductsController 47 | # # (app/controllers/admin/products_controller.rb) 48 | # resources :products 49 | # end 50 | 51 | # You can have the root of your site routed with "root" 52 | # just remember to delete public/index.html. 53 | # root :to => "welcome#index" 54 | 55 | # See how all your routes lay out with "rake routes" 56 | 57 | # This is a legacy wild controller route that's not recommended for RESTful applications. 58 | # Note: This route will make all actions in every controller accessible via GET requests. 59 | # match ':controller(/:action(/:id(.:format)))' 60 | end 61 | -------------------------------------------------------------------------------- /test/resources/rails30-app/db/schema.rb: -------------------------------------------------------------------------------- 1 | # This file is auto-generated from the current state of the database. Instead 2 | # of editing this file, please use the migrations feature of Active Record to 3 | # incrementally modify your database, and then regenerate this schema definition. 4 | # 5 | # Note that this schema.rb definition is the authoritative source for your 6 | # database schema. If you need to create the application database on another 7 | # system, you should be using db:schema:load, not running all the migrations 8 | # from scratch. The latter is a flawed and unsustainable approach (the more migrations 9 | # you'll amass, the slower it'll run and the greater likelihood for issues). 10 | # 11 | # It's strongly recommended to check this file into your version control system. 12 | 13 | ActiveRecord::Schema.define(:version => 0) do 14 | 15 | end 16 | -------------------------------------------------------------------------------- /test/resources/rails30-app/db/seeds.rb: -------------------------------------------------------------------------------- 1 | # This file should contain all the record creation needed to seed the database with its default values. 2 | # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). 3 | # 4 | # Examples: 5 | # 6 | # cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }]) 7 | # Mayor.create(:name => 'Daley', :city => cities.first) 8 | -------------------------------------------------------------------------------- /test/resources/rails30-app/gems/sample_gem1/.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | *.rbc 3 | .bundle 4 | .config 5 | .yardoc 6 | Gemfile.lock 7 | InstalledFiles 8 | _yardoc 9 | coverage 10 | doc/ 11 | lib/bundler/man 12 | pkg 13 | rdoc 14 | spec/reports 15 | test/tmp 16 | test/version_tmp 17 | tmp 18 | -------------------------------------------------------------------------------- /test/resources/rails30-app/gems/sample_gem1/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | # Specify your gem's dependencies in sample_gem1.gemspec 4 | gemspec 5 | -------------------------------------------------------------------------------- /test/resources/rails30-app/gems/sample_gem1/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 Huiming Teo 2 | 3 | MIT License 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /test/resources/rails30-app/gems/sample_gem1/README.md: -------------------------------------------------------------------------------- 1 | # SampleGem1 2 | 3 | TODO: Write a gem description 4 | 5 | ## Installation 6 | 7 | Add this line to your application's Gemfile: 8 | 9 | gem 'sample_gem1' 10 | 11 | And then execute: 12 | 13 | $ bundle 14 | 15 | Or install it yourself as: 16 | 17 | $ gem install sample_gem1 18 | 19 | ## Usage 20 | 21 | TODO: Write usage instructions here 22 | 23 | ## Contributing 24 | 25 | 1. Fork it 26 | 2. Create your feature branch (`git checkout -b my-new-feature`) 27 | 3. Commit your changes (`git commit -am 'Add some feature'`) 28 | 4. Push to the branch (`git push origin my-new-feature`) 29 | 5. Create new Pull Request 30 | -------------------------------------------------------------------------------- /test/resources/rails30-app/gems/sample_gem1/Rakefile: -------------------------------------------------------------------------------- 1 | require "bundler/gem_tasks" 2 | 3 | namespace :test do 4 | namespace :data do 5 | desc "Reset the codebase" 6 | task :reset do 7 | overwrite_codes_with!(:original) 8 | end 9 | 10 | desc "Modify the codebase" 11 | task :modify do 12 | overwrite_codes_with!(:modified) 13 | end 14 | 15 | def overwrite_codes_with!(type) 16 | require "fileutils" 17 | { 18 | "lib/sample_gem1.#{type}.rb" => "lib/sample_gem1.rb", 19 | "lib/sample_gem1/base.#{type}.rb" => "lib/sample_gem1/base.rb" 20 | }.each do |from, to| 21 | FileUtils.cp from, to 22 | end 23 | end 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /test/resources/rails30-app/gems/sample_gem1/lib/sample_gem1.modified.rb: -------------------------------------------------------------------------------- 1 | require "sample_gem1/version" 2 | require "sample_gem1/base" 3 | 4 | module SampleGem1 5 | def self.message 6 | "modified" 7 | end 8 | 9 | def self.test_message 10 | base = Base.new 11 | "local-gem: top-level:#{self.message}, sub-level:#{base.message}" 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /test/resources/rails30-app/gems/sample_gem1/lib/sample_gem1.original.rb: -------------------------------------------------------------------------------- 1 | require "sample_gem1/version" 2 | require "sample_gem1/base" 3 | 4 | module SampleGem1 5 | def self.message 6 | "original" 7 | end 8 | 9 | def self.test_message 10 | base = Base.new 11 | "local-gem: top-level:#{self.message}, sub-level:#{base.message}" 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /test/resources/rails30-app/gems/sample_gem1/lib/sample_gem1.rb: -------------------------------------------------------------------------------- 1 | require "sample_gem1/version" 2 | require "sample_gem1/base" 3 | 4 | module SampleGem1 5 | def self.message 6 | "original" 7 | end 8 | 9 | def self.test_message 10 | base = Base.new 11 | "local-gem: top-level:#{self.message}, sub-level:#{base.message}" 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /test/resources/rails30-app/gems/sample_gem1/lib/sample_gem1/base.modified.rb: -------------------------------------------------------------------------------- 1 | module SampleGem1 2 | class Base 3 | def message 4 | "modified" 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /test/resources/rails30-app/gems/sample_gem1/lib/sample_gem1/base.original.rb: -------------------------------------------------------------------------------- 1 | module SampleGem1 2 | class Base 3 | def message 4 | "original" 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /test/resources/rails30-app/gems/sample_gem1/lib/sample_gem1/base.rb: -------------------------------------------------------------------------------- 1 | module SampleGem1 2 | class Base 3 | def message 4 | "original" 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /test/resources/rails30-app/gems/sample_gem1/lib/sample_gem1/version.rb: -------------------------------------------------------------------------------- 1 | module SampleGem1 2 | VERSION = "0.0.1" 3 | end 4 | -------------------------------------------------------------------------------- /test/resources/rails30-app/gems/sample_gem1/sample_gem1.gemspec: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | lib = File.expand_path('../lib', __FILE__) 3 | $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) 4 | require 'sample_gem1/version' 5 | 6 | Gem::Specification.new do |gem| 7 | gem.name = "sample_gem1" 8 | gem.version = SampleGem1::VERSION 9 | gem.authors = ["Huiming Teo"] 10 | gem.email = ["teohuiming@gmail.com"] 11 | gem.description = %q{TODO: Write a gem description} 12 | gem.summary = %q{TODO: Write a gem summary} 13 | gem.homepage = "" 14 | 15 | gem.files = `git ls-files`.split($/) 16 | gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) } 17 | gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) 18 | gem.require_paths = ["lib"] 19 | end 20 | -------------------------------------------------------------------------------- /test/resources/rails30-app/lib/sample_gem2.modified.rb: -------------------------------------------------------------------------------- 1 | require "sample_gem2/base" 2 | 3 | module SampleGem2 4 | def self.message 5 | "modified" 6 | end 7 | 8 | def self.test_message 9 | base = Base.new 10 | "lib: top-level:#{self.message}, sub-level:#{base.message}" 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /test/resources/rails30-app/lib/sample_gem2.original.rb: -------------------------------------------------------------------------------- 1 | require "sample_gem2/base" 2 | 3 | module SampleGem2 4 | def self.message 5 | "original" 6 | end 7 | 8 | def self.test_message 9 | base = Base.new 10 | "lib: top-level:#{self.message}, sub-level:#{base.message}" 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /test/resources/rails30-app/lib/sample_gem2.rb: -------------------------------------------------------------------------------- 1 | require "sample_gem2/base" 2 | 3 | module SampleGem2 4 | def self.message 5 | "original" 6 | end 7 | 8 | def self.test_message 9 | base = Base.new 10 | "lib: top-level:#{self.message}, sub-level:#{base.message}" 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /test/resources/rails30-app/lib/sample_gem2/base.modified.rb: -------------------------------------------------------------------------------- 1 | module SampleGem2 2 | class Base 3 | def message 4 | "modified" 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /test/resources/rails30-app/lib/sample_gem2/base.original.rb: -------------------------------------------------------------------------------- 1 | module SampleGem2 2 | class Base 3 | def message 4 | "original" 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /test/resources/rails30-app/lib/sample_gem2/base.rb: -------------------------------------------------------------------------------- 1 | module SampleGem2 2 | class Base 3 | def message 4 | "original" 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /test/resources/rails30-app/lib/tasks/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teohm/require_reloader/94add3de6bac904aaad00eb364037d7263d4ab5d/test/resources/rails30-app/lib/tasks/.gitkeep -------------------------------------------------------------------------------- /test/resources/rails30-app/lib/tasks/test.rake: -------------------------------------------------------------------------------- 1 | namespace :test do 2 | namespace :data do 3 | desc "Reset the codebase" 4 | task :reset do 5 | overwrite_codes_with!(:original) 6 | end 7 | 8 | desc "Modify the codebase" 9 | task :modify do 10 | overwrite_codes_with!(:modified) 11 | end 12 | 13 | def overwrite_codes_with!(type) 14 | require "fileutils" 15 | { 16 | "gems/sample_gem1/lib/sample_gem1.#{type}.rb" => "gems/sample_gem1/lib/sample_gem1.rb", 17 | "gems/sample_gem1/lib/sample_gem1/base.#{type}.rb" => "gems/sample_gem1/lib/sample_gem1/base.rb" 18 | }.each do |from, to| 19 | FileUtils.cp from, to 20 | end 21 | end 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /test/resources/rails30-app/public/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The page you were looking for doesn't exist (404) 5 | 17 | 18 | 19 | 20 | 21 |
22 |

The page you were looking for doesn't exist.

23 |

You may have mistyped the address or the page may have moved.

24 |
25 | 26 | 27 | -------------------------------------------------------------------------------- /test/resources/rails30-app/public/422.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The change you wanted was rejected (422) 5 | 17 | 18 | 19 | 20 | 21 |
22 |

The change you wanted was rejected.

23 |

Maybe you tried to change something you didn't have access to.

24 |
25 | 26 | 27 | -------------------------------------------------------------------------------- /test/resources/rails30-app/public/500.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | We're sorry, but something went wrong (500) 5 | 17 | 18 | 19 | 20 | 21 |
22 |

We're sorry, but something went wrong.

23 |

We've been notified about this issue and we'll take a look at it shortly.

24 |
25 | 26 | 27 | -------------------------------------------------------------------------------- /test/resources/rails30-app/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teohm/require_reloader/94add3de6bac904aaad00eb364037d7263d4ab5d/test/resources/rails30-app/public/favicon.ico -------------------------------------------------------------------------------- /test/resources/rails30-app/public/images/rails.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teohm/require_reloader/94add3de6bac904aaad00eb364037d7263d4ab5d/test/resources/rails30-app/public/images/rails.png -------------------------------------------------------------------------------- /test/resources/rails30-app/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Ruby on Rails: Welcome aboard 5 | 172 | 185 | 186 | 187 |
188 | 201 | 202 |
203 | 207 | 208 | 212 | 213 |
214 |

Getting started

215 |

Here’s how to get rolling:

216 | 217 |
    218 |
  1. 219 |

    Use rails generate to create your models and controllers

    220 |

    To see all available options, run it without parameters.

    221 |
  2. 222 | 223 |
  3. 224 |

    Set up a default route and remove or rename this file

    225 |

    Routes are set up in config/routes.rb.

    226 |
  4. 227 | 228 |
  5. 229 |

    Create your database

    230 |

    Run rake db:migrate to create your database. If you're not using SQLite (the default), edit config/database.yml with your username and password.

    231 |
  6. 232 |
233 |
234 |
235 | 236 | 237 |
238 | 239 | 240 | -------------------------------------------------------------------------------- /test/resources/rails30-app/public/javascripts/application.js: -------------------------------------------------------------------------------- 1 | // Place your application-specific JavaScript functions and classes here 2 | // This file is automatically included by javascript_include_tag :defaults 3 | -------------------------------------------------------------------------------- /test/resources/rails30-app/public/javascripts/rails.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | // Technique from Juriy Zaytsev 3 | // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/ 4 | function isEventSupported(eventName) { 5 | var el = document.createElement('div'); 6 | eventName = 'on' + eventName; 7 | var isSupported = (eventName in el); 8 | if (!isSupported) { 9 | el.setAttribute(eventName, 'return;'); 10 | isSupported = typeof el[eventName] == 'function'; 11 | } 12 | el = null; 13 | return isSupported; 14 | } 15 | 16 | function isForm(element) { 17 | return Object.isElement(element) && element.nodeName.toUpperCase() == 'FORM' 18 | } 19 | 20 | function isInput(element) { 21 | if (Object.isElement(element)) { 22 | var name = element.nodeName.toUpperCase() 23 | return name == 'INPUT' || name == 'SELECT' || name == 'TEXTAREA' 24 | } 25 | else return false 26 | } 27 | 28 | var submitBubbles = isEventSupported('submit'), 29 | changeBubbles = isEventSupported('change') 30 | 31 | if (!submitBubbles || !changeBubbles) { 32 | // augment the Event.Handler class to observe custom events when needed 33 | Event.Handler.prototype.initialize = Event.Handler.prototype.initialize.wrap( 34 | function(init, element, eventName, selector, callback) { 35 | init(element, eventName, selector, callback) 36 | // is the handler being attached to an element that doesn't support this event? 37 | if ( (!submitBubbles && this.eventName == 'submit' && !isForm(this.element)) || 38 | (!changeBubbles && this.eventName == 'change' && !isInput(this.element)) ) { 39 | // "submit" => "emulated:submit" 40 | this.eventName = 'emulated:' + this.eventName 41 | } 42 | } 43 | ) 44 | } 45 | 46 | if (!submitBubbles) { 47 | // discover forms on the page by observing focus events which always bubble 48 | document.on('focusin', 'form', function(focusEvent, form) { 49 | // special handler for the real "submit" event (one-time operation) 50 | if (!form.retrieve('emulated:submit')) { 51 | form.on('submit', function(submitEvent) { 52 | var emulated = form.fire('emulated:submit', submitEvent, true) 53 | // if custom event received preventDefault, cancel the real one too 54 | if (emulated.returnValue === false) submitEvent.preventDefault() 55 | }) 56 | form.store('emulated:submit', true) 57 | } 58 | }) 59 | } 60 | 61 | if (!changeBubbles) { 62 | // discover form inputs on the page 63 | document.on('focusin', 'input, select, texarea', function(focusEvent, input) { 64 | // special handler for real "change" events 65 | if (!input.retrieve('emulated:change')) { 66 | input.on('change', function(changeEvent) { 67 | input.fire('emulated:change', changeEvent, true) 68 | }) 69 | input.store('emulated:change', true) 70 | } 71 | }) 72 | } 73 | 74 | function handleRemote(element) { 75 | var method, url, params; 76 | 77 | var event = element.fire("ajax:before"); 78 | if (event.stopped) return false; 79 | 80 | if (element.tagName.toLowerCase() === 'form') { 81 | method = element.readAttribute('method') || 'post'; 82 | url = element.readAttribute('action'); 83 | params = element.serialize(); 84 | } else { 85 | method = element.readAttribute('data-method') || 'get'; 86 | url = element.readAttribute('href'); 87 | params = {}; 88 | } 89 | 90 | new Ajax.Request(url, { 91 | method: method, 92 | parameters: params, 93 | evalScripts: true, 94 | 95 | onComplete: function(request) { element.fire("ajax:complete", request); }, 96 | onSuccess: function(request) { element.fire("ajax:success", request); }, 97 | onFailure: function(request) { element.fire("ajax:failure", request); } 98 | }); 99 | 100 | element.fire("ajax:after"); 101 | } 102 | 103 | function handleMethod(element) { 104 | var method = element.readAttribute('data-method'), 105 | url = element.readAttribute('href'), 106 | csrf_param = $$('meta[name=csrf-param]')[0], 107 | csrf_token = $$('meta[name=csrf-token]')[0]; 108 | 109 | var form = new Element('form', { method: "POST", action: url, style: "display: none;" }); 110 | element.parentNode.insert(form); 111 | 112 | if (method !== 'post') { 113 | var field = new Element('input', { type: 'hidden', name: '_method', value: method }); 114 | form.insert(field); 115 | } 116 | 117 | if (csrf_param) { 118 | var param = csrf_param.readAttribute('content'), 119 | token = csrf_token.readAttribute('content'), 120 | field = new Element('input', { type: 'hidden', name: param, value: token }); 121 | form.insert(field); 122 | } 123 | 124 | form.submit(); 125 | } 126 | 127 | 128 | document.on("click", "*[data-confirm]", function(event, element) { 129 | var message = element.readAttribute('data-confirm'); 130 | if (!confirm(message)) event.stop(); 131 | }); 132 | 133 | document.on("click", "a[data-remote]", function(event, element) { 134 | if (event.stopped) return; 135 | handleRemote(element); 136 | event.stop(); 137 | }); 138 | 139 | document.on("click", "a[data-method]", function(event, element) { 140 | if (event.stopped) return; 141 | handleMethod(element); 142 | event.stop(); 143 | }); 144 | 145 | document.on("submit", function(event) { 146 | var element = event.findElement(), 147 | message = element.readAttribute('data-confirm'); 148 | if (message && !confirm(message)) { 149 | event.stop(); 150 | return false; 151 | } 152 | 153 | var inputs = element.select("input[type=submit][data-disable-with]"); 154 | inputs.each(function(input) { 155 | input.disabled = true; 156 | input.writeAttribute('data-original-value', input.value); 157 | input.value = input.readAttribute('data-disable-with'); 158 | }); 159 | 160 | var element = event.findElement("form[data-remote]"); 161 | if (element) { 162 | handleRemote(element); 163 | event.stop(); 164 | } 165 | }); 166 | 167 | document.on("ajax:after", "form", function(event, element) { 168 | var inputs = element.select("input[type=submit][disabled=true][data-disable-with]"); 169 | inputs.each(function(input) { 170 | input.value = input.readAttribute('data-original-value'); 171 | input.removeAttribute('data-original-value'); 172 | input.disabled = false; 173 | }); 174 | }); 175 | 176 | Ajax.Responders.register({ 177 | onCreate: function(request) { 178 | var csrf_meta_tag = $$('meta[name=csrf-token]')[0]; 179 | 180 | if (csrf_meta_tag) { 181 | var header = 'X-CSRF-Token', 182 | token = csrf_meta_tag.readAttribute('content'); 183 | 184 | if (!request.options.requestHeaders) { 185 | request.options.requestHeaders = {}; 186 | } 187 | request.options.requestHeaders[header] = token; 188 | } 189 | } 190 | }); 191 | })(); 192 | -------------------------------------------------------------------------------- /test/resources/rails30-app/public/robots.txt: -------------------------------------------------------------------------------- 1 | # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file 2 | # 3 | # To ban all spiders from the entire site uncomment the next two lines: 4 | # User-Agent: * 5 | # Disallow: / 6 | -------------------------------------------------------------------------------- /test/resources/rails30-app/public/stylesheets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teohm/require_reloader/94add3de6bac904aaad00eb364037d7263d4ab5d/test/resources/rails30-app/public/stylesheets/.gitkeep -------------------------------------------------------------------------------- /test/resources/rails30-app/script/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. 3 | 4 | APP_PATH = File.expand_path('../../config/application', __FILE__) 5 | require File.expand_path('../../config/boot', __FILE__) 6 | require 'rails/commands' 7 | -------------------------------------------------------------------------------- /test/resources/rails30-app/test/integration/reload_require_files_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class ReloadRequireFilesTest < ActionDispatch::IntegrationTest 4 | 5 | self.use_transactional_fixtures = false 6 | 7 | test "the truth" do 8 | overwrite_codes_with!(:original) 9 | 10 | get "/test.txt" 11 | assert_equal [ 12 | "local-gem: top-level:original, sub-level:original", 13 | "lib: top-level:original, sub-level:original" 14 | ].join("\n"), @response.body, "before modify codebase" 15 | 16 | overwrite_codes_with!(:modified) 17 | 18 | get "/test.txt" 19 | assert_equal [ 20 | "local-gem: top-level:modified, sub-level:modified", 21 | "lib: top-level:modified, sub-level:modified" 22 | ].join("\n"), @response.body, "after modify codebase" 23 | 24 | overwrite_codes_with!(:original) 25 | end 26 | 27 | def overwrite_codes_with!(type) 28 | require "fileutils" 29 | { 30 | "gems/sample_gem1/lib/sample_gem1.#{type}.rb" => "gems/sample_gem1/lib/sample_gem1.rb", 31 | "gems/sample_gem1/lib/sample_gem1/base.#{type}.rb" => "gems/sample_gem1/lib/sample_gem1/base.rb", 32 | "lib/sample_gem2.#{type}.rb" => "lib/sample_gem2.rb", 33 | "lib/sample_gem2/base.#{type}.rb" => "lib/sample_gem2/base.rb" 34 | }.each do |from, to| 35 | FileUtils.cp from, to 36 | end 37 | sleep 0.5 38 | end 39 | end 40 | -------------------------------------------------------------------------------- /test/resources/rails30-app/test/performance/browsing_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | require 'rails/performance_test_help' 3 | 4 | # Profiling results for each test method are written to tmp/performance. 5 | class BrowsingTest < ActionDispatch::PerformanceTest 6 | def test_homepage 7 | get '/' 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /test/resources/rails30-app/test/test_helper.rb: -------------------------------------------------------------------------------- 1 | ENV["RAILS_ENV"] = "development" 2 | require File.expand_path('../../config/environment', __FILE__) 3 | require 'rails/test_help' 4 | 5 | class ActiveSupport::TestCase 6 | # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order. 7 | # 8 | # Note: You'll currently still have to declare fixtures explicitly in integration tests 9 | # -- they do not yet inherit this setting 10 | fixtures :all 11 | 12 | # Add more helper methods to be used by all tests here... 13 | end 14 | -------------------------------------------------------------------------------- /test/resources/rails30-app/vendor/plugins/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teohm/require_reloader/94add3de6bac904aaad00eb364037d7263d4ab5d/test/resources/rails30-app/vendor/plugins/.gitkeep -------------------------------------------------------------------------------- /test/resources/rails31-app/.gitignore: -------------------------------------------------------------------------------- 1 | .bundle 2 | db/*.sqlite3 3 | log/*.log 4 | tmp/ 5 | .sass-cache/ 6 | -------------------------------------------------------------------------------- /test/resources/rails31-app/Gemfile: -------------------------------------------------------------------------------- 1 | source 'http://rubygems.org' 2 | 3 | gem 'rails', '3.1.0' 4 | 5 | # Bundle edge Rails instead: 6 | # gem 'rails', :git => 'git://github.com/rails/rails.git' 7 | 8 | gem 'sqlite3' 9 | 10 | gem 'sample_gem1', :path => 'gems/sample_gem1' 11 | gem 'require_reloader', :path => '../../..' 12 | 13 | # Gems used only for assets and not required 14 | # in production environments by default. 15 | group :assets do 16 | gem 'sass-rails', " ~> 3.1.0" 17 | gem 'coffee-rails', "~> 3.1.0" 18 | gem 'uglifier' 19 | end 20 | 21 | gem 'jquery-rails' 22 | 23 | # Use unicorn as the web server 24 | # gem 'unicorn' 25 | 26 | # Deploy with Capistrano 27 | # gem 'capistrano' 28 | 29 | # To use debugger 30 | # gem 'ruby-debug19', :require => 'ruby-debug' 31 | 32 | group :test do 33 | # Pretty printed test output 34 | gem 'turn', :require => false 35 | end 36 | -------------------------------------------------------------------------------- /test/resources/rails31-app/README: -------------------------------------------------------------------------------- 1 | == Welcome to Rails 2 | 3 | Rails is a web-application framework that includes everything needed to create 4 | database-backed web applications according to the Model-View-Control pattern. 5 | 6 | This pattern splits the view (also called the presentation) into "dumb" 7 | templates that are primarily responsible for inserting pre-built data in between 8 | HTML tags. The model contains the "smart" domain objects (such as Account, 9 | Product, Person, Post) that holds all the business logic and knows how to 10 | persist themselves to a database. The controller handles the incoming requests 11 | (such as Save New Account, Update Product, Show Post) by manipulating the model 12 | and directing data to the view. 13 | 14 | In Rails, the model is handled by what's called an object-relational mapping 15 | layer entitled Active Record. This layer allows you to present the data from 16 | database rows as objects and embellish these data objects with business logic 17 | methods. You can read more about Active Record in 18 | link:files/vendor/rails/activerecord/README.html. 19 | 20 | The controller and view are handled by the Action Pack, which handles both 21 | layers by its two parts: Action View and Action Controller. These two layers 22 | are bundled in a single package due to their heavy interdependence. This is 23 | unlike the relationship between the Active Record and Action Pack that is much 24 | more separate. Each of these packages can be used independently outside of 25 | Rails. You can read more about Action Pack in 26 | link:files/vendor/rails/actionpack/README.html. 27 | 28 | 29 | == Getting Started 30 | 31 | 1. At the command prompt, create a new Rails application: 32 | rails new myapp (where myapp is the application name) 33 | 34 | 2. Change directory to myapp and start the web server: 35 | cd myapp; rails server (run with --help for options) 36 | 37 | 3. Go to http://localhost:3000/ and you'll see: 38 | "Welcome aboard: You're riding Ruby on Rails!" 39 | 40 | 4. Follow the guidelines to start developing your application. You can find 41 | the following resources handy: 42 | 43 | * The Getting Started Guide: http://guides.rubyonrails.org/getting_started.html 44 | * Ruby on Rails Tutorial Book: http://www.railstutorial.org/ 45 | 46 | 47 | == Debugging Rails 48 | 49 | Sometimes your application goes wrong. Fortunately there are a lot of tools that 50 | will help you debug it and get it back on the rails. 51 | 52 | First area to check is the application log files. Have "tail -f" commands 53 | running on the server.log and development.log. Rails will automatically display 54 | debugging and runtime information to these files. Debugging info will also be 55 | shown in the browser on requests from 127.0.0.1. 56 | 57 | You can also log your own messages directly into the log file from your code 58 | using the Ruby logger class from inside your controllers. Example: 59 | 60 | class WeblogController < ActionController::Base 61 | def destroy 62 | @weblog = Weblog.find(params[:id]) 63 | @weblog.destroy 64 | logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!") 65 | end 66 | end 67 | 68 | The result will be a message in your log file along the lines of: 69 | 70 | Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1! 71 | 72 | More information on how to use the logger is at http://www.ruby-doc.org/core/ 73 | 74 | Also, Ruby documentation can be found at http://www.ruby-lang.org/. There are 75 | several books available online as well: 76 | 77 | * Programming Ruby: http://www.ruby-doc.org/docs/ProgrammingRuby/ (Pickaxe) 78 | * Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide) 79 | 80 | These two books will bring you up to speed on the Ruby language and also on 81 | programming in general. 82 | 83 | 84 | == Debugger 85 | 86 | Debugger support is available through the debugger command when you start your 87 | Mongrel or WEBrick server with --debugger. This means that you can break out of 88 | execution at any point in the code, investigate and change the model, and then, 89 | resume execution! You need to install ruby-debug to run the server in debugging 90 | mode. With gems, use sudo gem install ruby-debug. Example: 91 | 92 | class WeblogController < ActionController::Base 93 | def index 94 | @posts = Post.all 95 | debugger 96 | end 97 | end 98 | 99 | So the controller will accept the action, run the first line, then present you 100 | with a IRB prompt in the server window. Here you can do things like: 101 | 102 | >> @posts.inspect 103 | => "[#nil, "body"=>nil, "id"=>"1"}>, 105 | #"Rails", "body"=>"Only ten..", "id"=>"2"}>]" 107 | >> @posts.first.title = "hello from a debugger" 108 | => "hello from a debugger" 109 | 110 | ...and even better, you can examine how your runtime objects actually work: 111 | 112 | >> f = @posts.first 113 | => #nil, "body"=>nil, "id"=>"1"}> 114 | >> f. 115 | Display all 152 possibilities? (y or n) 116 | 117 | Finally, when you're ready to resume execution, you can enter "cont". 118 | 119 | 120 | == Console 121 | 122 | The console is a Ruby shell, which allows you to interact with your 123 | application's domain model. Here you'll have all parts of the application 124 | configured, just like it is when the application is running. You can inspect 125 | domain models, change values, and save to the database. Starting the script 126 | without arguments will launch it in the development environment. 127 | 128 | To start the console, run rails console from the application 129 | directory. 130 | 131 | Options: 132 | 133 | * Passing the -s, --sandbox argument will rollback any modifications 134 | made to the database. 135 | * Passing an environment name as an argument will load the corresponding 136 | environment. Example: rails console production. 137 | 138 | To reload your controllers and models after launching the console run 139 | reload! 140 | 141 | More information about irb can be found at: 142 | link:http://www.rubycentral.org/pickaxe/irb.html 143 | 144 | 145 | == dbconsole 146 | 147 | You can go to the command line of your database directly through rails 148 | dbconsole. You would be connected to the database with the credentials 149 | defined in database.yml. Starting the script without arguments will connect you 150 | to the development database. Passing an argument will connect you to a different 151 | database, like rails dbconsole production. Currently works for MySQL, 152 | PostgreSQL and SQLite 3. 153 | 154 | == Description of Contents 155 | 156 | The default directory structure of a generated Ruby on Rails application: 157 | 158 | |-- app 159 | | |-- assets 160 | | |-- images 161 | | |-- javascripts 162 | | `-- stylesheets 163 | | |-- controllers 164 | | |-- helpers 165 | | |-- mailers 166 | | |-- models 167 | | `-- views 168 | | `-- layouts 169 | |-- config 170 | | |-- environments 171 | | |-- initializers 172 | | `-- locales 173 | |-- db 174 | |-- doc 175 | |-- lib 176 | | `-- tasks 177 | |-- log 178 | |-- public 179 | |-- script 180 | |-- test 181 | | |-- fixtures 182 | | |-- functional 183 | | |-- integration 184 | | |-- performance 185 | | `-- unit 186 | |-- tmp 187 | | |-- cache 188 | | |-- pids 189 | | |-- sessions 190 | | `-- sockets 191 | `-- vendor 192 | |-- assets 193 | `-- stylesheets 194 | `-- plugins 195 | 196 | app 197 | Holds all the code that's specific to this particular application. 198 | 199 | app/assets 200 | Contains subdirectories for images, stylesheets, and JavaScript files. 201 | 202 | app/controllers 203 | Holds controllers that should be named like weblogs_controller.rb for 204 | automated URL mapping. All controllers should descend from 205 | ApplicationController which itself descends from ActionController::Base. 206 | 207 | app/models 208 | Holds models that should be named like post.rb. Models descend from 209 | ActiveRecord::Base by default. 210 | 211 | app/views 212 | Holds the template files for the view that should be named like 213 | weblogs/index.html.erb for the WeblogsController#index action. All views use 214 | eRuby syntax by default. 215 | 216 | app/views/layouts 217 | Holds the template files for layouts to be used with views. This models the 218 | common header/footer method of wrapping views. In your views, define a layout 219 | using the layout :default and create a file named default.html.erb. 220 | Inside default.html.erb, call <% yield %> to render the view using this 221 | layout. 222 | 223 | app/helpers 224 | Holds view helpers that should be named like weblogs_helper.rb. These are 225 | generated for you automatically when using generators for controllers. 226 | Helpers can be used to wrap functionality for your views into methods. 227 | 228 | config 229 | Configuration files for the Rails environment, the routing map, the database, 230 | and other dependencies. 231 | 232 | db 233 | Contains the database schema in schema.rb. db/migrate contains all the 234 | sequence of Migrations for your schema. 235 | 236 | doc 237 | This directory is where your application documentation will be stored when 238 | generated using rake doc:app 239 | 240 | lib 241 | Application specific libraries. Basically, any kind of custom code that 242 | doesn't belong under controllers, models, or helpers. This directory is in 243 | the load path. 244 | 245 | public 246 | The directory available for the web server. Also contains the dispatchers and the 247 | default HTML files. This should be set as the DOCUMENT_ROOT of your web 248 | server. 249 | 250 | script 251 | Helper scripts for automation and generation. 252 | 253 | test 254 | Unit and functional tests along with fixtures. When using the rails generate 255 | command, template test files will be generated for you and placed in this 256 | directory. 257 | 258 | vendor 259 | External libraries that the application depends on. Also includes the plugins 260 | subdirectory. If the app has frozen rails, those gems also go here, under 261 | vendor/rails/. This directory is in the load path. 262 | -------------------------------------------------------------------------------- /test/resources/rails31-app/Rakefile: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env rake 2 | # Add your own tasks in files placed in lib/tasks ending in .rake, 3 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 4 | 5 | require File.expand_path('../config/application', __FILE__) 6 | 7 | Rails31App::Application.load_tasks 8 | -------------------------------------------------------------------------------- /test/resources/rails31-app/app/assets/images/rails.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teohm/require_reloader/94add3de6bac904aaad00eb364037d7263d4ab5d/test/resources/rails31-app/app/assets/images/rails.png -------------------------------------------------------------------------------- /test/resources/rails31-app/app/assets/javascripts/application.js: -------------------------------------------------------------------------------- 1 | // This is a manifest file that'll be compiled into including all the files listed below. 2 | // Add new JavaScript/Coffee code in separate files in this directory and they'll automatically 3 | // be included in the compiled file accessible from http://example.com/assets/application.js 4 | // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the 5 | // the compiled file. 6 | // 7 | //= require jquery 8 | //= require jquery_ujs 9 | //= require_tree . 10 | -------------------------------------------------------------------------------- /test/resources/rails31-app/app/assets/stylesheets/application.css: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a manifest file that'll automatically include all the stylesheets available in this directory 3 | * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at 4 | * the top of the compiled file, but it's generally better to create a new file per style scope. 5 | *= require_self 6 | *= require_tree . 7 | */ -------------------------------------------------------------------------------- /test/resources/rails31-app/app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::Base 2 | protect_from_forgery 3 | end 4 | -------------------------------------------------------------------------------- /test/resources/rails31-app/app/controllers/test_controller.rb: -------------------------------------------------------------------------------- 1 | require 'sample_gem1' 2 | require 'sample_gem2' 3 | 4 | class TestController < ApplicationController 5 | def show 6 | messages = [ 7 | SampleGem1.test_message, 8 | SampleGem2.test_message 9 | ] 10 | 11 | render :text => messages.join("\n") 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /test/resources/rails31-app/app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | end 3 | -------------------------------------------------------------------------------- /test/resources/rails31-app/app/mailers/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teohm/require_reloader/94add3de6bac904aaad00eb364037d7263d4ab5d/test/resources/rails31-app/app/mailers/.gitkeep -------------------------------------------------------------------------------- /test/resources/rails31-app/app/models/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teohm/require_reloader/94add3de6bac904aaad00eb364037d7263d4ab5d/test/resources/rails31-app/app/models/.gitkeep -------------------------------------------------------------------------------- /test/resources/rails31-app/app/views/layouts/application.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Rails31App 5 | <%= stylesheet_link_tag "application" %> 6 | <%= javascript_include_tag "application" %> 7 | <%= csrf_meta_tags %> 8 | 9 | 10 | 11 | <%= yield %> 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /test/resources/rails31-app/config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require ::File.expand_path('../config/environment', __FILE__) 4 | run Rails31App::Application 5 | -------------------------------------------------------------------------------- /test/resources/rails31-app/config/application.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../boot', __FILE__) 2 | 3 | require 'rails/all' 4 | 5 | if defined?(Bundler) 6 | # If you precompile assets before deploying to production, use this line 7 | Bundler.require *Rails.groups(:assets => %w(development test)) 8 | # If you want your assets lazily compiled in production, use this line 9 | # Bundler.require(:default, :assets, Rails.env) 10 | end 11 | 12 | module Rails31App 13 | class Application < Rails::Application 14 | # Settings in config/environments/* take precedence over those specified here. 15 | # Application configuration should go into files in config/initializers 16 | # -- all .rb files in that directory are automatically loaded. 17 | 18 | # Custom directories with classes and modules you want to be autoloadable. 19 | # config.autoload_paths += %W(#{config.root}/extras) 20 | 21 | # Only load the plugins named here, in the order given (default is alphabetical). 22 | # :all can be used as a placeholder for all plugins not explicitly named. 23 | # config.plugins = [ :exception_notification, :ssl_requirement, :all ] 24 | 25 | # Activate observers that should always be running. 26 | # config.active_record.observers = :cacher, :garbage_collector, :forum_observer 27 | 28 | # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. 29 | # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. 30 | # config.time_zone = 'Central Time (US & Canada)' 31 | 32 | # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. 33 | # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] 34 | # config.i18n.default_locale = :de 35 | 36 | # Configure the default encoding used in templates for Ruby 1.9. 37 | config.encoding = "utf-8" 38 | 39 | # Configure sensitive parameters which will be filtered from the log file. 40 | config.filter_parameters += [:password] 41 | 42 | # Enable the asset pipeline 43 | config.assets.enabled = true 44 | 45 | # Version of your assets, change this if you want to expire all your assets 46 | config.assets.version = '1.0' 47 | end 48 | end 49 | -------------------------------------------------------------------------------- /test/resources/rails31-app/config/boot.rb: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | 3 | # Set up gems listed in the Gemfile. 4 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 5 | 6 | require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE']) 7 | -------------------------------------------------------------------------------- /test/resources/rails31-app/config/database.yml: -------------------------------------------------------------------------------- 1 | # SQLite version 3.x 2 | # gem install sqlite3 3 | # 4 | # Ensure the SQLite 3 gem is defined in your Gemfile 5 | # gem 'sqlite3' 6 | development: 7 | adapter: sqlite3 8 | database: db/development.sqlite3 9 | pool: 5 10 | timeout: 5000 11 | 12 | # Warning: The database defined as "test" will be erased and 13 | # re-generated from your development database when you run "rake". 14 | # Do not set this db to the same as development or production. 15 | test: 16 | adapter: sqlite3 17 | database: db/test.sqlite3 18 | pool: 5 19 | timeout: 5000 20 | 21 | production: 22 | adapter: sqlite3 23 | database: db/production.sqlite3 24 | pool: 5 25 | timeout: 5000 26 | -------------------------------------------------------------------------------- /test/resources/rails31-app/config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the rails application 2 | require File.expand_path('../application', __FILE__) 3 | 4 | # Initialize the rails application 5 | Rails31App::Application.initialize! 6 | -------------------------------------------------------------------------------- /test/resources/rails31-app/config/environments/development.rb: -------------------------------------------------------------------------------- 1 | Rails31App::Application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb 3 | 4 | # In the development environment your application's code is reloaded on 5 | # every request. This slows down response time but is perfect for development 6 | # since you don't have to restart the web server when you make code changes. 7 | config.cache_classes = false 8 | 9 | # Log error messages when you accidentally call methods on nil. 10 | config.whiny_nils = true 11 | 12 | # Show full error reports and disable caching 13 | config.consider_all_requests_local = true 14 | config.action_controller.perform_caching = false 15 | 16 | # Don't care if the mailer can't send 17 | config.action_mailer.raise_delivery_errors = false 18 | 19 | # Print deprecation notices to the Rails logger 20 | config.active_support.deprecation = :log 21 | 22 | # Only use best-standards-support built into browsers 23 | config.action_dispatch.best_standards_support = :builtin 24 | 25 | # Do not compress assets 26 | config.assets.compress = false 27 | 28 | # Expands the lines which load the assets 29 | config.assets.debug = true 30 | 31 | RequireReloader.watch_local_gems! 32 | RequireReloader.watch :sample_gem2 33 | 34 | end 35 | -------------------------------------------------------------------------------- /test/resources/rails31-app/config/environments/production.rb: -------------------------------------------------------------------------------- 1 | Rails31App::Application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb 3 | 4 | # Code is not reloaded between requests 5 | config.cache_classes = true 6 | 7 | # Full error reports are disabled and caching is turned on 8 | config.consider_all_requests_local = false 9 | config.action_controller.perform_caching = true 10 | 11 | # Disable Rails's static asset server (Apache or nginx will already do this) 12 | config.serve_static_assets = false 13 | 14 | # Compress JavaScripts and CSS 15 | config.assets.compress = true 16 | 17 | # Don't fallback to assets pipeline if a precompiled asset is missed 18 | config.assets.compile = false 19 | 20 | # Generate digests for assets URLs 21 | config.assets.digest = true 22 | 23 | # Defaults to Rails.root.join("public/assets") 24 | # config.assets.manifest = YOUR_PATH 25 | 26 | # Specifies the header that your server uses for sending files 27 | # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache 28 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx 29 | 30 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. 31 | # config.force_ssl = true 32 | 33 | # See everything in the log (default is :info) 34 | # config.log_level = :debug 35 | 36 | # Use a different logger for distributed setups 37 | # config.logger = SyslogLogger.new 38 | 39 | # Use a different cache store in production 40 | # config.cache_store = :mem_cache_store 41 | 42 | # Enable serving of images, stylesheets, and JavaScripts from an asset server 43 | # config.action_controller.asset_host = "http://assets.example.com" 44 | 45 | # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added) 46 | # config.assets.precompile += %w( search.js ) 47 | 48 | # Disable delivery errors, bad email addresses will be ignored 49 | # config.action_mailer.raise_delivery_errors = false 50 | 51 | # Enable threaded mode 52 | # config.threadsafe! 53 | 54 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to 55 | # the I18n.default_locale when a translation can not be found) 56 | config.i18n.fallbacks = true 57 | 58 | # Send deprecation notices to registered listeners 59 | config.active_support.deprecation = :notify 60 | end 61 | -------------------------------------------------------------------------------- /test/resources/rails31-app/config/environments/test.rb: -------------------------------------------------------------------------------- 1 | Rails31App::Application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb 3 | 4 | # The test environment is used exclusively to run your application's 5 | # test suite. You never need to work with it otherwise. Remember that 6 | # your test database is "scratch space" for the test suite and is wiped 7 | # and recreated between test runs. Don't rely on the data there! 8 | config.cache_classes = true 9 | 10 | # Configure static asset server for tests with Cache-Control for performance 11 | config.serve_static_assets = true 12 | config.static_cache_control = "public, max-age=3600" 13 | 14 | # Log error messages when you accidentally call methods on nil 15 | config.whiny_nils = true 16 | 17 | # Show full error reports and disable caching 18 | config.consider_all_requests_local = true 19 | config.action_controller.perform_caching = false 20 | 21 | # Raise exceptions instead of rendering exception templates 22 | config.action_dispatch.show_exceptions = false 23 | 24 | # Disable request forgery protection in test environment 25 | config.action_controller.allow_forgery_protection = false 26 | 27 | # Tell Action Mailer not to deliver emails to the real world. 28 | # The :test delivery method accumulates sent emails in the 29 | # ActionMailer::Base.deliveries array. 30 | config.action_mailer.delivery_method = :test 31 | 32 | # Use SQL instead of Active Record's schema dumper when creating the test database. 33 | # This is necessary if your schema can't be completely dumped by the schema dumper, 34 | # like if you have constraints or database-specific column types 35 | # config.active_record.schema_format = :sql 36 | 37 | # Print deprecation notices to the stderr 38 | config.active_support.deprecation = :stderr 39 | 40 | # Allow pass debug_assets=true as a query parameter to load pages with unpackaged assets 41 | config.assets.allow_debugging = true 42 | end 43 | -------------------------------------------------------------------------------- /test/resources/rails31-app/config/initializers/backtrace_silencers.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. 4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } 5 | 6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. 7 | # Rails.backtrace_cleaner.remove_silencers! 8 | -------------------------------------------------------------------------------- /test/resources/rails31-app/config/initializers/inflections.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new inflection rules using the following format 4 | # (all these examples are active by default): 5 | # ActiveSupport::Inflector.inflections do |inflect| 6 | # inflect.plural /^(ox)$/i, '\1en' 7 | # inflect.singular /^(ox)en/i, '\1' 8 | # inflect.irregular 'person', 'people' 9 | # inflect.uncountable %w( fish sheep ) 10 | # end 11 | -------------------------------------------------------------------------------- /test/resources/rails31-app/config/initializers/mime_types.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new mime types for use in respond_to blocks: 4 | # Mime::Type.register "text/richtext", :rtf 5 | # Mime::Type.register_alias "text/html", :iphone 6 | -------------------------------------------------------------------------------- /test/resources/rails31-app/config/initializers/secret_token.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Your secret key for verifying the integrity of signed cookies. 4 | # If you change this key, all old signed cookies will become invalid! 5 | # Make sure the secret is at least 30 characters and all random, 6 | # no regular words or you'll be exposed to dictionary attacks. 7 | Rails31App::Application.config.secret_token = '5cb9bd9f651fddc18240f1411717303959b4dc0b95208cca37809aa3368ea518a32dcfa606c4ce7f036d98aa60209c03289ac21e2ea01073e580a02550f2fab0' 8 | -------------------------------------------------------------------------------- /test/resources/rails31-app/config/initializers/session_store.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails31App::Application.config.session_store :cookie_store, key: '_rails31-app_session' 4 | 5 | # Use the database for sessions instead of the cookie-based default, 6 | # which shouldn't be used to store highly confidential information 7 | # (create the session table with "rails generate session_migration") 8 | # Rails31App::Application.config.session_store :active_record_store 9 | -------------------------------------------------------------------------------- /test/resources/rails31-app/config/initializers/wrap_parameters.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | # 3 | # This file contains settings for ActionController::ParamsWrapper which 4 | # is enabled by default. 5 | 6 | # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. 7 | ActiveSupport.on_load(:action_controller) do 8 | wrap_parameters format: [:json] 9 | end 10 | 11 | # Disable root element in JSON by default. 12 | ActiveSupport.on_load(:active_record) do 13 | self.include_root_in_json = false 14 | end 15 | -------------------------------------------------------------------------------- /test/resources/rails31-app/config/locales/en.yml: -------------------------------------------------------------------------------- 1 | # Sample localization file for English. Add more files in this directory for other locales. 2 | # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. 3 | 4 | en: 5 | hello: "Hello world" 6 | -------------------------------------------------------------------------------- /test/resources/rails31-app/config/routes.rb: -------------------------------------------------------------------------------- 1 | Rails31App::Application.routes.draw do 2 | match 'test' => 'test#show', :via => :get 3 | 4 | # The priority is based upon order of creation: 5 | # first created -> highest priority. 6 | 7 | # Sample of regular route: 8 | # match 'products/:id' => 'catalog#view' 9 | # Keep in mind you can assign values other than :controller and :action 10 | 11 | # Sample of named route: 12 | # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase 13 | # This route can be invoked with purchase_url(:id => product.id) 14 | 15 | # Sample resource route (maps HTTP verbs to controller actions automatically): 16 | # resources :products 17 | 18 | # Sample resource route with options: 19 | # resources :products do 20 | # member do 21 | # get 'short' 22 | # post 'toggle' 23 | # end 24 | # 25 | # collection do 26 | # get 'sold' 27 | # end 28 | # end 29 | 30 | # Sample resource route with sub-resources: 31 | # resources :products do 32 | # resources :comments, :sales 33 | # resource :seller 34 | # end 35 | 36 | # Sample resource route with more complex sub-resources 37 | # resources :products do 38 | # resources :comments 39 | # resources :sales do 40 | # get 'recent', :on => :collection 41 | # end 42 | # end 43 | 44 | # Sample resource route within a namespace: 45 | # namespace :admin do 46 | # # Directs /admin/products/* to Admin::ProductsController 47 | # # (app/controllers/admin/products_controller.rb) 48 | # resources :products 49 | # end 50 | 51 | # You can have the root of your site routed with "root" 52 | # just remember to delete public/index.html. 53 | # root :to => 'welcome#index' 54 | 55 | # See how all your routes lay out with "rake routes" 56 | 57 | # This is a legacy wild controller route that's not recommended for RESTful applications. 58 | # Note: This route will make all actions in every controller accessible via GET requests. 59 | # match ':controller(/:action(/:id(.:format)))' 60 | end 61 | -------------------------------------------------------------------------------- /test/resources/rails31-app/db/schema.rb: -------------------------------------------------------------------------------- 1 | # encoding: UTF-8 2 | # This file is auto-generated from the current state of the database. Instead 3 | # of editing this file, please use the migrations feature of Active Record to 4 | # incrementally modify your database, and then regenerate this schema definition. 5 | # 6 | # Note that this schema.rb definition is the authoritative source for your 7 | # database schema. If you need to create the application database on another 8 | # system, you should be using db:schema:load, not running all the migrations 9 | # from scratch. The latter is a flawed and unsustainable approach (the more migrations 10 | # you'll amass, the slower it'll run and the greater likelihood for issues). 11 | # 12 | # It's strongly recommended to check this file into your version control system. 13 | 14 | ActiveRecord::Schema.define(:version => 0) do 15 | 16 | end 17 | -------------------------------------------------------------------------------- /test/resources/rails31-app/db/seeds.rb: -------------------------------------------------------------------------------- 1 | # This file should contain all the record creation needed to seed the database with its default values. 2 | # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). 3 | # 4 | # Examples: 5 | # 6 | # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) 7 | # Mayor.create(name: 'Emanuel', city: cities.first) 8 | -------------------------------------------------------------------------------- /test/resources/rails31-app/gems/sample_gem1/.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | *.rbc 3 | .bundle 4 | .config 5 | .yardoc 6 | Gemfile.lock 7 | InstalledFiles 8 | _yardoc 9 | coverage 10 | doc/ 11 | lib/bundler/man 12 | pkg 13 | rdoc 14 | spec/reports 15 | test/tmp 16 | test/version_tmp 17 | tmp 18 | -------------------------------------------------------------------------------- /test/resources/rails31-app/gems/sample_gem1/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | # Specify your gem's dependencies in sample_gem1.gemspec 4 | gemspec 5 | -------------------------------------------------------------------------------- /test/resources/rails31-app/gems/sample_gem1/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 Huiming Teo 2 | 3 | MIT License 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /test/resources/rails31-app/gems/sample_gem1/README.md: -------------------------------------------------------------------------------- 1 | # SampleGem1 2 | 3 | TODO: Write a gem description 4 | 5 | ## Installation 6 | 7 | Add this line to your application's Gemfile: 8 | 9 | gem 'sample_gem1' 10 | 11 | And then execute: 12 | 13 | $ bundle 14 | 15 | Or install it yourself as: 16 | 17 | $ gem install sample_gem1 18 | 19 | ## Usage 20 | 21 | TODO: Write usage instructions here 22 | 23 | ## Contributing 24 | 25 | 1. Fork it 26 | 2. Create your feature branch (`git checkout -b my-new-feature`) 27 | 3. Commit your changes (`git commit -am 'Add some feature'`) 28 | 4. Push to the branch (`git push origin my-new-feature`) 29 | 5. Create new Pull Request 30 | -------------------------------------------------------------------------------- /test/resources/rails31-app/gems/sample_gem1/Rakefile: -------------------------------------------------------------------------------- 1 | require "bundler/gem_tasks" 2 | 3 | namespace :test do 4 | namespace :data do 5 | desc "Reset the codebase" 6 | task :reset do 7 | overwrite_codes_with!(:original) 8 | end 9 | 10 | desc "Modify the codebase" 11 | task :modify do 12 | overwrite_codes_with!(:modified) 13 | end 14 | 15 | def overwrite_codes_with!(type) 16 | require "fileutils" 17 | { 18 | "lib/sample_gem1.#{type}.rb" => "lib/sample_gem1.rb", 19 | "lib/sample_gem1/base.#{type}.rb" => "lib/sample_gem1/base.rb" 20 | }.each do |from, to| 21 | FileUtils.cp from, to 22 | end 23 | end 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /test/resources/rails31-app/gems/sample_gem1/lib/sample_gem1.modified.rb: -------------------------------------------------------------------------------- 1 | require "sample_gem1/version" 2 | require "sample_gem1/base" 3 | 4 | module SampleGem1 5 | def self.message 6 | "modified" 7 | end 8 | 9 | def self.test_message 10 | base = Base.new 11 | "local-gem: top-level:#{self.message}, sub-level:#{base.message}" 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /test/resources/rails31-app/gems/sample_gem1/lib/sample_gem1.original.rb: -------------------------------------------------------------------------------- 1 | require "sample_gem1/version" 2 | require "sample_gem1/base" 3 | 4 | module SampleGem1 5 | def self.message 6 | "original" 7 | end 8 | 9 | def self.test_message 10 | base = Base.new 11 | "local-gem: top-level:#{self.message}, sub-level:#{base.message}" 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /test/resources/rails31-app/gems/sample_gem1/lib/sample_gem1.rb: -------------------------------------------------------------------------------- 1 | require "sample_gem1/version" 2 | require "sample_gem1/base" 3 | 4 | module SampleGem1 5 | def self.message 6 | "original" 7 | end 8 | 9 | def self.test_message 10 | base = Base.new 11 | "local-gem: top-level:#{self.message}, sub-level:#{base.message}" 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /test/resources/rails31-app/gems/sample_gem1/lib/sample_gem1/base.modified.rb: -------------------------------------------------------------------------------- 1 | module SampleGem1 2 | class Base 3 | def message 4 | "modified" 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /test/resources/rails31-app/gems/sample_gem1/lib/sample_gem1/base.original.rb: -------------------------------------------------------------------------------- 1 | module SampleGem1 2 | class Base 3 | def message 4 | "original" 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /test/resources/rails31-app/gems/sample_gem1/lib/sample_gem1/base.rb: -------------------------------------------------------------------------------- 1 | module SampleGem1 2 | class Base 3 | def message 4 | "original" 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /test/resources/rails31-app/gems/sample_gem1/lib/sample_gem1/version.rb: -------------------------------------------------------------------------------- 1 | module SampleGem1 2 | VERSION = "0.0.1" 3 | end 4 | -------------------------------------------------------------------------------- /test/resources/rails31-app/gems/sample_gem1/sample_gem1.gemspec: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | lib = File.expand_path('../lib', __FILE__) 3 | $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) 4 | require 'sample_gem1/version' 5 | 6 | Gem::Specification.new do |gem| 7 | gem.name = "sample_gem1" 8 | gem.version = SampleGem1::VERSION 9 | gem.authors = ["Huiming Teo"] 10 | gem.email = ["teohuiming@gmail.com"] 11 | gem.description = %q{TODO: Write a gem description} 12 | gem.summary = %q{TODO: Write a gem summary} 13 | gem.homepage = "" 14 | 15 | gem.files = `git ls-files`.split($/) 16 | gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) } 17 | gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) 18 | gem.require_paths = ["lib"] 19 | end 20 | -------------------------------------------------------------------------------- /test/resources/rails31-app/lib/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teohm/require_reloader/94add3de6bac904aaad00eb364037d7263d4ab5d/test/resources/rails31-app/lib/assets/.gitkeep -------------------------------------------------------------------------------- /test/resources/rails31-app/lib/sample_gem2.modified.rb: -------------------------------------------------------------------------------- 1 | require "sample_gem2/base" 2 | 3 | module SampleGem2 4 | def self.message 5 | "modified" 6 | end 7 | 8 | def self.test_message 9 | base = Base.new 10 | "lib: top-level:#{self.message}, sub-level:#{base.message}" 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /test/resources/rails31-app/lib/sample_gem2.original.rb: -------------------------------------------------------------------------------- 1 | require "sample_gem2/base" 2 | 3 | module SampleGem2 4 | def self.message 5 | "original" 6 | end 7 | 8 | def self.test_message 9 | base = Base.new 10 | "lib: top-level:#{self.message}, sub-level:#{base.message}" 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /test/resources/rails31-app/lib/sample_gem2.rb: -------------------------------------------------------------------------------- 1 | require "sample_gem2/base" 2 | 3 | module SampleGem2 4 | def self.message 5 | "original" 6 | end 7 | 8 | def self.test_message 9 | base = Base.new 10 | "lib: top-level:#{self.message}, sub-level:#{base.message}" 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /test/resources/rails31-app/lib/sample_gem2/base.modified.rb: -------------------------------------------------------------------------------- 1 | module SampleGem2 2 | class Base 3 | def message 4 | "modified" 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /test/resources/rails31-app/lib/sample_gem2/base.original.rb: -------------------------------------------------------------------------------- 1 | module SampleGem2 2 | class Base 3 | def message 4 | "original" 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /test/resources/rails31-app/lib/sample_gem2/base.rb: -------------------------------------------------------------------------------- 1 | module SampleGem2 2 | class Base 3 | def message 4 | "original" 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /test/resources/rails31-app/lib/tasks/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teohm/require_reloader/94add3de6bac904aaad00eb364037d7263d4ab5d/test/resources/rails31-app/lib/tasks/.gitkeep -------------------------------------------------------------------------------- /test/resources/rails31-app/lib/tasks/test.rake: -------------------------------------------------------------------------------- 1 | namespace :test do 2 | namespace :data do 3 | desc "Reset the codebase" 4 | task :reset do 5 | overwrite_codes_with!(:original) 6 | end 7 | 8 | desc "Modify the codebase" 9 | task :modify do 10 | overwrite_codes_with!(:modified) 11 | end 12 | 13 | def overwrite_codes_with!(type) 14 | require "fileutils" 15 | { 16 | "gems/sample_gem1/lib/sample_gem1.#{type}.rb" => "gems/sample_gem1/lib/sample_gem1.rb", 17 | "gems/sample_gem1/lib/sample_gem1/base.#{type}.rb" => "gems/sample_gem1/lib/sample_gem1/base.rb" 18 | }.each do |from, to| 19 | FileUtils.cp from, to 20 | end 21 | end 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /test/resources/rails31-app/log/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teohm/require_reloader/94add3de6bac904aaad00eb364037d7263d4ab5d/test/resources/rails31-app/log/.gitkeep -------------------------------------------------------------------------------- /test/resources/rails31-app/public/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The page you were looking for doesn't exist (404) 5 | 17 | 18 | 19 | 20 | 21 |
22 |

The page you were looking for doesn't exist.

23 |

You may have mistyped the address or the page may have moved.

24 |
25 | 26 | 27 | -------------------------------------------------------------------------------- /test/resources/rails31-app/public/422.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The change you wanted was rejected (422) 5 | 17 | 18 | 19 | 20 | 21 |
22 |

The change you wanted was rejected.

23 |

Maybe you tried to change something you didn't have access to.

24 |
25 | 26 | 27 | -------------------------------------------------------------------------------- /test/resources/rails31-app/public/500.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | We're sorry, but something went wrong (500) 5 | 17 | 18 | 19 | 20 | 21 |
22 |

We're sorry, but something went wrong.

23 |

We've been notified about this issue and we'll take a look at it shortly.

24 |
25 | 26 | 27 | -------------------------------------------------------------------------------- /test/resources/rails31-app/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teohm/require_reloader/94add3de6bac904aaad00eb364037d7263d4ab5d/test/resources/rails31-app/public/favicon.ico -------------------------------------------------------------------------------- /test/resources/rails31-app/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Ruby on Rails: Welcome aboard 5 | 174 | 187 | 188 | 189 |
190 | 203 | 204 |
205 | 209 | 210 | 214 | 215 |
216 |

Getting started

217 |

Here’s how to get rolling:

218 | 219 |
    220 |
  1. 221 |

    Use rails generate to create your models and controllers

    222 |

    To see all available options, run it without parameters.

    223 |
  2. 224 | 225 |
  3. 226 |

    Set up a default route and remove public/index.html

    227 |

    Routes are set up in config/routes.rb.

    228 |
  4. 229 | 230 |
  5. 231 |

    Create your database

    232 |

    Run rake db:create to create your database. If you're not using SQLite (the default), edit config/database.yml with your username and password.

    233 |
  6. 234 |
235 |
236 |
237 | 238 | 239 |
240 | 241 | 242 | -------------------------------------------------------------------------------- /test/resources/rails31-app/public/robots.txt: -------------------------------------------------------------------------------- 1 | # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file 2 | # 3 | # To ban all spiders from the entire site uncomment the next two lines: 4 | # User-Agent: * 5 | # Disallow: / 6 | -------------------------------------------------------------------------------- /test/resources/rails31-app/script/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. 3 | 4 | APP_PATH = File.expand_path('../../config/application', __FILE__) 5 | require File.expand_path('../../config/boot', __FILE__) 6 | require 'rails/commands' 7 | -------------------------------------------------------------------------------- /test/resources/rails31-app/test/fixtures/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teohm/require_reloader/94add3de6bac904aaad00eb364037d7263d4ab5d/test/resources/rails31-app/test/fixtures/.gitkeep -------------------------------------------------------------------------------- /test/resources/rails31-app/test/functional/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teohm/require_reloader/94add3de6bac904aaad00eb364037d7263d4ab5d/test/resources/rails31-app/test/functional/.gitkeep -------------------------------------------------------------------------------- /test/resources/rails31-app/test/integration/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teohm/require_reloader/94add3de6bac904aaad00eb364037d7263d4ab5d/test/resources/rails31-app/test/integration/.gitkeep -------------------------------------------------------------------------------- /test/resources/rails31-app/test/integration/reload_require_files_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class ReloadRequireFilesTest < ActionDispatch::IntegrationTest 4 | 5 | self.use_transactional_fixtures = false 6 | 7 | test "the truth" do 8 | overwrite_codes_with!(:original) 9 | 10 | get "/test.txt" 11 | assert_equal [ 12 | "local-gem: top-level:original, sub-level:original", 13 | "lib: top-level:original, sub-level:original" 14 | ].join("\n"), @response.body, "before modify codebase" 15 | 16 | overwrite_codes_with!(:modified) 17 | 18 | get "/test.txt" 19 | assert_equal [ 20 | "local-gem: top-level:modified, sub-level:modified", 21 | "lib: top-level:modified, sub-level:modified" 22 | ].join("\n"), @response.body, "after modify codebase" 23 | 24 | overwrite_codes_with!(:original) 25 | end 26 | 27 | def overwrite_codes_with!(type) 28 | require "fileutils" 29 | { 30 | "gems/sample_gem1/lib/sample_gem1.#{type}.rb" => "gems/sample_gem1/lib/sample_gem1.rb", 31 | "gems/sample_gem1/lib/sample_gem1/base.#{type}.rb" => "gems/sample_gem1/lib/sample_gem1/base.rb", 32 | "lib/sample_gem2.#{type}.rb" => "lib/sample_gem2.rb", 33 | "lib/sample_gem2/base.#{type}.rb" => "lib/sample_gem2/base.rb" 34 | }.each do |from, to| 35 | FileUtils.cp from, to 36 | end 37 | sleep 0.5 38 | end 39 | end 40 | -------------------------------------------------------------------------------- /test/resources/rails31-app/test/performance/browsing_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | require 'rails/performance_test_help' 3 | 4 | class BrowsingTest < ActionDispatch::PerformanceTest 5 | # Refer to the documentation for all available options 6 | # self.profile_options = { :runs => 5, :metrics => [:wall_time, :memory] 7 | # :output => 'tmp/performance', :formats => [:flat] } 8 | 9 | def test_homepage 10 | get '/' 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /test/resources/rails31-app/test/test_helper.rb: -------------------------------------------------------------------------------- 1 | ENV["RAILS_ENV"] = "development" 2 | require File.expand_path('../../config/environment', __FILE__) 3 | require 'rails/test_help' 4 | 5 | class ActiveSupport::TestCase 6 | # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order. 7 | # 8 | # Note: You'll currently still have to declare fixtures explicitly in integration tests 9 | # -- they do not yet inherit this setting 10 | fixtures :all 11 | 12 | # Add more helper methods to be used by all tests here... 13 | end 14 | -------------------------------------------------------------------------------- /test/resources/rails31-app/test/unit/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teohm/require_reloader/94add3de6bac904aaad00eb364037d7263d4ab5d/test/resources/rails31-app/test/unit/.gitkeep -------------------------------------------------------------------------------- /test/resources/rails31-app/vendor/assets/stylesheets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teohm/require_reloader/94add3de6bac904aaad00eb364037d7263d4ab5d/test/resources/rails31-app/vendor/assets/stylesheets/.gitkeep -------------------------------------------------------------------------------- /test/resources/rails31-app/vendor/plugins/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teohm/require_reloader/94add3de6bac904aaad00eb364037d7263d4ab5d/test/resources/rails31-app/vendor/plugins/.gitkeep -------------------------------------------------------------------------------- /test/resources/rails32-app/.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | # 3 | # If you find yourself ignoring temporary files generated by your text editor 4 | # or operating system, you probably want to add a global ignore instead: 5 | # git config --global core.excludesfile ~/.gitignore_global 6 | 7 | # Ignore bundler config 8 | #/.bundle 9 | 10 | # Ignore the default SQLite database. 11 | /db/*.sqlite3 12 | 13 | # Ignore all logfiles and tempfiles. 14 | /log/*.log 15 | /tmp 16 | -------------------------------------------------------------------------------- /test/resources/rails32-app/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gem 'rails', '3.2.11' 4 | 5 | # Bundle edge Rails instead: 6 | # gem 'rails', :git => 'git://github.com/rails/rails.git' 7 | 8 | gem 'sqlite3' 9 | 10 | gem 'sample_gem1', :path => 'gems/sample_gem1' 11 | gem 'sample_gem3', :path => 'vendor/gems/sample_gem3' 12 | gem 'require_reloader', :path => '../../..' 13 | 14 | gem 'progress_bar', :git => 'git://github.com/paul/progress_bar.git', 15 | :branch => 'master' 16 | 17 | gem 'haml-rails', :git => 'git://github.com/indirect/haml-rails.git', 18 | :ref => 'dad799d', :require => 'haml' 19 | 20 | # Gems used only for assets and not required 21 | # in production environments by default. 22 | group :assets do 23 | gem 'sass-rails', '~> 3.2.3' 24 | gem 'coffee-rails', '~> 3.2.1' 25 | 26 | # See https://github.com/sstephenson/execjs#readme for more supported runtimes 27 | # gem 'therubyracer', :platforms => :ruby 28 | 29 | gem 'uglifier', '>= 1.0.3' 30 | end 31 | 32 | gem 'jquery-rails' 33 | 34 | # To use ActiveModel has_secure_password 35 | # gem 'bcrypt-ruby', '~> 3.0.0' 36 | 37 | # To use Jbuilder templates for JSON 38 | # gem 'jbuilder' 39 | 40 | # Use unicorn as the app server 41 | # gem 'unicorn' 42 | 43 | # Deploy with Capistrano 44 | # gem 'capistrano' 45 | 46 | # To use debugger 47 | gem 'debugger' 48 | -------------------------------------------------------------------------------- /test/resources/rails32-app/README.rdoc: -------------------------------------------------------------------------------- 1 | == Welcome to Rails 2 | 3 | Rails is a web-application framework that includes everything needed to create 4 | database-backed web applications according to the Model-View-Control pattern. 5 | 6 | This pattern splits the view (also called the presentation) into "dumb" 7 | templates that are primarily responsible for inserting pre-built data in between 8 | HTML tags. The model contains the "smart" domain objects (such as Account, 9 | Product, Person, Post) that holds all the business logic and knows how to 10 | persist themselves to a database. The controller handles the incoming requests 11 | (such as Save New Account, Update Product, Show Post) by manipulating the model 12 | and directing data to the view. 13 | 14 | In Rails, the model is handled by what's called an object-relational mapping 15 | layer entitled Active Record. This layer allows you to present the data from 16 | database rows as objects and embellish these data objects with business logic 17 | methods. You can read more about Active Record in 18 | link:files/vendor/rails/activerecord/README.html. 19 | 20 | The controller and view are handled by the Action Pack, which handles both 21 | layers by its two parts: Action View and Action Controller. These two layers 22 | are bundled in a single package due to their heavy interdependence. This is 23 | unlike the relationship between the Active Record and Action Pack that is much 24 | more separate. Each of these packages can be used independently outside of 25 | Rails. You can read more about Action Pack in 26 | link:files/vendor/rails/actionpack/README.html. 27 | 28 | 29 | == Getting Started 30 | 31 | 1. At the command prompt, create a new Rails application: 32 | rails new myapp (where myapp is the application name) 33 | 34 | 2. Change directory to myapp and start the web server: 35 | cd myapp; rails server (run with --help for options) 36 | 37 | 3. Go to http://localhost:3000/ and you'll see: 38 | "Welcome aboard: You're riding Ruby on Rails!" 39 | 40 | 4. Follow the guidelines to start developing your application. You can find 41 | the following resources handy: 42 | 43 | * The Getting Started Guide: http://guides.rubyonrails.org/getting_started.html 44 | * Ruby on Rails Tutorial Book: http://www.railstutorial.org/ 45 | 46 | 47 | == Debugging Rails 48 | 49 | Sometimes your application goes wrong. Fortunately there are a lot of tools that 50 | will help you debug it and get it back on the rails. 51 | 52 | First area to check is the application log files. Have "tail -f" commands 53 | running on the server.log and development.log. Rails will automatically display 54 | debugging and runtime information to these files. Debugging info will also be 55 | shown in the browser on requests from 127.0.0.1. 56 | 57 | You can also log your own messages directly into the log file from your code 58 | using the Ruby logger class from inside your controllers. Example: 59 | 60 | class WeblogController < ActionController::Base 61 | def destroy 62 | @weblog = Weblog.find(params[:id]) 63 | @weblog.destroy 64 | logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!") 65 | end 66 | end 67 | 68 | The result will be a message in your log file along the lines of: 69 | 70 | Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1! 71 | 72 | More information on how to use the logger is at http://www.ruby-doc.org/core/ 73 | 74 | Also, Ruby documentation can be found at http://www.ruby-lang.org/. There are 75 | several books available online as well: 76 | 77 | * Programming Ruby: http://www.ruby-doc.org/docs/ProgrammingRuby/ (Pickaxe) 78 | * Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide) 79 | 80 | These two books will bring you up to speed on the Ruby language and also on 81 | programming in general. 82 | 83 | 84 | == Debugger 85 | 86 | Debugger support is available through the debugger command when you start your 87 | Mongrel or WEBrick server with --debugger. This means that you can break out of 88 | execution at any point in the code, investigate and change the model, and then, 89 | resume execution! You need to install ruby-debug to run the server in debugging 90 | mode. With gems, use sudo gem install ruby-debug. Example: 91 | 92 | class WeblogController < ActionController::Base 93 | def index 94 | @posts = Post.all 95 | debugger 96 | end 97 | end 98 | 99 | So the controller will accept the action, run the first line, then present you 100 | with a IRB prompt in the server window. Here you can do things like: 101 | 102 | >> @posts.inspect 103 | => "[#nil, "body"=>nil, "id"=>"1"}>, 105 | #"Rails", "body"=>"Only ten..", "id"=>"2"}>]" 107 | >> @posts.first.title = "hello from a debugger" 108 | => "hello from a debugger" 109 | 110 | ...and even better, you can examine how your runtime objects actually work: 111 | 112 | >> f = @posts.first 113 | => #nil, "body"=>nil, "id"=>"1"}> 114 | >> f. 115 | Display all 152 possibilities? (y or n) 116 | 117 | Finally, when you're ready to resume execution, you can enter "cont". 118 | 119 | 120 | == Console 121 | 122 | The console is a Ruby shell, which allows you to interact with your 123 | application's domain model. Here you'll have all parts of the application 124 | configured, just like it is when the application is running. You can inspect 125 | domain models, change values, and save to the database. Starting the script 126 | without arguments will launch it in the development environment. 127 | 128 | To start the console, run rails console from the application 129 | directory. 130 | 131 | Options: 132 | 133 | * Passing the -s, --sandbox argument will rollback any modifications 134 | made to the database. 135 | * Passing an environment name as an argument will load the corresponding 136 | environment. Example: rails console production. 137 | 138 | To reload your controllers and models after launching the console run 139 | reload! 140 | 141 | More information about irb can be found at: 142 | link:http://www.rubycentral.org/pickaxe/irb.html 143 | 144 | 145 | == dbconsole 146 | 147 | You can go to the command line of your database directly through rails 148 | dbconsole. You would be connected to the database with the credentials 149 | defined in database.yml. Starting the script without arguments will connect you 150 | to the development database. Passing an argument will connect you to a different 151 | database, like rails dbconsole production. Currently works for MySQL, 152 | PostgreSQL and SQLite 3. 153 | 154 | == Description of Contents 155 | 156 | The default directory structure of a generated Ruby on Rails application: 157 | 158 | |-- app 159 | | |-- assets 160 | | |-- images 161 | | |-- javascripts 162 | | `-- stylesheets 163 | | |-- controllers 164 | | |-- helpers 165 | | |-- mailers 166 | | |-- models 167 | | `-- views 168 | | `-- layouts 169 | |-- config 170 | | |-- environments 171 | | |-- initializers 172 | | `-- locales 173 | |-- db 174 | |-- doc 175 | |-- lib 176 | | `-- tasks 177 | |-- log 178 | |-- public 179 | |-- script 180 | |-- test 181 | | |-- fixtures 182 | | |-- functional 183 | | |-- integration 184 | | |-- performance 185 | | `-- unit 186 | |-- tmp 187 | | |-- cache 188 | | |-- pids 189 | | |-- sessions 190 | | `-- sockets 191 | `-- vendor 192 | |-- assets 193 | `-- stylesheets 194 | `-- plugins 195 | 196 | app 197 | Holds all the code that's specific to this particular application. 198 | 199 | app/assets 200 | Contains subdirectories for images, stylesheets, and JavaScript files. 201 | 202 | app/controllers 203 | Holds controllers that should be named like weblogs_controller.rb for 204 | automated URL mapping. All controllers should descend from 205 | ApplicationController which itself descends from ActionController::Base. 206 | 207 | app/models 208 | Holds models that should be named like post.rb. Models descend from 209 | ActiveRecord::Base by default. 210 | 211 | app/views 212 | Holds the template files for the view that should be named like 213 | weblogs/index.html.erb for the WeblogsController#index action. All views use 214 | eRuby syntax by default. 215 | 216 | app/views/layouts 217 | Holds the template files for layouts to be used with views. This models the 218 | common header/footer method of wrapping views. In your views, define a layout 219 | using the layout :default and create a file named default.html.erb. 220 | Inside default.html.erb, call <% yield %> to render the view using this 221 | layout. 222 | 223 | app/helpers 224 | Holds view helpers that should be named like weblogs_helper.rb. These are 225 | generated for you automatically when using generators for controllers. 226 | Helpers can be used to wrap functionality for your views into methods. 227 | 228 | config 229 | Configuration files for the Rails environment, the routing map, the database, 230 | and other dependencies. 231 | 232 | db 233 | Contains the database schema in schema.rb. db/migrate contains all the 234 | sequence of Migrations for your schema. 235 | 236 | doc 237 | This directory is where your application documentation will be stored when 238 | generated using rake doc:app 239 | 240 | lib 241 | Application specific libraries. Basically, any kind of custom code that 242 | doesn't belong under controllers, models, or helpers. This directory is in 243 | the load path. 244 | 245 | public 246 | The directory available for the web server. Also contains the dispatchers and the 247 | default HTML files. This should be set as the DOCUMENT_ROOT of your web 248 | server. 249 | 250 | script 251 | Helper scripts for automation and generation. 252 | 253 | test 254 | Unit and functional tests along with fixtures. When using the rails generate 255 | command, template test files will be generated for you and placed in this 256 | directory. 257 | 258 | vendor 259 | External libraries that the application depends on. Also includes the plugins 260 | subdirectory. If the app has frozen rails, those gems also go here, under 261 | vendor/rails/. This directory is in the load path. 262 | -------------------------------------------------------------------------------- /test/resources/rails32-app/Rakefile: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env rake 2 | # Add your own tasks in files placed in lib/tasks ending in .rake, 3 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 4 | 5 | require File.expand_path('../config/application', __FILE__) 6 | 7 | Rails32App::Application.load_tasks 8 | -------------------------------------------------------------------------------- /test/resources/rails32-app/app/assets/images/rails.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teohm/require_reloader/94add3de6bac904aaad00eb364037d7263d4ab5d/test/resources/rails32-app/app/assets/images/rails.png -------------------------------------------------------------------------------- /test/resources/rails32-app/app/assets/javascripts/application.js: -------------------------------------------------------------------------------- 1 | // This is a manifest file that'll be compiled into application.js, which will include all the files 2 | // listed below. 3 | // 4 | // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, 5 | // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. 6 | // 7 | // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the 8 | // the compiled file. 9 | // 10 | // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD 11 | // GO AFTER THE REQUIRES BELOW. 12 | // 13 | //= require jquery 14 | //= require jquery_ujs 15 | //= require_tree . 16 | -------------------------------------------------------------------------------- /test/resources/rails32-app/app/assets/stylesheets/application.css: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a manifest file that'll be compiled into application.css, which will include all the files 3 | * listed below. 4 | * 5 | * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, 6 | * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. 7 | * 8 | * You're free to add application-wide styles to this file and they'll appear at the top of the 9 | * compiled file, but it's generally better to create a new file per style scope. 10 | * 11 | *= require_self 12 | *= require_tree . 13 | */ 14 | -------------------------------------------------------------------------------- /test/resources/rails32-app/app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::Base 2 | protect_from_forgery 3 | end 4 | -------------------------------------------------------------------------------- /test/resources/rails32-app/app/controllers/test_controller.rb: -------------------------------------------------------------------------------- 1 | require 'sample_gem1' 2 | require 'sample_gem2' 3 | require 'sample_gem3' 4 | 5 | class TestController < ApplicationController 6 | def show 7 | messages = [ 8 | SampleGem1.test_message, 9 | SampleGem2.test_message, 10 | SampleGem3.test_message 11 | ] 12 | 13 | render :text => messages.join("\n") 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /test/resources/rails32-app/app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | end 3 | -------------------------------------------------------------------------------- /test/resources/rails32-app/app/mailers/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teohm/require_reloader/94add3de6bac904aaad00eb364037d7263d4ab5d/test/resources/rails32-app/app/mailers/.gitkeep -------------------------------------------------------------------------------- /test/resources/rails32-app/app/models/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teohm/require_reloader/94add3de6bac904aaad00eb364037d7263d4ab5d/test/resources/rails32-app/app/models/.gitkeep -------------------------------------------------------------------------------- /test/resources/rails32-app/app/views/layouts/application.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Rails32App 5 | <%= stylesheet_link_tag "application", :media => "all" %> 6 | <%= javascript_include_tag "application" %> 7 | <%= csrf_meta_tags %> 8 | 9 | 10 | 11 | <%= yield %> 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /test/resources/rails32-app/config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require ::File.expand_path('../config/environment', __FILE__) 4 | run Rails32App::Application 5 | -------------------------------------------------------------------------------- /test/resources/rails32-app/config/application.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../boot', __FILE__) 2 | 3 | require 'rails/all' 4 | 5 | if defined?(Bundler) 6 | # If you precompile assets before deploying to production, use this line 7 | Bundler.require(*Rails.groups(:assets => %w(development test))) 8 | # If you want your assets lazily compiled in production, use this line 9 | # Bundler.require(:default, :assets, Rails.env) 10 | end 11 | 12 | module Rails32App 13 | class Application < Rails::Application 14 | # Settings in config/environments/* take precedence over those specified here. 15 | # Application configuration should go into files in config/initializers 16 | # -- all .rb files in that directory are automatically loaded. 17 | 18 | # Custom directories with classes and modules you want to be autoloadable. 19 | # config.autoload_paths += %W(#{config.root}/extras) 20 | 21 | # Only load the plugins named here, in the order given (default is alphabetical). 22 | # :all can be used as a placeholder for all plugins not explicitly named. 23 | # config.plugins = [ :exception_notification, :ssl_requirement, :all ] 24 | 25 | # Activate observers that should always be running. 26 | # config.active_record.observers = :cacher, :garbage_collector, :forum_observer 27 | 28 | # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. 29 | # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. 30 | # config.time_zone = 'Central Time (US & Canada)' 31 | 32 | # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. 33 | # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] 34 | # config.i18n.default_locale = :de 35 | 36 | # Configure the default encoding used in templates for Ruby 1.9. 37 | config.encoding = "utf-8" 38 | 39 | # Configure sensitive parameters which will be filtered from the log file. 40 | config.filter_parameters += [:password] 41 | 42 | # Enable escaping HTML in JSON. 43 | config.active_support.escape_html_entities_in_json = true 44 | 45 | # Use SQL instead of Active Record's schema dumper when creating the database. 46 | # This is necessary if your schema can't be completely dumped by the schema dumper, 47 | # like if you have constraints or database-specific column types 48 | # config.active_record.schema_format = :sql 49 | 50 | # Enforce whitelist mode for mass assignment. 51 | # This will create an empty whitelist of attributes available for mass-assignment for all models 52 | # in your app. As such, your models will need to explicitly whitelist or blacklist accessible 53 | # parameters by using an attr_accessible or attr_protected declaration. 54 | config.active_record.whitelist_attributes = true 55 | 56 | # Enable the asset pipeline 57 | config.assets.enabled = true 58 | 59 | # Version of your assets, change this if you want to expire all your assets 60 | config.assets.version = '1.0' 61 | end 62 | end 63 | -------------------------------------------------------------------------------- /test/resources/rails32-app/config/boot.rb: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | 3 | # Set up gems listed in the Gemfile. 4 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 5 | 6 | require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE']) 7 | -------------------------------------------------------------------------------- /test/resources/rails32-app/config/database.yml: -------------------------------------------------------------------------------- 1 | # SQLite version 3.x 2 | # gem install sqlite3 3 | # 4 | # Ensure the SQLite 3 gem is defined in your Gemfile 5 | # gem 'sqlite3' 6 | development: 7 | adapter: sqlite3 8 | database: db/development.sqlite3 9 | pool: 5 10 | timeout: 5000 11 | 12 | # Warning: The database defined as "test" will be erased and 13 | # re-generated from your development database when you run "rake". 14 | # Do not set this db to the same as development or production. 15 | test: 16 | adapter: sqlite3 17 | database: db/test.sqlite3 18 | pool: 5 19 | timeout: 5000 20 | 21 | production: 22 | adapter: sqlite3 23 | database: db/production.sqlite3 24 | pool: 5 25 | timeout: 5000 26 | -------------------------------------------------------------------------------- /test/resources/rails32-app/config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the rails application 2 | require File.expand_path('../application', __FILE__) 3 | 4 | # Initialize the rails application 5 | Rails32App::Application.initialize! 6 | -------------------------------------------------------------------------------- /test/resources/rails32-app/config/environments/development.rb: -------------------------------------------------------------------------------- 1 | Rails32App::Application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb 3 | 4 | # In the development environment your application's code is reloaded on 5 | # every request. This slows down response time but is perfect for development 6 | # since you don't have to restart the web server when you make code changes. 7 | config.cache_classes = false 8 | 9 | # Log error messages when you accidentally call methods on nil. 10 | config.whiny_nils = true 11 | 12 | # Show full error reports and disable caching 13 | config.consider_all_requests_local = true 14 | config.action_controller.perform_caching = false 15 | 16 | # Don't care if the mailer can't send 17 | config.action_mailer.raise_delivery_errors = false 18 | 19 | # Print deprecation notices to the Rails logger 20 | config.active_support.deprecation = :log 21 | 22 | # Only use best-standards-support built into browsers 23 | config.action_dispatch.best_standards_support = :builtin 24 | 25 | # Raise exception on mass assignment protection for Active Record models 26 | config.active_record.mass_assignment_sanitizer = :strict 27 | 28 | # Log the query plan for queries taking more than this (works 29 | # with SQLite, MySQL, and PostgreSQL) 30 | config.active_record.auto_explain_threshold_in_seconds = 0.5 31 | 32 | # Do not compress assets 33 | config.assets.compress = false 34 | 35 | # Expands the lines which load the assets 36 | config.assets.debug = true 37 | 38 | RequireReloader.watch_local_gems! 39 | RequireReloader.watch :sample_gem2 40 | 41 | end 42 | -------------------------------------------------------------------------------- /test/resources/rails32-app/config/environments/production.rb: -------------------------------------------------------------------------------- 1 | Rails32App::Application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb 3 | 4 | # Code is not reloaded between requests 5 | config.cache_classes = true 6 | 7 | # Full error reports are disabled and caching is turned on 8 | config.consider_all_requests_local = false 9 | config.action_controller.perform_caching = true 10 | 11 | # Disable Rails's static asset server (Apache or nginx will already do this) 12 | config.serve_static_assets = false 13 | 14 | # Compress JavaScripts and CSS 15 | config.assets.compress = true 16 | 17 | # Don't fallback to assets pipeline if a precompiled asset is missed 18 | config.assets.compile = false 19 | 20 | # Generate digests for assets URLs 21 | config.assets.digest = true 22 | 23 | # Defaults to nil and saved in location specified by config.assets.prefix 24 | # config.assets.manifest = YOUR_PATH 25 | 26 | # Specifies the header that your server uses for sending files 27 | # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache 28 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx 29 | 30 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. 31 | # config.force_ssl = true 32 | 33 | # See everything in the log (default is :info) 34 | # config.log_level = :debug 35 | 36 | # Prepend all log lines with the following tags 37 | # config.log_tags = [ :subdomain, :uuid ] 38 | 39 | # Use a different logger for distributed setups 40 | # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) 41 | 42 | # Use a different cache store in production 43 | # config.cache_store = :mem_cache_store 44 | 45 | # Enable serving of images, stylesheets, and JavaScripts from an asset server 46 | # config.action_controller.asset_host = "http://assets.example.com" 47 | 48 | # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added) 49 | # config.assets.precompile += %w( search.js ) 50 | 51 | # Disable delivery errors, bad email addresses will be ignored 52 | # config.action_mailer.raise_delivery_errors = false 53 | 54 | # Enable threaded mode 55 | # config.threadsafe! 56 | 57 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to 58 | # the I18n.default_locale when a translation can not be found) 59 | config.i18n.fallbacks = true 60 | 61 | # Send deprecation notices to registered listeners 62 | config.active_support.deprecation = :notify 63 | 64 | # Log the query plan for queries taking more than this (works 65 | # with SQLite, MySQL, and PostgreSQL) 66 | # config.active_record.auto_explain_threshold_in_seconds = 0.5 67 | end 68 | -------------------------------------------------------------------------------- /test/resources/rails32-app/config/environments/test.rb: -------------------------------------------------------------------------------- 1 | Rails32App::Application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb 3 | 4 | # The test environment is used exclusively to run your application's 5 | # test suite. You never need to work with it otherwise. Remember that 6 | # your test database is "scratch space" for the test suite and is wiped 7 | # and recreated between test runs. Don't rely on the data there! 8 | #config.cache_classes = true 9 | config.cache_classes = false 10 | 11 | # Configure static asset server for tests with Cache-Control for performance 12 | config.serve_static_assets = true 13 | config.static_cache_control = "public, max-age=3600" 14 | 15 | # Log error messages when you accidentally call methods on nil 16 | config.whiny_nils = true 17 | 18 | # Show full error reports and disable caching 19 | config.consider_all_requests_local = true 20 | config.action_controller.perform_caching = false 21 | 22 | # Raise exceptions instead of rendering exception templates 23 | config.action_dispatch.show_exceptions = false 24 | 25 | # Disable request forgery protection in test environment 26 | config.action_controller.allow_forgery_protection = false 27 | 28 | # Tell Action Mailer not to deliver emails to the real world. 29 | # The :test delivery method accumulates sent emails in the 30 | # ActionMailer::Base.deliveries array. 31 | config.action_mailer.delivery_method = :test 32 | 33 | # Raise exception on mass assignment protection for Active Record models 34 | config.active_record.mass_assignment_sanitizer = :strict 35 | 36 | # Print deprecation notices to the stderr 37 | config.active_support.deprecation = :stderr 38 | end 39 | -------------------------------------------------------------------------------- /test/resources/rails32-app/config/initializers/backtrace_silencers.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. 4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } 5 | 6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. 7 | # Rails.backtrace_cleaner.remove_silencers! 8 | -------------------------------------------------------------------------------- /test/resources/rails32-app/config/initializers/inflections.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new inflection rules using the following format 4 | # (all these examples are active by default): 5 | # ActiveSupport::Inflector.inflections do |inflect| 6 | # inflect.plural /^(ox)$/i, '\1en' 7 | # inflect.singular /^(ox)en/i, '\1' 8 | # inflect.irregular 'person', 'people' 9 | # inflect.uncountable %w( fish sheep ) 10 | # end 11 | # 12 | # These inflection rules are supported but not enabled by default: 13 | # ActiveSupport::Inflector.inflections do |inflect| 14 | # inflect.acronym 'RESTful' 15 | # end 16 | -------------------------------------------------------------------------------- /test/resources/rails32-app/config/initializers/mime_types.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new mime types for use in respond_to blocks: 4 | # Mime::Type.register "text/richtext", :rtf 5 | # Mime::Type.register_alias "text/html", :iphone 6 | -------------------------------------------------------------------------------- /test/resources/rails32-app/config/initializers/secret_token.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Your secret key for verifying the integrity of signed cookies. 4 | # If you change this key, all old signed cookies will become invalid! 5 | # Make sure the secret is at least 30 characters and all random, 6 | # no regular words or you'll be exposed to dictionary attacks. 7 | Rails32App::Application.config.secret_token = '2c99bdd99cfdce159fc07f0d4fef99e2e2834e041e9e57e8cd6e73d8d357429b6457e3831d76c42bfc8f8f96eb8d011eb6e624d81cb65c14daf38c59959ad5ae' 8 | -------------------------------------------------------------------------------- /test/resources/rails32-app/config/initializers/session_store.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails32App::Application.config.session_store :cookie_store, key: '_rails32-app_session' 4 | 5 | # Use the database for sessions instead of the cookie-based default, 6 | # which shouldn't be used to store highly confidential information 7 | # (create the session table with "rails generate session_migration") 8 | # Rails32App::Application.config.session_store :active_record_store 9 | -------------------------------------------------------------------------------- /test/resources/rails32-app/config/initializers/wrap_parameters.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | # 3 | # This file contains settings for ActionController::ParamsWrapper which 4 | # is enabled by default. 5 | 6 | # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. 7 | ActiveSupport.on_load(:action_controller) do 8 | wrap_parameters format: [:json] 9 | end 10 | 11 | # Disable root element in JSON by default. 12 | ActiveSupport.on_load(:active_record) do 13 | self.include_root_in_json = false 14 | end 15 | -------------------------------------------------------------------------------- /test/resources/rails32-app/config/locales/en.yml: -------------------------------------------------------------------------------- 1 | # Sample localization file for English. Add more files in this directory for other locales. 2 | # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. 3 | 4 | en: 5 | hello: "Hello world" 6 | -------------------------------------------------------------------------------- /test/resources/rails32-app/config/routes.rb: -------------------------------------------------------------------------------- 1 | Rails32App::Application.routes.draw do 2 | match 'test' => 'test#show', :via => :get 3 | 4 | # The priority is based upon order of creation: 5 | # first created -> highest priority. 6 | 7 | # Sample of regular route: 8 | # match 'products/:id' => 'catalog#view' 9 | # Keep in mind you can assign values other than :controller and :action 10 | 11 | # Sample of named route: 12 | # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase 13 | # This route can be invoked with purchase_url(:id => product.id) 14 | 15 | # Sample resource route (maps HTTP verbs to controller actions automatically): 16 | # resources :products 17 | 18 | # Sample resource route with options: 19 | # resources :products do 20 | # member do 21 | # get 'short' 22 | # post 'toggle' 23 | # end 24 | # 25 | # collection do 26 | # get 'sold' 27 | # end 28 | # end 29 | 30 | # Sample resource route with sub-resources: 31 | # resources :products do 32 | # resources :comments, :sales 33 | # resource :seller 34 | # end 35 | 36 | # Sample resource route with more complex sub-resources 37 | # resources :products do 38 | # resources :comments 39 | # resources :sales do 40 | # get 'recent', :on => :collection 41 | # end 42 | # end 43 | 44 | # Sample resource route within a namespace: 45 | # namespace :admin do 46 | # # Directs /admin/products/* to Admin::ProductsController 47 | # # (app/controllers/admin/products_controller.rb) 48 | # resources :products 49 | # end 50 | 51 | # You can have the root of your site routed with "root" 52 | # just remember to delete public/index.html. 53 | # root :to => 'welcome#index' 54 | 55 | # See how all your routes lay out with "rake routes" 56 | 57 | # This is a legacy wild controller route that's not recommended for RESTful applications. 58 | # Note: This route will make all actions in every controller accessible via GET requests. 59 | # match ':controller(/:action(/:id))(.:format)' 60 | end 61 | -------------------------------------------------------------------------------- /test/resources/rails32-app/db/schema.rb: -------------------------------------------------------------------------------- 1 | # encoding: UTF-8 2 | # This file is auto-generated from the current state of the database. Instead 3 | # of editing this file, please use the migrations feature of Active Record to 4 | # incrementally modify your database, and then regenerate this schema definition. 5 | # 6 | # Note that this schema.rb definition is the authoritative source for your 7 | # database schema. If you need to create the application database on another 8 | # system, you should be using db:schema:load, not running all the migrations 9 | # from scratch. The latter is a flawed and unsustainable approach (the more migrations 10 | # you'll amass, the slower it'll run and the greater likelihood for issues). 11 | # 12 | # It's strongly recommended to check this file into your version control system. 13 | 14 | ActiveRecord::Schema.define(:version => 0) do 15 | 16 | end 17 | -------------------------------------------------------------------------------- /test/resources/rails32-app/db/seeds.rb: -------------------------------------------------------------------------------- 1 | # This file should contain all the record creation needed to seed the database with its default values. 2 | # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). 3 | # 4 | # Examples: 5 | # 6 | # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) 7 | # Mayor.create(name: 'Emanuel', city: cities.first) 8 | -------------------------------------------------------------------------------- /test/resources/rails32-app/gems/sample_gem1/.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | *.rbc 3 | .bundle 4 | .config 5 | .yardoc 6 | Gemfile.lock 7 | InstalledFiles 8 | _yardoc 9 | coverage 10 | doc/ 11 | lib/bundler/man 12 | pkg 13 | rdoc 14 | spec/reports 15 | test/tmp 16 | test/version_tmp 17 | tmp 18 | -------------------------------------------------------------------------------- /test/resources/rails32-app/gems/sample_gem1/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | # Specify your gem's dependencies in sample_gem1.gemspec 4 | gemspec 5 | -------------------------------------------------------------------------------- /test/resources/rails32-app/gems/sample_gem1/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 Huiming Teo 2 | 3 | MIT License 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /test/resources/rails32-app/gems/sample_gem1/README.md: -------------------------------------------------------------------------------- 1 | # SampleGem1 2 | 3 | TODO: Write a gem description 4 | 5 | ## Installation 6 | 7 | Add this line to your application's Gemfile: 8 | 9 | gem 'sample_gem1' 10 | 11 | And then execute: 12 | 13 | $ bundle 14 | 15 | Or install it yourself as: 16 | 17 | $ gem install sample_gem1 18 | 19 | ## Usage 20 | 21 | TODO: Write usage instructions here 22 | 23 | ## Contributing 24 | 25 | 1. Fork it 26 | 2. Create your feature branch (`git checkout -b my-new-feature`) 27 | 3. Commit your changes (`git commit -am 'Add some feature'`) 28 | 4. Push to the branch (`git push origin my-new-feature`) 29 | 5. Create new Pull Request 30 | -------------------------------------------------------------------------------- /test/resources/rails32-app/gems/sample_gem1/Rakefile: -------------------------------------------------------------------------------- 1 | require "bundler/gem_tasks" 2 | 3 | namespace :test do 4 | namespace :data do 5 | desc "Reset the codebase" 6 | task :reset do 7 | overwrite_codes_with!(:original) 8 | end 9 | 10 | desc "Modify the codebase" 11 | task :modify do 12 | overwrite_codes_with!(:modified) 13 | end 14 | 15 | def overwrite_codes_with!(type) 16 | require "fileutils" 17 | { 18 | "lib/sample_gem1.#{type}.rb" => "lib/sample_gem1.rb", 19 | "lib/sample_gem1/base.#{type}.rb" => "lib/sample_gem1/base.rb" 20 | }.each do |from, to| 21 | FileUtils.cp from, to 22 | end 23 | end 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /test/resources/rails32-app/gems/sample_gem1/lib/sample_gem1.modified.rb: -------------------------------------------------------------------------------- 1 | require "sample_gem1/version" 2 | require "sample_gem1/base" 3 | 4 | module SampleGem1 5 | def self.message 6 | "modified" 7 | end 8 | 9 | def self.test_message 10 | base = Base.new 11 | "local-gem: top-level:#{self.message}, sub-level:#{base.message}" 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /test/resources/rails32-app/gems/sample_gem1/lib/sample_gem1.original.rb: -------------------------------------------------------------------------------- 1 | require "sample_gem1/version" 2 | require "sample_gem1/base" 3 | 4 | module SampleGem1 5 | def self.message 6 | "original" 7 | end 8 | 9 | def self.test_message 10 | base = Base.new 11 | "local-gem: top-level:#{self.message}, sub-level:#{base.message}" 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /test/resources/rails32-app/gems/sample_gem1/lib/sample_gem1.rb: -------------------------------------------------------------------------------- 1 | require "sample_gem1/version" 2 | require "sample_gem1/base" 3 | 4 | module SampleGem1 5 | def self.message 6 | "original" 7 | end 8 | 9 | def self.test_message 10 | base = Base.new 11 | "local-gem: top-level:#{self.message}, sub-level:#{base.message}" 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /test/resources/rails32-app/gems/sample_gem1/lib/sample_gem1/base.modified.rb: -------------------------------------------------------------------------------- 1 | module SampleGem1 2 | class Base 3 | def message 4 | "modified" 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /test/resources/rails32-app/gems/sample_gem1/lib/sample_gem1/base.original.rb: -------------------------------------------------------------------------------- 1 | module SampleGem1 2 | class Base 3 | def message 4 | "original" 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /test/resources/rails32-app/gems/sample_gem1/lib/sample_gem1/base.rb: -------------------------------------------------------------------------------- 1 | module SampleGem1 2 | class Base 3 | def message 4 | "original" 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /test/resources/rails32-app/gems/sample_gem1/lib/sample_gem1/version.rb: -------------------------------------------------------------------------------- 1 | module SampleGem1 2 | VERSION = "0.0.1" 3 | end 4 | -------------------------------------------------------------------------------- /test/resources/rails32-app/gems/sample_gem1/sample_gem1.gemspec: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | lib = File.expand_path('../lib', __FILE__) 3 | $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) 4 | require 'sample_gem1/version' 5 | 6 | Gem::Specification.new do |gem| 7 | gem.name = "sample_gem1" 8 | gem.version = SampleGem1::VERSION 9 | gem.authors = ["Huiming Teo"] 10 | gem.email = ["teohuiming@gmail.com"] 11 | gem.description = %q{TODO: Write a gem description} 12 | gem.summary = %q{TODO: Write a gem summary} 13 | gem.homepage = "" 14 | 15 | gem.files = `git ls-files`.split($/) 16 | gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) } 17 | gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) 18 | gem.require_paths = ["lib"] 19 | end 20 | -------------------------------------------------------------------------------- /test/resources/rails32-app/lib/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teohm/require_reloader/94add3de6bac904aaad00eb364037d7263d4ab5d/test/resources/rails32-app/lib/assets/.gitkeep -------------------------------------------------------------------------------- /test/resources/rails32-app/lib/sample_gem2.modified.rb: -------------------------------------------------------------------------------- 1 | require "sample_gem2/base" 2 | 3 | module SampleGem2 4 | def self.message 5 | "modified" 6 | end 7 | 8 | def self.test_message 9 | base = Base.new 10 | "lib: top-level:#{self.message}, sub-level:#{base.message}" 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /test/resources/rails32-app/lib/sample_gem2.original.rb: -------------------------------------------------------------------------------- 1 | require "sample_gem2/base" 2 | 3 | module SampleGem2 4 | def self.message 5 | "original" 6 | end 7 | 8 | def self.test_message 9 | base = Base.new 10 | "lib: top-level:#{self.message}, sub-level:#{base.message}" 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /test/resources/rails32-app/lib/sample_gem2.rb: -------------------------------------------------------------------------------- 1 | require "sample_gem2/base" 2 | 3 | module SampleGem2 4 | def self.message 5 | "original" 6 | end 7 | 8 | def self.test_message 9 | base = Base.new 10 | "lib: top-level:#{self.message}, sub-level:#{base.message}" 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /test/resources/rails32-app/lib/sample_gem2/base.modified.rb: -------------------------------------------------------------------------------- 1 | module SampleGem2 2 | class Base 3 | def message 4 | "modified" 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /test/resources/rails32-app/lib/sample_gem2/base.original.rb: -------------------------------------------------------------------------------- 1 | module SampleGem2 2 | class Base 3 | def message 4 | "original" 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /test/resources/rails32-app/lib/sample_gem2/base.rb: -------------------------------------------------------------------------------- 1 | module SampleGem2 2 | class Base 3 | def message 4 | "original" 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /test/resources/rails32-app/lib/tasks/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teohm/require_reloader/94add3de6bac904aaad00eb364037d7263d4ab5d/test/resources/rails32-app/lib/tasks/.gitkeep -------------------------------------------------------------------------------- /test/resources/rails32-app/lib/tasks/test.rake: -------------------------------------------------------------------------------- 1 | namespace :test do 2 | namespace :data do 3 | desc "Reset the codebase" 4 | task :reset do 5 | overwrite_codes_with!(:original) 6 | end 7 | 8 | desc "Modify the codebase" 9 | task :modify do 10 | overwrite_codes_with!(:modified) 11 | end 12 | 13 | def overwrite_codes_with!(type) 14 | require "fileutils" 15 | { 16 | "gems/sample_gem1/lib/sample_gem1.#{type}.rb" => "gems/sample_gem1/lib/sample_gem1.rb", 17 | "gems/sample_gem1/lib/sample_gem1/base.#{type}.rb" => "gems/sample_gem1/lib/sample_gem1/base.rb" 18 | }.each do |from, to| 19 | FileUtils.cp from, to 20 | end 21 | end 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /test/resources/rails32-app/log/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teohm/require_reloader/94add3de6bac904aaad00eb364037d7263d4ab5d/test/resources/rails32-app/log/.gitkeep -------------------------------------------------------------------------------- /test/resources/rails32-app/public/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The page you were looking for doesn't exist (404) 5 | 17 | 18 | 19 | 20 | 21 |
22 |

The page you were looking for doesn't exist.

23 |

You may have mistyped the address or the page may have moved.

24 |
25 | 26 | 27 | -------------------------------------------------------------------------------- /test/resources/rails32-app/public/422.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The change you wanted was rejected (422) 5 | 17 | 18 | 19 | 20 | 21 |
22 |

The change you wanted was rejected.

23 |

Maybe you tried to change something you didn't have access to.

24 |
25 | 26 | 27 | -------------------------------------------------------------------------------- /test/resources/rails32-app/public/500.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | We're sorry, but something went wrong (500) 5 | 17 | 18 | 19 | 20 | 21 |
22 |

We're sorry, but something went wrong.

23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /test/resources/rails32-app/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teohm/require_reloader/94add3de6bac904aaad00eb364037d7263d4ab5d/test/resources/rails32-app/public/favicon.ico -------------------------------------------------------------------------------- /test/resources/rails32-app/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Ruby on Rails: Welcome aboard 5 | 174 | 187 | 188 | 189 |
190 | 203 | 204 |
205 | 209 | 210 | 214 | 215 |
216 |

Getting started

217 |

Here’s how to get rolling:

218 | 219 |
    220 |
  1. 221 |

    Use rails generate to create your models and controllers

    222 |

    To see all available options, run it without parameters.

    223 |
  2. 224 | 225 |
  3. 226 |

    Set up a default route and remove public/index.html

    227 |

    Routes are set up in config/routes.rb.

    228 |
  4. 229 | 230 |
  5. 231 |

    Create your database

    232 |

    Run rake db:create to create your database. If you're not using SQLite (the default), edit config/database.yml with your username and password.

    233 |
  6. 234 |
235 |
236 |
237 | 238 | 239 |
240 | 241 | 242 | -------------------------------------------------------------------------------- /test/resources/rails32-app/public/robots.txt: -------------------------------------------------------------------------------- 1 | # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file 2 | # 3 | # To ban all spiders from the entire site uncomment the next two lines: 4 | # User-Agent: * 5 | # Disallow: / 6 | -------------------------------------------------------------------------------- /test/resources/rails32-app/script/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. 3 | 4 | APP_PATH = File.expand_path('../../config/application', __FILE__) 5 | require File.expand_path('../../config/boot', __FILE__) 6 | require 'rails/commands' 7 | -------------------------------------------------------------------------------- /test/resources/rails32-app/test/fixtures/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teohm/require_reloader/94add3de6bac904aaad00eb364037d7263d4ab5d/test/resources/rails32-app/test/fixtures/.gitkeep -------------------------------------------------------------------------------- /test/resources/rails32-app/test/functional/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teohm/require_reloader/94add3de6bac904aaad00eb364037d7263d4ab5d/test/resources/rails32-app/test/functional/.gitkeep -------------------------------------------------------------------------------- /test/resources/rails32-app/test/integration/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teohm/require_reloader/94add3de6bac904aaad00eb364037d7263d4ab5d/test/resources/rails32-app/test/integration/.gitkeep -------------------------------------------------------------------------------- /test/resources/rails32-app/test/integration/reload_require_files_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class ReloadRequireFilesTest < ActionDispatch::IntegrationTest 4 | 5 | self.use_transactional_fixtures = false 6 | 7 | test "the truth" do 8 | overwrite_codes_with!(:original) 9 | 10 | get "/test.txt" 11 | assert_equal [ 12 | "local-gem: top-level:original, sub-level:original", 13 | "lib: top-level:original, sub-level:original", 14 | "vendor/gems: top-level:original, sub-level:original" 15 | ].join("\n"), @response.body, "before modify codebase" 16 | 17 | overwrite_codes_with!(:modified) 18 | 19 | get "/test.txt" 20 | assert_equal [ 21 | "local-gem: top-level:modified, sub-level:modified", 22 | "lib: top-level:modified, sub-level:modified", 23 | "vendor/gems: top-level:modified, sub-level:modified", 24 | ].join("\n"), @response.body, "after modify codebase" 25 | 26 | overwrite_codes_with!(:original) 27 | end 28 | 29 | def overwrite_codes_with!(type) 30 | require "fileutils" 31 | { 32 | "gems/sample_gem1/lib/sample_gem1.#{type}.rb" => "gems/sample_gem1/lib/sample_gem1.rb", 33 | "gems/sample_gem1/lib/sample_gem1/base.#{type}.rb" => "gems/sample_gem1/lib/sample_gem1/base.rb", 34 | "lib/sample_gem2.#{type}.rb" => "lib/sample_gem2.rb", 35 | "lib/sample_gem2/base.#{type}.rb" => "lib/sample_gem2/base.rb", 36 | "vendor/gems/sample_gem3/lib/sample_gem3.#{type}.rb" => "vendor/gems/sample_gem3/lib/sample_gem3.rb", 37 | "vendor/gems/sample_gem3/lib/sample_gem3/base.#{type}.rb" => "vendor/gems/sample_gem3/lib/sample_gem3/base.rb", 38 | }.each do |from, to| 39 | FileUtils.cp from, to 40 | end 41 | sleep 0.5 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /test/resources/rails32-app/test/performance/browsing_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | require 'rails/performance_test_help' 3 | 4 | class BrowsingTest < ActionDispatch::PerformanceTest 5 | # Refer to the documentation for all available options 6 | # self.profile_options = { :runs => 5, :metrics => [:wall_time, :memory] 7 | # :output => 'tmp/performance', :formats => [:flat] } 8 | 9 | def test_homepage 10 | get '/' 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /test/resources/rails32-app/test/test_helper.rb: -------------------------------------------------------------------------------- 1 | #ENV["RAILS_ENV"] = "test" 2 | ENV["RAILS_ENV"] = "development" 3 | require File.expand_path('../../config/environment', __FILE__) 4 | require 'rails/test_help' 5 | #require 'capybara/rails' 6 | 7 | class ActiveSupport::TestCase 8 | # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order. 9 | # 10 | # Note: You'll currently still have to declare fixtures explicitly in integration tests 11 | # -- they do not yet inherit this setting 12 | #fixtures :all 13 | 14 | # Add more helper methods to be used by all tests here... 15 | end 16 | -------------------------------------------------------------------------------- /test/resources/rails32-app/test/unit/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teohm/require_reloader/94add3de6bac904aaad00eb364037d7263d4ab5d/test/resources/rails32-app/test/unit/.gitkeep -------------------------------------------------------------------------------- /test/resources/rails32-app/vendor/assets/javascripts/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teohm/require_reloader/94add3de6bac904aaad00eb364037d7263d4ab5d/test/resources/rails32-app/vendor/assets/javascripts/.gitkeep -------------------------------------------------------------------------------- /test/resources/rails32-app/vendor/assets/stylesheets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teohm/require_reloader/94add3de6bac904aaad00eb364037d7263d4ab5d/test/resources/rails32-app/vendor/assets/stylesheets/.gitkeep -------------------------------------------------------------------------------- /test/resources/rails32-app/vendor/gems/sample_gem3/.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | *.rbc 3 | .bundle 4 | .config 5 | .yardoc 6 | Gemfile.lock 7 | InstalledFiles 8 | _yardoc 9 | coverage 10 | doc/ 11 | lib/bundler/man 12 | pkg 13 | rdoc 14 | spec/reports 15 | test/tmp 16 | test/version_tmp 17 | tmp 18 | -------------------------------------------------------------------------------- /test/resources/rails32-app/vendor/gems/sample_gem3/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | # Specify your gem's dependencies in sample_gem1.gemspec 4 | gemspec 5 | -------------------------------------------------------------------------------- /test/resources/rails32-app/vendor/gems/sample_gem3/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 Huiming Teo 2 | 3 | MIT License 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /test/resources/rails32-app/vendor/gems/sample_gem3/README.md: -------------------------------------------------------------------------------- 1 | # SampleGem3 2 | 3 | TODO: Write a gem description 4 | 5 | ## Installation 6 | 7 | Add this line to your application's Gemfile: 8 | 9 | gem 'sample_gem3' 10 | 11 | And then execute: 12 | 13 | $ bundle 14 | 15 | Or install it yourself as: 16 | 17 | $ gem install sample_gem3 18 | 19 | ## Usage 20 | 21 | TODO: Write usage instructions here 22 | 23 | ## Contributing 24 | 25 | 1. Fork it 26 | 2. Create your feature branch (`git checkout -b my-new-feature`) 27 | 3. Commit your changes (`git commit -am 'Add some feature'`) 28 | 4. Push to the branch (`git push origin my-new-feature`) 29 | 5. Create new Pull Request 30 | -------------------------------------------------------------------------------- /test/resources/rails32-app/vendor/gems/sample_gem3/Rakefile: -------------------------------------------------------------------------------- 1 | require "bundler/gem_tasks" 2 | 3 | namespace :test do 4 | namespace :data do 5 | desc "Reset the codebase" 6 | task :reset do 7 | overwrite_codes_with!(:original) 8 | end 9 | 10 | desc "Modify the codebase" 11 | task :modify do 12 | overwrite_codes_with!(:modified) 13 | end 14 | 15 | def overwrite_codes_with!(type) 16 | require "fileutils" 17 | { 18 | "lib/sample_gem3.#{type}.rb" => "lib/sample_gem3.rb", 19 | "lib/sample_gem3/base.#{type}.rb" => "lib/sample_gem3/base.rb" 20 | }.each do |from, to| 21 | FileUtils.cp from, to 22 | end 23 | end 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /test/resources/rails32-app/vendor/gems/sample_gem3/lib/sample_gem3.modified.rb: -------------------------------------------------------------------------------- 1 | require "sample_gem3/version" 2 | require "sample_gem3/base" 3 | 4 | module SampleGem3 5 | def self.message 6 | "modified" 7 | end 8 | 9 | def self.test_message 10 | base = Base.new 11 | "vendor/gems: top-level:#{self.message}, sub-level:#{base.message}" 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /test/resources/rails32-app/vendor/gems/sample_gem3/lib/sample_gem3.original.rb: -------------------------------------------------------------------------------- 1 | require "sample_gem3/version" 2 | require "sample_gem3/base" 3 | 4 | module SampleGem3 5 | def self.message 6 | "original" 7 | end 8 | 9 | def self.test_message 10 | base = Base.new 11 | "vendor/gems: top-level:#{self.message}, sub-level:#{base.message}" 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /test/resources/rails32-app/vendor/gems/sample_gem3/lib/sample_gem3.rb: -------------------------------------------------------------------------------- 1 | require "sample_gem3/version" 2 | require "sample_gem3/base" 3 | 4 | module SampleGem3 5 | def self.message 6 | "original" 7 | end 8 | 9 | def self.test_message 10 | base = Base.new 11 | "vendor/gems: top-level:#{self.message}, sub-level:#{base.message}" 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /test/resources/rails32-app/vendor/gems/sample_gem3/lib/sample_gem3/base.modified.rb: -------------------------------------------------------------------------------- 1 | module SampleGem3 2 | class Base 3 | def message 4 | "modified" 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /test/resources/rails32-app/vendor/gems/sample_gem3/lib/sample_gem3/base.original.rb: -------------------------------------------------------------------------------- 1 | module SampleGem3 2 | class Base 3 | def message 4 | "original" 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /test/resources/rails32-app/vendor/gems/sample_gem3/lib/sample_gem3/base.rb: -------------------------------------------------------------------------------- 1 | module SampleGem3 2 | class Base 3 | def message 4 | "original" 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /test/resources/rails32-app/vendor/gems/sample_gem3/lib/sample_gem3/version.rb: -------------------------------------------------------------------------------- 1 | module SampleGem3 2 | VERSION = "0.0.1" 3 | end 4 | -------------------------------------------------------------------------------- /test/resources/rails32-app/vendor/gems/sample_gem3/sample_gem3.gemspec: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | lib = File.expand_path('../lib', __FILE__) 3 | $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) 4 | require 'sample_gem3/version' 5 | 6 | Gem::Specification.new do |gem| 7 | gem.name = "sample_gem3" 8 | gem.version = SampleGem3::VERSION 9 | gem.authors = ["Huiming Teo"] 10 | gem.email = ["teohuiming@gmail.com"] 11 | gem.description = %q{TODO: Write a gem description} 12 | gem.summary = %q{TODO: Write a gem summary} 13 | gem.homepage = "" 14 | 15 | gem.files = `git ls-files`.split($/) 16 | gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) } 17 | gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) 18 | gem.require_paths = ["lib"] 19 | end 20 | -------------------------------------------------------------------------------- /test/resources/rails32-app/vendor/plugins/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teohm/require_reloader/94add3de6bac904aaad00eb364037d7263d4ab5d/test/resources/rails32-app/vendor/plugins/.gitkeep --------------------------------------------------------------------------------