カピバラのREADMEによると:
次の2つのステートメントは、機能的に同等です。
page.should_not have_xpath('a') page.should have_no_xpath('a')
しかし、これを試してみると、それは真実ではないようです。capybara-webkitを使用すると、これは正常に機能するようです。
visit dashboard_accounting_reports_path
click_link 'Delete'
page.should_not have_css('#reports .report')
しかし、poltergeistを使用する場合、これで失敗することがよくあります。これは#has_css?
、特定の要素が消えるのを実際に待たない、裏で使用していることを示しているようです。
Failure/Error: page.should_not have_css('#reports .report')
expected #has_css?("#reports .report") to return false, got true
代わりにこのようにアサーションを読み取るように変更すると、毎回成功するようです。
page.should have_no_css('#reports .report')
私は頭がおかしいのですか、それともこれはポルターガイストのバグですか?PhantomJS 1.8.2、poltergeist 1.1.0、capybara2.0.2を使用しています。
should_not have_css
例からのデバッグ出力は次のとおりです。http: //pastebin.com/4ZtPEN5B
そして、これがshould have_no_css
例からのものです:http: //pastebin.com/TrtURWcZ