title: Test Recipe: How to test a ruby gem with rails dependencies
body: <p>I am developing a ruby gem which provides some methods that can be mixed into a ActiveRecord model, similar to e.g. acts_as_taggable.</p>
  
  <p>My question is: How do I write e.g. unit tests for my code without having a rails app? My model relies e.g. on an existing database / connection that rails establishes. If there is no connection, the test execution fails.</p>
  
  <p>I also need to copy some files from my gem directory to the rails app using e.g. RAILS_ROOT to detect the rails app dir. Environment variables are also not available.</p>
  
  <p>What would be your approach? Can a rails app somehow be "simulated" during test runs?</p>
  
  <p>Thanks in advance for any hints.</p>