如何使用Capybara获取,显示,发布和放入控制器测试? [英] How do I use Capybara get, show, post, put in controller tests?

查看:61
本文介绍了如何使用Capybara获取,显示,发布和放入控制器测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是不确定确切的用词是什么。。

I'm just not sure what the exact way to word it is..

这告诉我‘还没有答复。首先请求页面。'

This tells me 'No response yet. Request a page first.'

it "should list searches" do
  get 'index'
  page.should have_selector('tr#search-1')
end

会是这样吗?

it "should list searches" do
  get 'index' do
    page.should have_selector('tr#search-1')
  end
end

那种方式似乎并没有实际测试任何东西。

That way doesn't seem to actually test anything though.

什么是正确的方式?

推荐答案

根据对此,Capybara不支持默认驱动程序的PUT和DELETE请求。 PUT和DELETE通常用javascript伪造,以适应基于REST的体系结构。

According to this, Capybara doesn't support PUT and DELETE requests with the default driver. PUT and DELETE are usually faked with javascript to accomodate REST based architecture.

我还没有检查过,但我相信如果您使用Capybara中的一种JS兼容驱动程序(例如Selenium),可以将其与Capybara一起使用。

I haven't checked, but I believe that you can use PUT and DELETE with Capybara if you make it use one of it's JS compatible drivers such as Selenium.

这篇关于如何使用Capybara获取,显示,发布和放入控制器测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆