我正在創建一個使用jstree的rails應用程序。現在我試圖在一個rspec測試中使用capybara和selenium驅動(js:true)來測試jstree的功能。該測試是:尋找不應存在的資產路線時Rspec /水豚/硒測試失敗
scenario "the object associated with the data-pane is selected in the tree", js: true do
visit surveyor_path
using_wait_time(20) { expect(page).to have_selector("##{obj.class.name}_#{obj.id.to_s}") }
end
這在shared_example,和obj爲與測試對象(在這種情況下,測量員)。我的JS樹應該產生像「_」一樣的ID的節點。所以我期待像「Surveyor_1」這樣的東西。
運行時,我收到以下錯誤:
Failure/Error: Unable to find matching line from backtrace
ActionController::RoutingError:
No route matches [GET] "/surveyors/themes/default/style.css"
# /Users/chrisgat/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
# /Users/chrisgat/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
# /Users/chrisgat/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/rack/logger.rb:26:in `call_app'
# /Users/chrisgat/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/rack/logger.rb:16:in `call'
# /Users/chrisgat/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/action_dispatch/middleware/request_id.rb:22:in `call'
# /Users/chrisgat/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/methodoverride.rb:21:in `call'
# /Users/chrisgat/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/runtime.rb:17:in `call'
# /Users/chrisgat/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.8/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
# /Users/chrisgat/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/lock.rb:15:in `call'
# /Users/chrisgat/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/action_dispatch/middleware/static.rb:62:in `call'
# /Users/chrisgat/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/engine.rb:479:in `call'
# /Users/chrisgat/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/application.rb:223:in `call'
# /Users/chrisgat/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/builder.rb:134:in `call'
# /Users/chrisgat/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/urlmap.rb:64:in `block in call'
# /Users/chrisgat/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/urlmap.rb:49:in `each'
# /Users/chrisgat/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/urlmap.rb:49:in `call'
# /Users/chrisgat/.rvm/gems/ruby-1.9.3-p194/gems/capybara-2.0.1/lib/capybara/server.rb:19:in `call'
# /Users/chrisgat/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/handler/webrick.rb:59:in `service'
# /Users/chrisgat/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
# /Users/chrisgat/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
# /Users/chrisgat/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
這裏的東西雖然不應該擺在首位的路線。它正在尋找的資產是assets/themes/default/style.css
。這是一個js-tree特定的樣式表。在測試中插入一些調試器語句,我可以驗證頁面是否有選擇器。如果頁面確實有選擇器,我只會得到異常......也就是說,如果我將have_selector
的內容更改爲"BadSelector"
,則測試將定期失敗(未找到選擇器)。手動查看時,js-tree功能起作用。
在此先感謝您的幫助
的Rails 3.2.8 Rspec的2.12水豚2.0
請注意,我安裝了jstree-rails gem的tristanm分支,該分支被記錄爲稍微好一點,並且可以使用更多jstree插件。 – cgat