rspec logging tips?

119 views
Skip to first unread message

Christopher Dwan

unread,
Jul 5, 2011, 9:49:27 PM7/5/11
to golia...@googlegroups.com
We're finding that it's like voodoo magic for us to work with rspec and our goliath app. The main thing is that failures happen and there is no logging, which can be somewhat infuriating when the test passes by manually testing it via curl requests but fails in the rspec tests.

Is there a method to get logging to output to test.log while running rspec?

-C

Ilya Grigorik

unread,
Jul 6, 2011, 4:17:40 AM7/6/11
to golia...@googlegroups.com
I've run into this before as well.. Should be just a matter of extending with_api? 

ig

Juan Felipe Rincon

unread,
Dec 4, 2011, 5:18:07 PM12/4/11
to golia...@googlegroups.com
Try adding the following to your spec_helper.rb file --

...

module Goliath
  module TestHelper
    def server(api, port, options = {}, &blk)
      op = OptionParser.new
      s = Goliath::Server.new
      # Make it possible for you to specify a log file in with_api call as Options parameter
      s.logger = options[:log_file].nil? ? mock('log').as_null_object : Logger.new(options.delete(:log_file))
      s.api = api.new
      s.app = Goliath::Rack::Builder.build(api, s.api)
      s.api.options_parser(op, options)
      s.options = options
      s.port = @test_server_port = port
      s.start(&blk)
      s
    end
  end
end

....

With that, you can call with_api(YourApi, {:log_file => 'path/to/your/logfile'})  and see the log output in a file.


Juan Felipe Rincon

unread,
Jan 19, 2012, 9:35:25 PM1/19/12
to golia...@googlegroups.com
In case anyone lands on this via search, this was fixed with this patch:

sleeper

unread,
Jan 20, 2012, 1:12:30 AM1/20/12
to golia...@googlegroups.com
Not to be pedantic but the above commit was not working for me, and I've to fix it: 

Reply all
Reply to author
Forward
0 new messages