When I have problems isolating behavior in tests, sometimes it can be useful to test more rather than less. If you are testing log output, use a dummy rails app inside of your test suite with dummy controller actions and hit it as a user would with capybara. Then you could route logs to stdout or a custom log object, or simply parse the log file in log/ to verify the correct strings are being written. While not as helpful for development as unit tests, this type of end-to-end testing is great for protecting against regressions and bugs.
-- Richard Schneeman http://heroku.com @schneems (http://twitter.com/schneems) On Wednesday, September 26, 2012 at 5:05 AM, Jeffrey Jones wrote: > Ahoi Gary > > Thanks for the info but the gem has already been created and the testing I > want to do is not obvious (to my mind anyway) so online "Getting started" > style stuff that I have found is not that useful.. > > This is why I was asking if an expert can offer some time to answer specific > questions I have and help my get my head around it. > > On a site-note by hacking around I seem to have got the LogSubscriber tests > working, still no idea on how to do the rack logger tests though. > > Cheers > > Jeff > > > On 25/09/12 23:58, Gary Weaver wrote: > > Not an expert, but since I have been kind of slack on testing recently, > > I'll try to get some karma by trying to help. First, you may want to ask on > > this list instead/too: > > https://groups.google.com/forum/?fromgroups=#!forum/rubyonrails-talk > > (Stackoverflow is also a good place to get Rails stuff answered for more > > specific questions.) > > > > This was the thing for Rails 3.0: > > https://github.com/josevalim/enginex > > > > After that it became: > > rails plugin new > > > > In: http://guides.rubyonrails.org/plugins.html > > > > > 1.2 Or generate a gemified plugin. > > > > > > Writing your Rails plugin as a gem, rather than as a vendored plugin, > > > lets you share your plugin across different rails applications using > > > RubyGems and Bundler. > > > > > > Rails 3.1 ships with a rails plugin new command which creates a skeleton > > > for developing any kind of Rails extension with the ability to run > > > integration tests using a dummy Rails application. See usage and options > > > by asking for help: > > > $ rails plugin --help > > > > This looks like it might help: > > http://namick.tumblr.com/post/17663752365/how-to-create-a-gemified-plugin-with-rails-3-2-rspec > > > > Rails initialization guide since you mentioned wanting to know the boot > > process, but sounds like you don't need it: > > http://guides.rubyonrails.org/initialization.html > > > > > > On Tuesday, September 25, 2012 1:00:38 AM UTC-4, Jeffrey Jones wrote: > > > Hello all. > > > > > > #1 I am working on a rails3 gem called Yarder > > > (https://github.com/rurounijones/yarder). The goal of this gem is to > > > replace the rails logging system with one that is JSON based rather than > > > string based. > > > > > > #2 To this end I also recently asked this list about making the > > > LogSubscribers subscriptions to ActiveRecord::Notifications configurable > > > and am looking at submitting a patch request. > > > > > > However for both of these I have rather run into a brick wall. > > > > > > #1 Yarder works (mostly, I have not finished or refactored and there are > > > probably bugs) but it has no tests. The reasons for this is that I > > > cannot get my head around how to test it (and how to set up the tests in > > > the first place ) and there aren't examples of this kind of stuff online > > > that I can see (rails own LogSubscriber tests use a lot of support files > > > specific to the rails gems which makes using them as a base less than > > > obvious) > > > > > > #2 For this I am just not exactly sure how to start (Both dev and test) > > > > > > I have spent the last week or so looking through the rails code-base and > > > testing setup to try and grok how to do the above but it is beyond me at > > > the moment. > > > > > > I don't suppose there is a altruistic rails expert out there who is > > > willing to spare some time (email, skype, whatever suits you best) to > > > help me get my head around the rails internals (mainly the boot process > > > and what to change for #2 plus setting up the tests) and how to test #1. > > > > > > Regards, > > > > > > Jeff Jones > > > > > > > > > > > > > > -- > > You received this message because you are subscribed to the Google Groups > > "Ruby on Rails: Core" group. > > To view this discussion on the web visit > > https://groups.google.com/d/msg/rubyonrails-core/-/a9Xaa3XtugcJ. > > To post to this group, send email to [email protected] > > (mailto:[email protected]). > > To unsubscribe from this group, send email to > > [email protected] > > (mailto:[email protected]). > > For more options, visit this group at > > http://groups.google.com/group/rubyonrails-core?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Core" group. > To post to this group, send email to [email protected] > (mailto:[email protected]). > To unsubscribe from this group, send email to > [email protected] > (mailto:[email protected]). > For more options, visit this group at > http://groups.google.com/group/rubyonrails-core?hl=en. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" 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-core?hl=en.
