2

要素が存在しないことをテストするにはどうすればよいですか? 次のことを試しましたが、textarea#Question1Text does not existテストに合格する代わりにエラーが発生しました。

it "should not have question 1" do
  find('textarea#Question1Text').should_not be
end

it { should_not find('textarea#Question1Text') }
4

3 に答える 3

4

have_css要素が存在するかどうかをテストするために、カピバラマッチャーの 1 つ (具体的には ) を使用できます。

it 'should not have question1' do
  page.should_not have_css('textarea#Question1Text')
end
于 2013-06-23T13:43:44.760 に答える
1

簡単に

expect{page.find_by_id("update-#{term1.id}").should}.not_to raise_error
expect{page.find_by_id("update-#{term4.id}")}.to  raise_error

一意の ID がない場合は、spullen が示唆する Css が機能します

于 2013-09-29T16:11:46.503 に答える