Rspec测试render :nothing => true

对于controller render/redirect的测试,一般对应以下的测试方法

render :action => :index
response.should render_template('index')

render :partial => 'post'
response.should render_template('_post')

redirect_to login_path
response.should redirect_to(login_path)

但是对于render :nothing = true来说,并没有相应的方法来测试,也无法用render_template来解决,只能是判断返回的response的内容是不是为空了。

response.should have_text(' ')

注意是 ,不是,至于为什么有个空格?我也没有仔细研究

Posted in  rails rspec


blog comments powered by Disqus
Fork me on GitHub