0
我正在使用Michael Hartl的紅寶石上軌教程。bundle exec rspec spec/requests/static_pages_spec.rb和error
當我嘗試執行命令:bundle exec rspec spec/requests/static_pages_spec.rb
我收到以下錯誤:
[email protected]:~/rails_projects/sample_app$ bundle exec rspec spec/requests/static_pages_spec.rb
/var/lib/gems/2.3.0/gems/activesupport-3.2.3/lib/active_support/values/time_zone.rb:268: warning: circular argument reference - now
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: /var/lib/gems/2.3.0/gems/actionpack-3.2.3/lib/action_dispatch/middleware/session/abstract_store.rb:28:in `initialize'.
Rack::File headers parameter replaces cache_control after Rack 1.5.
/var/lib/gems/2.3.0/gems/rspec-rails-2.13.1/lib/rspec/rails/fixture_support.rb:19:in `block (2 levels) in <module:FixtureSupport>': private method `fixture_path' called for #<RSpec::Core::Configuration:0x000000017db6e8> (NoMethodError)
Did you mean? fixture_path=
from /var/lib/gems/2.3.0/gems/rspec-rails-2.13.1/lib/rspec/rails/fixture_support.rb:17:in `class_eval'
from /var/lib/gems/2.3.0/gems/rspec-rails-2.13.1/lib/rspec/rails/fixture_support.rb:17:in `block in <module:FixtureSupport>'
from /var/lib/gems/2.3.0/gems/activesupport-3.2.3/lib/active_support/concern.rb:119:in `class_eval'
from /var/lib/gems/2.3.0/gems/activesupport-3.2.3/lib/active_support/concern.rb:119:in `append_features'
from /var/lib/gems/2.3.0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:791:in `include'
from /var/lib/gems/2.3.0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:791:in `safe_include'
from /var/lib/gems/2.3.0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:785:in `block in configure_group'
from /var/lib/gems/2.3.0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:783:in `each'
from /var/lib/gems/2.3.0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:783:in `configure_group'
from /var/lib/gems/2.3.0/gems/rspec-core-2.13.1/lib/rspec/core/world.rb:47:in `configure_group'
from /var/lib/gems/2.3.0/gems/rspec-core-2.13.1/lib/rspec/core/example_group.rb:290:in `set_it_up'
from /var/lib/gems/2.3.0/gems/rspec-core-2.13.1/lib/rspec/core/example_group.rb:241:in `subclass'
from /var/lib/gems/2.3.0/gems/rspec-core-2.13.1/lib/rspec/core/example_group.rb:228:in `describe'
from /var/lib/gems/2.3.0/gems/rspec-core-2.13.1/lib/rspec/core/dsl.rb:18:in `describe'
from /home/mudit/rails_projects/sample_app/spec/requests/static_pages_spec.rb:3:in `<top (required)>'
from /var/lib/gems/2.3.0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load'
from /var/lib/gems/2.3.0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `block in load_spec_files'
from /var/lib/gems/2.3.0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `each'
from /var/lib/gems/2.3.0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load_spec_files'
from /var/lib/gems/2.3.0/gems/rspec-core-2.13.1/lib/rspec/core/command_line.rb:22:in `run'
from /var/lib/gems/2.3.0/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:80:in `run'
from /var/lib/gems/2.3.0/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:17:in `block in autorun'
我static_pages_spec.rb如下:
require 'spec_helper'
describe "Static pages" do
describe "Home page" do
it "should have the content 'Sample App'" do
visit '/static_pages/home'
expect(page).to have_content('Sample App')
end
end
end
我spec_helper.rb如下:
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
RSpec.configure do |config|
config.fixture_path = "#{::Rails.root}/spec/fixtures"
config.use_transactional_fixtures = true
config.infer_base_class_for_anonymous_controllers = false
config.order = "random"
config.include Capybara::DSL
end
我的Gemfile如下:
source 'https://rubygems.org'
gem 'rails', '3.2.3'
group :development, :test do
gem 'sqlite3'
gem 'rspec-rails', '2.13.1'
end
group :test do
gem 'selenium-webdriver', '2.35.1'
gem 'capybara', '2.1.0'
end
gem 'sass-rails', '3.2.4'
gem 'coffee-rails', '3.2.2'
gem 'uglifier', '1.2.3'
gem 'jquery-rails', '3.0.4'
gem 'turbolinks', '1.1.1'
gem 'jbuilder', '1.0.2'
group :production do
gem 'pg', '0.12.2'
end
我試過..但它並沒有爲我工作。 –