How to write tests for alternative logging for Rails (tests for gem)? Not only unit tests, but also check functionality with rails. Maybe somebody know best way for such testing.
preguntado el 08 de noviembre de 11 a las 15:11
If you want to test the integration of a gem then you could do this with either rspec or cucumber or even test_unit if you wanted the process would be very similar.
You essentially need to write some integration tests that are going to build a new rails application (you could do this by running the 'rails new application' command or by loading a pre-build rails application in your project). I would probably do the former and create a new rails application into a your_project_dir/tmp/test_rails_application and make sure you ignore the tmp dir in git. Also remove the application every time you run your integration tests.
You now need to write some code to add your logging gem to the Gemfile and have the process run bundle to install the gem. Once you've done that you should be able to see where to go with this, you'll be writing code to add code to your rails application, load up the application and assert your logging commands are getting written out to the log files.
It's not an overly difficult process but will require some thought about the best way to get it done.