我将登录表单放入 Jquery UI 对话框弹出框。当我开始进行 RSpec 测试时,出现错误
Failure/Error: fill_in "Username", with: "user@example.com"
Capybara::ElementNotFound
cannot fill in, no text field, text area or password field with id, name, or label 'Username' found
这是我的规格/请求页面:
describe "create user", :js => true do
before { visit new_enr_rds_dea_path }
let(:submit) { "Create Dea" }
describe "with invalid information" do
it "should not create a user" do
expect { click_button submit }.not_to change(Enr::Rds::Dea, :count)
end
end
describe "with valid information" do
before do
fill_in "Username", with: "user@example.com"
fill_in "Password", with: "foobar"
fill_in "Confirm password", with: "foobar"
fill_in "Organisation", with: "foobar"
end
it "should create a user" do
expect { click_link_or_button submit }.to change(Enr::Rds::Dea, :count).by()
end
end
工厂.rb
FactoryGirl.define do
factory :dea_user do |user|
user.dea_user "example@in4systems.com"
user.dea_pwd "foobar"
user.dea_pwd_confirmation "foobar"
user.pro_organisation_id "NHER"
end
end
我正在将我的新页面和编辑页面呈现到表单部分。New
和edit
按钮都有打开JqueryUI:remote => true
对话框的方法。谢谢..