【问题标题】:Jasmine runner at '/specs' returned a 302 error: Found'/specs' 处的 Jasmine runner 返回 302 错误:找到
【发布时间】:2013-06-18 19:53:35
【问题描述】:

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

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

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

有什么线索吗? 谢谢

【问题讨论】:

  • 您被重定向可能是因为设计导致授权失败。不知何故,您需要授权访问此路由。
  • 是的,我就是这个错误。谢谢!
  • @EmilianoZilocchi 你能分享这个问题的解决方案吗?谢谢
  • @xiaopang 看到我的回答。如果有帮助,请告诉我

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


【解决方案1】:

这就是它解决问题的原因(我为更新版本做了升级):

  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

希望对你有帮助

【讨论】:

    猜你喜欢
    • 2017-09-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-11
    • 2013-12-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多