所以我最近接受了一个将Ruby 1.9.3 / Rails 3.2应用程序升级到Ruby 2 / Rails 4.0.2的项目。一切似乎都很好,但我有一个失败的规范。我正在尝试测试页面底部的按钮是否正在“建议”框中。
失败消息是:
Failures:
1) StaticPages Scheduler Page after authenticating filling in the suggestion form after submitting the form should send an email request with the form contents
Failure/Error: click_button("suggestion-button")
ActionController::UnknownFormat:
ActionController::UnknownFormat
# ./app/controllers/static_pages_controller.rb:39:in `suggestion'
# ./spec/features/static_pages_spec.rb:93:in `block (6 levels) in <top (required)>'
规范如下:
context "after submitting the form" do
before(:each) do
click_button("suggestion-button")
end
控制器读取:
def suggestion
if user_signed_in?
user = current_user.email
else
user = "< not logged in >"
end
if params[:suggestion]
ContactMailer.suggestion_email(params[:suggestion], params[:pathname], user).deliver!
end
respond_to do |format|
format.json { render json: params[:suggestion] }
end
end
页面上按钮的来源是:
<button type="submit" class="btn" id="suggestion-button">
Tell Us!
</button>
</form>
<script>
// After form submission, gray out and disable the form
$(document).ready(function(){
$("#footer-suggestion-form").bind("ajax:complete", function(event, xhr, status){
console.log($("#footer-suggestion-form input"));
$("#footer-suggestion-form input").attr("disabled","disabled");
$("#footer-suggestion-form button").attr("disabled","disabled").html("Thanks!");
console.log("did it!");
});
$("#suggestion-pathname").val(location.pathname);
});
</script>
是因为它是一个AJAX形式吗?或者只是一个在Rails 3.2中运行的测试但由于某些变化而不再适用于4?我很感激任何帮助,我真的很失落。
我确实尝试过使用:js =&gt;在规范和下载capybara-webkit gem中是真的,但是当我尝试运行规范时,它会进入该测试,然后挂起就等待发生从未发生的事情。
编辑:进展。现在它进入那个测试,坐着一个大,然后用失败1)在提交表单后填写建议表格后验证静态页面调度页面应发送带有表单内容的电子邮件请求
失败/错误:{visit scheduler_path}之前
RuntimeError: 机架应用程序在启动期间超时 ./spec/features/static_pages_spec.rb:31:in块(3级)