Ruby on rails 3 Rspec/Capybara/Selenium测试在寻找不应';不存在

Ruby on rails 3 Rspec/Capybara/Selenium测试在寻找不应';不存在,ruby-on-rails-3,capybara,jstree,rspec-rails,Ruby On Rails 3,Capybara,Jstree,Rspec Rails,我正在创建一个利用jstree的rails应用程序。现在,我正试图在rspec测试中测试jstree的功能,使用capybara和selenium驱动程序(js:true)。测试是: 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_s

我正在创建一个利用jstree的rails应用程序。现在,我正试图在rspec测试中测试jstree的功能,使用capybara和selenium驱动程序(js:true)。测试是:

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
这是一个共享的示例,obj是一个与测试相关的对象(在本例中为测量员)。我的js树应该生成id为“\u1”的节点。所以我期待像“测量员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'
但问题是,
/surveyors/themes/default/style.css
首先不应该是一条路线。它正在查找的资产位于
assets/themes/default/style.css
中。这是一个特定于js树的样式表。在测试中插入一些调试器语句,我可以验证页面是否具有选择器。我只会在页面没有选择器的情况下得到异常。。。也就是说,如果我将
have_selector
的内容更改为
“BadSelector”
,测试将定期失败(未找到选择器)。手动查看时,js树功能可以正常工作

提前谢谢你的帮助


Rails 3.2.8 Rspec 2.12水豚2.0回声,有人在吗?不,看起来我在给自己写信


如果其他人遇到这个问题,我确实找到了解决方法,尽管我不能百分之百确定根本原因。当我“安装”jstree时,我只是将其转储到资产管道(javascript)中。它在开发中工作得很好,但在测试中不起作用(见上文)。Jstree使用其主题插件加载样式表,而不是将它们直接放在样式表文件夹中。在测试中,无论出于何种原因,它生成的路径都会作为当前页面路径的前缀。我使用jstree rails gem解决了这个问题,它显式地引用了样式表使用的目录。问题解决了

注意,我安装了jstree-rails-gem的tristanm分支,它的文档记录稍微好一点,可以与更多的jstree插件一起使用。