'/ specs'的Jasmine runner返回302错误:找到了

时间:2013-06-18 19:53:35

标签: devise ruby-on-rails-3.2 jasmine rspec-rails

我在标准 rails-3.2 应用中使用 jasmine-rails-0.4.5 devise-2.2.3 。当我运行 bundle exec rake spec:javascript 时,为了运行jasmine规范,我收到以下消息:“ Jasmine runner at'/ specs'返回302错误:找到

由于我正在设计针对尚未经过身份验证的服务器的任何请求,因此它将被重定向到登录页面。到目前为止一切都那么好,这是设计的预期行为,但jasmine-rails需要访问 / specs url 才能运行测试,所以当它试图访问它时,它会得到这个错误:“ Jasmine runner at'/ specs'返回302错误:发现

在我的routes.rb文件中,我添加了这一行:“* mount JasmineRails :: Engine =>”/ my_specs“if defined defined?(JasmineRails)*”

有任何线索吗? 感谢

1 个答案:

答案 0 :(得分:0)

这就解决了这个问题(我对新版本进行了升级):

  1. 更新您的js库

  2. 删除“src_files”部分下的所有条目,但spec / javascripts / support / jasmine.yml文件中的“assets / application.js”除外

  3. 添加此文件: +++ b/spec/javascripts/support/jasmine_helper.rb @@ -0,0 +1,13 @@ +#Use this file to set/override Jasmine configuration options +#You can remove it if you don't need it. +#This file is loaded *after* jasmine.yml is interpreted. +# +#Example: using a different boot file. +#Jasmine.configure do |config| +# @config.boot_dir = '/absolute/path/to/boot_dir' +# @config.boot_files = lambda { ['/absolute/path/to/boot_dir/file.js'] } +#end +# + +Rails.application.config.action_controller.asset_host = "//localhost:8888" +Rails.application.config.base_url = ENV['BASE_URL'] || "http://localhost:8888"

  4. 摆脱此文件:spec / javascripts / support / jasmine_runner.rb

  5. 希望这有帮助