3
我对测试非常陌生,所以我不确定我应该在这里调试什么。用rspec,水豚和条纹测试注册表格
也就是说,我有两种不同的用户类型:作者和读者,分类在用户上。
他们都可以在我的应用程序中注册,并且对读者的测试没有任何问题。
作者的注册表格包含分条付款表单 - 并在提交表单之前对Stripe的API进行远程调用。
下面是测试的样子:
require 'spec_helper'
feature 'Author sign up' do
scenario 'author can see signup form' do
visit root_path
expect(page).to have_css 'form#new_author'
end
scenario 'user signs up and is logged in' do
visit root_path
fill_in 'author[email]', :with => '[email protected]'
fill_in 'author[password]', :with => '123456'
fill_in 'author[password_confirmation]', :with => '123456'
fill_in 'author[name]', :with => 'joe shmoe'
fill_in 'author[zipcode]', :with => '02021'
fill_in 'card_number', :with => '4242424242424242'
fill_in 'card_code', :with => '123'
select "1 - January", :from => 'card_month'
select "2014", :from => 'card_year'
find('.author_signup_button').click
expect(page).to have_css '.author_menu'
end
end
这次试验和阅读器测试之间的唯一区别是信用卡的形式。
它处理这个账号创建控制器看起来是这样的:
def create
@author = Author.new(params[:author])
if @author.save_with_payment
sign_in @author, :event => :authentication
redirect_to root_path, :notice => "Thanks for signing up!"
else
render :nothing => true
end
end
如果我没有别的在这里做什么,测试失败得越早,称其缺少的模板。这意味着它不会传递“save_with_payment”方法,该方法支持表单从不打印条纹的想法。
错误只是说:
**Failure/Error: expect(page).to have_css '.author_menu'
expected css ".author_menu' to return something**
这个工作之前,我与条纹结合 - 所以我相信它与Ajax调用做。
我应该做些什么来支持ajax?
如果你想没有本地浏览器中运行这个,硒支持远程模式,使用像[硒电网(http://selenium-grid.seleniumhq.org/) - 这可让您测试其他平台太(特别是如果你使用提供它的服务) –