On Apr 8, 1:40 pm, Jonathan Rochkind <[email protected]> wrote: > Ah, I see you are not actually using plugin_test_helper, on a re-read. > > Can you explain what you mean by "I have those things loaded in the > environment". You load them in the environment how? We're not talking > "Rails app environment", because there is none in your tests of the > plugin, right?
I think I might have mis-spoken. I'm doing a fork of Foreigner, and you can see my work in progress at http://github.com/hosh/foreigner/tree/rspec Since I want to test different database configuration, all I need to do is push in the connection credentials. I actually patterned this off of an old version of acts_as_soft_deleteable (which, IMO, should be deleted as an evolutionary dead-end). Unlike David Wilkie, I chose to metaprogram anonymous migrations, so that the tests are easier to read (see how I did it in http://github.com/hosh/foreigner/blob/rspec/spec/adapter_helper.rb ). Because of that, I don't actually need to use plugin_test_helper to create a fake app path and manage the library loads (the migrations are embedded inside the spec where it is easier to follow along what is being tested). What you are trying to do might require more. So what *are* you trying to do? > So are you just specifically loading the parts of Rails you need loaded > in tests in your test code? require rubygems, require active-support? > Or something else? Yes. See http://github.com/hosh/foreigner/blob/rspec/spec/spec_helper.rb It is manageable like that for now. I imagine if I needed more, I'd write a lot more helpers to do that. The main thing, though, is that I only need a fraction of Rails stack and I only want to test against a fraction of the Rails stack. Your mileage may vary. > Without Rails there, my _own_ classes don't seem to autoload, like they > do in Rails. How are you loading all your own classes in so classes that > reference each other can be tested? Even if I wanted to just "require" > each one, one by one -- circular dependencies seem to cause a problem > with that. Which the Rails autoloader somehow gets around, but I don't > know how to do it myself for testing without Rails. I don't have that many classes, so I'm explicitly declaring it. This is a very common pattern in most of the plugins and gems I've seen. However, if you want to see how autoloading is done right, look at the Merb-more gems and the Rails 3 gems. They have awesome examples of how to organize the autoloading. Ho-Sheng Hsiao http://hosheng.blogspot.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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

