小编Eli*_*jah的帖子

捆绑exec rspec VS rspec规范

Ruby 1.9.2 Rails 3.1

这是问题bundle exec rspec spec/不起作用,但rspec spec/运行正常.

当我运行时c:\RailsInstaller\work\apptwit>bundle exec rspec spec/(这是我的应用程序所在的目录,因此不需要指定规范的路径)我收到了

c:/RailsInstaller/work/apptwit/spec/controllers/pages_controller_spec.rb:1:in `require': no such file to load -- spec_he lper (LoadError)
        from c:/RailsInstaller/work/apptwit/spec/controllers/pages_controller_spec.rb:1:in `<top (required)>'
        from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:459:i
n `load'
        from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:459:i
n `block in load_spec_files'
        from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:459:i
n `map'
        from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:459:i
n `load_spec_files'
        from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/command_line.rb:18:in
`run'
        from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/runner.rb:80:in `run_i
n_process'
        from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/runner.rb:69:in `run'
        from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/runner.rb:10:in `block
 in autorun'
Run Code Online (Sandbox Code Playgroud)

/ spec目录中存在spec_helper.rb.

所以基本上我有两个问题:

  1. 为什么不bundle exec rspec spec/工作而rspec spec/没有问题?

  2. 这两个命令有什么区别?

rspec2 ruby-on-rails-3

6
推荐指数
1
解决办法
1万
查看次数

基本的http身份验证 - 会话的持续时间

我已配置基本身份验证(在控制器中)

在控制器文件中的所有内容

before_filter :check_logged_in, :only => [:edit, :update, :destroy]
Run Code Online (Sandbox Code Playgroud)

在文件的底部:

 private
  def check_logged_in
    authenticate_or_request_with_http_basic("Ads") do |username, password|
            username == "admin" && password == "apple"
    end
end
Run Code Online (Sandbox Code Playgroud)

它就像一个魅力,但有一件事我不明白 - 当我提供用户名和密码时,它会长时间保持登录状态,当我点击"删除"或"更新"特定条目时我会我没有得到再次提示.我认为出了问题,但是当我打开另一个浏览器时 - 它再次提示我,但只有一次,我没有;我必须对其余的进行身份验证.然后我认为这是一个cookie问题,但即使我删除了Chrome中的所有Cookie,也没有任何改变.所以我有几个问题:

  1. 有什么方法可以说我要经过多长时间的认证?
  2. 每次点击这里提到的资源时,有什么方法可以提示进行身份验证:check_logged_in, :only => [:edit, :update, :destroy]吗?

basic-authentication ruby-on-rails-3

2
推荐指数
1
解决办法
1307
查看次数