我正在使用Rspec和Cucumber创建一个应用程序。我的应用程序使用了大量的Javascript和Ajax,它可以工作但是......我总是遇到很多问题,使用Cucumber和Javascript。另外,它很慢。对于每次启动,它启动firefox,并且对于每个场景,它必须登录我的站点。我想我可以使用带有rspec的mock来登录部分(???)。
你认为使用黄瓜而不是RSpec / Capybara(也许是牛排)更好吗?忘记黄瓜会更快吗?你是如何进行接受测试的?
答案 0 :(得分:3)
我的公司也使用rspec /黄瓜。如果硒的速度是瓶颈,你可以试试类似capybara-webkit
的东西不确定它是否有帮助,但我们也使用仅在javascript请求期间点击登录页面的登录宏
def login_user
let(:current_user) { Factory.create(:user) }
before(:each) do
if example.options[:js]
visit new_user_session_path
fill_in 'Email', :with => current_user.email
fill_in 'Password', :with => current_user.password
click_button 'Sign In'
else
page.driver.post user_session_path, 'user[email]' => current_user.email, 'user[password]' => current_user.password
end
end
end
答案 1 :(得分:1)
在我的公司,我们用Rspec + Capybara取代了Cucumber,我认为它更快更简洁。测试的所有代码大部分位于一个位置,这使得调试也更容易。