开发者

Rspec Ruby on Rails controller question

开发者 https://www.devze.com 2023-03-30 03:48 出处:网络
I\'m currently using ruby 1.9.2 and rails 3 and I\'m in the middle of rspec testing.Basically, I have a function that is called by a before filter in the application controller such that it obviously

I'm currently using ruby 1.9.2 and rails 3 and I'm in the middle of rspec testing. Basically, I have a function that is called by a before filter in the application controller such that it obviously gets run every time a controller action is made anywhere on my site. For testing purposes, I'm writing tests for a different controller but my actions do not set off my before filter function call. Is there any way to specifically call functions from a specific controller within rspec开发者_开发百科 tests? I can't post the code online, so no use asking for it :P.

Thanks


Inside an it or before(:each) block in a controller spec:

controller.send( :your_method_name )

And your function is going to be called.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号