次のスタック経由で phantomjs を実行しようとするとエラーが発生します: rails (3.2.11)、rspec (2.12.2)、capybara (1.1.4)、poltergeist (1.0.2)、phantomjs (1.8.1)、angular .js (1.1.2)。
Angular なしで、このスタックで問題なく動作する多くの仕様があります。しかし、Angular を開始するテスト ページでは、フォロー エラーが発生します。セレンドライバーを使用して仕様を実行すると、合格します。
{"name"=>"visit", "args"=>["http://127.0.0.1:57124/pages/angular"]}
{"response"=>{"status"=>"success"}}
{"name"=>"find", "args"=>["./descendant-or-self::*[contains(normalize-space(.), 'Hello')]"]}
{"error"=>{"name"=>"Poltergeist.JavascriptError", "args"=>[[{"message"=>"TypeError: 'undefined' is not an object (evaluating '$lastDestination.offset().top')", "stack"=>"TypeError: 'undefined' is not an object (evaluating '$lastDestination.offset().top')
at http://127.0.0.1:57124/assets/application.js:13100
at http://127.0.0.1:57124/assets/application.js:3046
at http://127.0.0.1:57124/assets/application.js:2722"}]]}}
これは、他の ng ディレクティブ (コントローラーがインスタンス化されていないなど) がない場合にのみ、最も基本的なコンテンツでも発生します。
<div ng-app>
<h1>Hello</h1>
</div>
スペックはこんな感じ
describe 'ng_posts', type: :request, js: true do
it "should load page" do
visit '/pages/angular'
page.should have_content('Hello')
end
end
これは、ページがブラウザーに読み込まれ (js コンソールにエラーはありません)、仕様が Selenium で実行されるため、phantom.js のバグのようです。これは既知の問題ですか? 私はそれを乗り越えることができますか?ありがとう。
ジョン