Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rails4 rails-observers gem causes observed models to get loaded at startup #252

Open
inspire22 opened this issue Mar 4, 2014 · 0 comments

Comments

@inspire22
Copy link

Using spork, at startup now it's loading all my files referenced by observers.

The goal of spork is to only load the files at each test, so the latest changes are included.

Here's the caller[] block, but basically once environment is included, the observers load all models listed in config.active_record.observers.

spork-rails (4.0.0)
spork 1.0.0rc4

Suggestions welcome! I know spork tries to trap_method, but it's not working for me for some reason. I tried varying the placement in Gemfile but it didn't help

  pro ➤ spork
  Using RSpec, Rails
  Preloading Rails environment
  0.046477 startup
  Loading Spork.prefork block...
  Starting new test rails, 2014-03-04 18:42:38. Pid: 54449, heap: 600000
  [deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message.
  Loading group
  ["/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:424:in `load'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:424:in `block in load_file'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:616:in `new_constants_in'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:423:in `load_file'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:324:in `require_or_load'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:463:in `load_missing_constant'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:184:in `const_missing'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.3/lib/active_support/inflector/methods.rb:226:in `const_get'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.3/lib/active_support/inflector/methods.rb:226:in `block in constantize'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.3/lib/active_support/inflector/methods.rb:224:in `each'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.3/lib/active_support/inflector/methods.rb:224:in `inject'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.3/lib/active_support/inflector/methods.rb:224:in `constantize'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.3/lib/active_support/inflector/methods.rb:269:in `safe_constantize'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.3/lib/active_support/core_ext/string/inflections.rb:77:in `safe_constantize'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-4.0.3/lib/active_record/associations/builder/belongs_to.rb:65:in `add_counter_cache_callbacks'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-4.0.3/lib/active_record/associations/builder/belongs_to.rb:17:in `build'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-4.0.3/lib/active_record/associations/builder/association.rb:12:in `build'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-4.0.3/lib/active_record/associations.rb:1401:in `belongs_to'",
   "/Users/inspire/Projects/_rails/ap.pro/app/models/topic.rb:21:in `<class:Topic>'",
   "/Users/inspire/Projects/_rails/ap.pro/app/models/topic.rb:1:in `<top (required)>'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:424:in `load'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:424:in `block in load_file'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:616:in `new_constants_in'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:423:in `load_file'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:324:in `require_or_load'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:463:in `load_missing_constant'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:184:in `const_missing'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:495:in `load_missing_constant'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:184:in `const_missing'",
   "/Users/inspire/Projects/_rails/ap.pro/app/models/admin_watch.rb:15:in `<class:AdminWatch>'",
   "/Users/inspire/Projects/_rails/ap.pro/app/models/admin_watch.rb:14:in `<top (required)>'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:424:in `load'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:424:in `block in load_file'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:616:in `new_constants_in'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:423:in `load_file'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:324:in `require_or_load'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:463:in `load_missing_constant'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:184:in `const_missing'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.3/lib/active_support/inflector/methods.rb:226:in `const_get'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.3/lib/active_support/inflector/methods.rb:226:in `block in constantize'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.3/lib/active_support/inflector/methods.rb:224:in `each'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.3/lib/active_support/inflector/methods.rb:224:in `inject'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.3/lib/active_support/inflector/methods.rb:224:in `constantize'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.3/lib/active_support/core_ext/string/inflections.rb:66:in `constantize'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/rails-observers-0.1.2/lib/rails/observers/active_model/observing.rb:183:in `instantiate_observer'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/rails-observers-0.1.2/lib/rails/observers/active_model/observing.rb:108:in `block in instantiate_observers'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/rails-observers-0.1.2/lib/rails/observers/active_model/observing.rb:108:in `each'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/rails-observers-0.1.2/lib/rails/observers/active_model/observing.rb:108:in `instantiate_observers'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/rails-observers-0.1.2/lib/rails/observers/railtie.rb:24:in `block (2 levels) in <class:Railtie>'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.3/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.3/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.3/lib/active_support/lazy_load_hooks.rb:28:in `block in on_load'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.3/lib/active_support/lazy_load_hooks.rb:27:in `each'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.3/lib/active_support/lazy_load_hooks.rb:27:in `on_load'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/rails-observers-0.1.2/lib/rails/observers/railtie.rb:23:in `block in <class:Railtie>'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.3/lib/active_support/lazy_load_hooks.rb:36:in `call'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.3/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.3/lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.3/lib/active_support/lazy_load_hooks.rb:44:in `each'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.3/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/railties-4.0.3/lib/rails/application/finisher.rb:62:in `block in <module:Finisher>'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/railties-4.0.3/lib/rails/initializable.rb:30:in `instance_exec'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/railties-4.0.3/lib/rails/initializable.rb:30:in `run'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/railties-4.0.3/lib/rails/initializable.rb:55:in `block in run_initializers'",
   "/Users/inspire/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/tsort.rb:150:in `block in tsort_each'",
   "/Users/inspire/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/tsort.rb:183:in `block (2 levels) in each_strongly_connected_component'",
   "/Users/inspire/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/tsort.rb:219:in `each_strongly_connected_component_from'",
   "/Users/inspire/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/tsort.rb:182:in `block in each_strongly_connected_component'",
   "/Users/inspire/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/tsort.rb:180:in `each'",
   "/Users/inspire/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/tsort.rb:180:in `each_strongly_connected_component'",
   "/Users/inspire/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/tsort.rb:148:in `tsort_each'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/railties-4.0.3/lib/rails/initializable.rb:54:in `run_initializers'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/railties-4.0.3/lib/rails/application.rb:215:in `initialize!'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/railties-4.0.3/lib/rails/railtie/configurable.rb:30:in `method_missing'",
   "/Users/inspire/Projects/_rails/ap.pro/config/environment.rb:8:in `<top (required)>'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:229:in `require'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:229:in `block in require'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:214:in `load_dependency'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:229:in `require'",
   "/Users/inspire/Projects/_rails/ap.pro/spec/spec_helper.rb:6:in `block in <top (required)>'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/spork-1.0.0rc4/lib/spork.rb:24:in `prefork'",
   "/Users/inspire/Projects/_rails/ap.pro/spec/spec_helper.rb:4:in `<top (required)>'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:223:in `load'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:223:in `block in load'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:214:in `load_dependency'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:223:in `load'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/spork-1.0.0rc4/lib/spork/test_framework.rb:138:in `block (2 levels) in preload'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/spork-rails-4.0.0/lib/spork/app_framework/rails.rb:8:in `preload'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/spork-1.0.0rc4/lib/spork/test_framework.rb:134:in `block in preload'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/spork-1.0.0rc4/lib/spork.rb:62:in `exec_prefork'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/spork-1.0.0rc4/lib/spork/test_framework.rb:120:in `preload'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/spork-1.0.0rc4/lib/spork/run_strategy/forking.rb:25:in `preload'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/spork-1.0.0rc4/lib/spork/runner.rb:75:in `run'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/spork-1.0.0rc4/lib/spork/runner.rb:10:in `run'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/gems/spork-1.0.0rc4/bin/spork:10:in `<top (required)>'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/bin/spork:23:in `load'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/bin/spork:23:in `<main>'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/bin/ruby_noexec_wrapper:14:in `eval'",
   "/Users/inspire/.rvm/gems/ruby-2.0.0-p195/bin/ruby_noexec_wrapper:14:in `<main>'"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant