使用 capybara+rspec 如何编译带有空字段的表单?我正在测试一个编辑资源页面,所以我有一个已编译的表单并想要清理它的文本字段。这是部分测试:
context "when submitting" do
before { visit edit_post_path(post) }
it {should have_content('Editing')}
it {current_path.should == edit_post_path(post)}
describe "whit invalid information" do
before do
fill_in "post[title]", :with => "" #not working
fill_in "post[body]", :with => "" #not working
click_button "update"
end
it {current_path.should == edit_post_path(post)}
end
describe "whit valid information" do
before do
fill_in "post[title]", with: "some"
fill_in "post[body]", with: "some"
click_button "update"
end
it {should have_content('some')}
it {should have_content('some')}
it {current_path.should == post_path(post)}
end
end