我想在需要身份验证(通过设计)的Web应用程序上测试一个操作。具体的操作使用JavaScript,因此我申请了js
选项来规范这样:请求规格为JavaScript失败,设计身份验证
scenario "User wants to fax a single document", js: true do
reset_email
@doc = @user.documents.create(FactoryGirl.attributes_for(:document))
visit "/documents/#{@user.id}"
click_on "send_document_#{@doc.id}"
last_email.should eq(@doc)
end
控制器在电子邮件十岁上下的方式发送传真。我不知道为什么;我没有写。无论如何,在(使用水豚使用RSpec)此功能规格的顶部,我验证文件中使用
before(:each) do
# Signs in as an admin
@company = FactoryGirl.create(:company)
@subscription = FactoryGirl.create(:admin_subscription, company_id: @company.id)
@user = FactoryGirl.create(:user, company_id: @company.id)
login_as @user, scope: :user
end
所有其他规格(这还需要登录)依然通过,有我认为它必须做与JavaScript。因此,js
选项在Firefox中打开浏览器,并且该页面不是正确的内容。它说
500 Internal Server Error
undefined method `status' for nil:NilClass
我在网上搜索,发现只有回应说,不要在我的叫response
或action
控制器动作。放心,我没有这样的行为;只有RESTful行动以及两个加法:
def send_document
@to = params[:to].gsub(/([() \-]+)/, '')
#The below parses the number to format it for InterFax
#It adds a "+1" to the front, and a dash in the middle
#of the number where needed.
@to = "+1"[email protected][0..-5]+"-"[email protected][-4,4]
@document = Document.find(params[:id])
DocumentMailer.send_document(@to, @document).deliver
render :template => false, :text => 'true'
end
def email_document
@to = params[:to]
@document = Document.find(params[:id])
DocumentMailer.email_document(@to, @document).deliver
render :template => false, :text => 'true'
end
任何人都可以帮助理解这些错误吗?很多此应用程序使用javascript,并且我确实需要一种方式来在登录时测试这些操作。