【发布时间】:2014-08-23 07:05:40
【问题描述】:
我正在尝试以与the tuturial do 相同的方式测试我的注册表单。
但在本教程中,注册页面是一个页面,所以这样做没问题:
visit signup_path.
对我来说,签名表格是通过 javascript 弹出的显示:
<%= link_to( "Inscrivez-vous !", "javascript:void(0)", id: "button-inscription" ) %>
如何在 Ruby on Rails 中使用 TDD 进行模拟?
这是我们按下按钮时的动作:
$('#button-inscription').click(function() {
showinscription();
});
function showinscription()
{
document.getElementById("wrapper-inscription").style.visibility="visible";
document.getElementById("bloc-inscription").style.visibility="visible";
}
谢谢
编辑
这是我的配置:
group :test do
gem 'selenium-webdriver', '2.35.1'
gem 'capybara', '2.1.0'
gem 'factory_girl_rails', '4.2.0'
end
这是我现在的测试:
describe "signup form", js: true do
before { visit root_path }
it { click_link("button-inscription") }
it { should have_content('Inscription') }
end
在 spec/spec_helper.rb 我添加了:
Capybara.javascript_driver = :webkit
那些测试失败了
【问题讨论】:
标签: javascript ruby-on-rails ruby rspec tdd