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.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.
David