English 中文(简体)
我如何在测试带有幻觉的控制器时拿我的记录电去档案?
原标题:how do I get my logger messages to go to a file when testing a controller with rspec?

I m 利用Rspec2与观察家一道测试一个员额,以便像这样:

...
 post :add_item, :add_item=> { "price" => price.to_s, "product_line" => line }
 # puts " response: "  + response.body
 response.should be_success
...    

我正在得到答复,看得很错,但出于某种原因,这只是给我一个“成功”的反应。 我试图说明原因。 为此,如果我能看到我的记录,那将非常有益。 我可以看到,这些标志正在初步形成,并且指向正确的位置,因为当我开始站出来时,我有:

Loading environment: test
Logger: #<ActiveSupport::BufferedLogger:0xa201b24 @level=0, @buffer={},         
  @auto_flushing=1, @guard=#<Mutex:0xa201728>, 
  @log=#<File:/mnt/hgfs/the_app/log/test.log>, @namespace="">
Database: the_app_test

页: 1 我的所有大布电话都被拖拉,但RSpec似乎正在改用对账的电话。 此处的样本没有显示在记录中:

logger.debug "Params #{params.inspect}" (this line is right after the def in the controller)

我检查了我的环境,看不出任何解释。 是否有办法获取由控制器生成的信息,以便进入自己的记录? Rspec是否转移了我的伐木产出?

I read this blog post, but it s pretty obsolete so I m not ensure that it will help. 这个问题与铁路有关。

最佳回答

快速但又ug:将<代码>logger = 铁路:logger置于你的控制器方法之上。 如果不能打破正常的伐木,就无法确定。

并且

config.before(:suite) do
Rails::logger  =
    ActiveSupport::BufferedLogger.new(File.join(Rails.root,
    "log", "rspec_env_#{Rails.env}.log"),
    ActiveSupport::BufferedLogger::Severity::DEBUG)

摘自我的“帮助者”。 这两条将会导致将光谱仪表化电话投向“仪表_env_test.log”等。

Anyone got a better way?

问题回答

暂无回答




相关问题
Selenium not working with Firefox 3.x on linux

I am using selenium-server , selenium rc for UI testing in my application . My dev box is Windows with FireFox 3.5 and every thing is running fine and cool. But when i try to run selenium tests on my ...

Best browser for testing under Safari Mobile on Linux?

I have an iPhone web app I m producing on a Linux machine. What s the best browser I can use to most closely mimic the feature-limited version of Safari present on the iPhone? (It s a "slimmed down" ...

Code Coverage Tools & Visual Studio 2008 Pro

Just wondering what people are using for code coverage tools when using MS Visual Studio 2008 Pro. We are using the built-in MS test project and unit testing tool (the one that come pre-installed ...

Is there any error checking web app cralwers out there?

Wondering if there was some sort of crawler we could use to test and re-test everything when changes are made to the web app so we know some new change didn t error out any existing pages. Or maybe a ...

热门标签