RSpec测试神秘失败

时间:2013-11-06 07:44:47

标签: ruby-on-rails ruby-on-rails-3 testing rspec capybara

我正在为我的rails应用程序功能编写一个测试来处理学校的入学请求。我目前无法测试的测试是否在提交入学申请表之后测试入学申请总数是否变化1。这是测试

describe "with valid information" do

  before do
    fill_in "Name",         with: "Example User"
    fill_in "Email",        with: "user@example.com"
    fill_in "Address",     with: "68 High St"
    fill_in "Phone", with: "2035846857"
    fill_in "Card", with: "4242424242424242"
    fill_in "CVC", with: "557"
    fill_in "admission_request_exp_month", with: "08"
    fill_in "admission_request_exp_year", with: "2017"
  end

  it "should create a request", :js => true do
    expect { click_button 'Submit Request' }.to change(AdmissionRequest, :count).by(1)
  end
  ...

这是我运行测试时得到的结果

 1) Admission requests pages new admission request with valid information should create a request
 Failure/Error: expect { click_button 'Submit Request' }.to change(AdmissionRequest, :count).by(1)
   count should have been changed by 1, but was changed by 0

但是如果我手动提交表单,一切都运行正常,新的录取请求会保存到数据库中,计数会改变1.可能是什么问题? 我使用rails 3.2.13和capybara 1.1.2

由于

0 个答案:

没有答案