I've written a simple module to extend ActiveRecord::Base, which works fine in the rails console but fails miserably in rspec tests. The intended usage looks like this:
class Premise < ActiveRecord::Base has_my_extensions end I've traced it down to the fact that in the console, it loads lib/my_extensions.rb before it loads premise.rb. In rspec, it's attempting to load premise.rb without loading my_extensions.rb, which (naturally) results in a method_missing error. (A) has anyone else seen this? (B) what's the proper remedy? Details below the sig. Thanks... - ff Some particulars: Ruby 1.9.2. Rails 3.0.3. RSpec 2.4.0. === file: $ROOT/config/environment.rb require File.expand_path('../application', __FILE__) Demo::Application.initialize! require 'my_extensions' === EOF === file: $ROOT/app/models/premise.rb $stderr.puts(Rails.logger.debug("==== loading #{__FILE__}")) class Premise < ActiveRecord::Base has_my_extensions def test_one extension_one end end === EOF === file: $ROOT/lib/my_extensions.rb hews to a familiar pattern: $stderr.puts(Rails.logger.debug("==== loading #{__FILE__}")) module MyExtensions def self.included(base) base.extend(ClassMethods) end module ClassMethods def has_my_extensions send(:include, InstanceMethods) end end module InstanceMethods def extension_one $stderr.puts(Rails.logger.debug("==== extension_one")) end end end ActiveRecord::Base.send(:include, MyExtensions) === EOF -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.