1

これは、私の spec/requests/static_pages_spec.rb ファイルにあるものです

require 'spec_helper'

describe "Static pages" do

  subject { page }

  describe "Home page" do
    before { visit root_path }

    it { should have_content('Sample App') }
    it { should have_title(full_title('')) }
    it { should_not have_title('| Home') }
  end

  describe "Help page" do
    before { visit help_path }

    it { should have_content('Help') }
    it { should have_title(full_title('Help')) }
  end

  describe "About page" do
    before { visit about_path }

    it { should have_content('About') }
    it { should have_title(full_title('About Us')) }
  end

  describe "Contact page" do
    before { visit contact_path }

    it { should have_content('Contact') }
    it { should have_title(full_title('Contact')) }
  end
end

これは、実行時に表示されるエラー メッセージです。bundle exec rspec spec/requests/static_pages_spec.rb

    SECURITY WARNING: No secret option provided to Rack::Session::Cookie.
        This poses a security threat. It is strongly recommended that you
        provide a secret to prevent exploits that may be possible from crafted
        cookies. This will not be supported in future versions of Rack, and
        future versions will even invalidate your existing user cookies.

        Called from: /usr/local/rvm/gems/ruby-2.0.0-p247/gems/actionpack-3.2.1/lib/action_dispatch/middleware/session/abstract_store.rb:28:in `initialize'.
Rack::File headers parameter replaces cache_control after Rack 1.5.
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/actionpack-3.2.1/lib/action_dispatch/routing/mapper.rb:258:in `merge': no implicit conversion of String into Hash (TypeError)
  from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/actionpack-3.2.1/lib/action_dispatch/routing/mapper.rb:258:in `root'
  from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/actionpack-3.2.1/lib/action_dispatch/routing/mapper.rb:1315:in `root'
  from /Users/StevenW/Documents/Code/rails_projects/sample_app/config/routes.rb:2:in `block in <top (required)>'
  from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/actionpack-3.2.1/lib/action_dispatch/routing/route_set.rb:272:in `instance_exec'
  from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/actionpack-3.2.1/lib/action_dispatch/routing/route_set.rb:272:in `eval_block'
  from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/actionpack-3.2.1/lib/action_dispatch/routing/route_set.rb:249:in `draw'
  from /Users/StevenW/Documents/Code/rails_projects/sample_app/config/routes.rb:1:in `<top (required)>'
  from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:245:in `load'
  from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:245:in `block in load'
  from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:236:in `load_dependency'
  from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:245:in `load'
  from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/railties-3.2.1/lib/rails/application/routes_reloader.rb:40:in `block in load_paths'
  from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/railties-3.2.1/lib/rails/application/routes_reloader.rb:40:in `each'
  from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/railties-3.2.1/lib/rails/application/routes_reloader.rb:40:in `load_paths'
  from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/railties-3.2.1/lib/rails/application/routes_reloader.rb:16:in `reload!'
  from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/railties-3.2.1/lib/rails/application/routes_reloader.rb:26:in `block in updater'
  from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/activesupport-3.2.1/lib/active_support/file_update_checker.rb:78:in `call'
  from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/activesupport-3.2.1/lib/active_support/file_update_checker.rb:78:in `execute'
  from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/railties-3.2.1/lib/rails/application/routes_reloader.rb:27:in `updater'
  from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/railties-3.2.1/lib/rails/application/routes_reloader.rb:7:in `execute_if_updated'
  from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/railties-3.2.1/lib/rails/application/finisher.rb:66:in `block in <module:Finisher>'
  from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/railties-3.2.1/lib/rails/initializable.rb:30:in `instance_exec'
  from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/railties-3.2.1/lib/rails/initializable.rb:30:in `run'
  from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/railties-3.2.1/lib/rails/initializable.rb:55:in `block in run_initializers'
  from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/railties-3.2.1/lib/rails/initializable.rb:54:in `each'
  from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/railties-3.2.1/lib/rails/initializable.rb:54:in `run_initializers'
  from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/railties-3.2.1/lib/rails/application.rb:136:in `initialize!'
  from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/railties-3.2.1/lib/rails/railtie/configurable.rb:30:in `method_missing'
  from /Users/StevenW/Documents/Code/rails_projects/sample_app/config/environment.rb:5:in `<top (required)>'
  from /Users/StevenW/Documents/Code/rails_projects/sample_app/spec/spec_helper.rb:3:in `require'
  from /Users/StevenW/Documents/Code/rails_projects/sample_app/spec/spec_helper.rb:3:in `<top (required)>'
  from /Users/StevenW/Documents/Code/rails_projects/sample_app/spec/requests/static_pages_spec.rb:1:in `require'
  from /Users/StevenW/Documents/Code/rails_projects/sample_app/spec/requests/static_pages_spec.rb:1:in `<top (required)>'
  from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.5/lib/rspec/core/configuration.rb:896:in `load'
  from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.5/lib/rspec/core/configuration.rb:896:in `block in load_spec_files'
  from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.5/lib/rspec/core/configuration.rb:896:in `each'
  from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.5/lib/rspec/core/configuration.rb:896:in `load_spec_files'
  from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.5/lib/rspec/core/command_line.rb:22:in `run'
  from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.5/lib/rspec/core/runner.rb:80:in `run'
  from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/rspec-core-2.14.5/lib/rspec/core/runner.rb:17:in `block in autorun'

Security Warning を回避するために別の投稿を読みましたが、その下にある残りのエラーについてどうすればよいかわかりません。よろしくお願いいたします。

4

4 に答える 4

2

スタック トレースの一番上の行:

/usr/local/rvm/gems/ruby-2.0.0-p247/gems/actionpack-3.2.1
   /lib/action_dispatch/routing/mapper.rb:258:in `merge': 
   no implicit conversion of String into Hash (TypeError)

これにより、ルートに無効なものがあると思われます。何かうまくいきますか?

于 2013-08-20T18:27:01.780 に答える
0

私は自分で問題を解決することができました。何が問題だったのか正確にはわかりませんが、Rails 4.0 と Ruby 2.0 にアップグレードした後、アプリをゼロから始めました (これが実行可能なオプションなのか、それともチュートリアルを進めているのかはわかりません)。エラーを取得します。

これが詳細な回答や説明ではないことは承知していますが、物事を開始して実行したいだけであれば、これが役立つことを願っています!

于 2014-02-08T18:56:14.363 に答える