[rspec-users] RSpec - Testing ActiveRecord addins

James Byrne lists at ruby-forum.com
Mon Feb 2 13:49:46 EST 2009


James Byrne wrote:

> 
> What is happening is that RSpec is blowing up at its own logger code in 
> the default spec_helper.rb file. This happens whether or not ActAsFu is 
> installed and whether or not my custom logger is commented out in 
> environment.rb

I poked at this a bit and hit upon the problem. As distributed, 
spec_helper.rb says this:

  config.before(:each) do
    full_example_description = "#{self.class.description} 
#{@method_name}"
    logger.info(
      "\n\n#{full_example_description}\n#{'-' *
          (full_example_description.length)}")
  end

The fix is to prefix logger with Rails:: thus:

  config.before(:each) do
    full_example_description = "#{self.class.description} 
#{@method_name}"
    Rails::logger.info(
      "\n\n#{full_example_description}\n#{'-' *
          (full_example_description.length)}")
  end

I have one other difficulty when running this on MS-WinXPpro under 
cygwin. The newline character seems to have no effect.  I can force it 
to behave locally by adding a \r in front of each \n but, obviously, 
that will have unfortunate consequences on *nix.

Suggestions welcome.
-- 
Posted via http://www.ruby-forum.com/.


More information about the rspec-users mailing list