私は Michael Hartl 本による Ruby On Rails 3 チュートリアル (Learn Rails By Example) をやっています。
私は第 3 章にいますが、私のアウトプットはマイケルが本に書いたものとは異なります。誰か助けてくれませんか?
admin@new-host:~/Desktop/sample_app$ rspec spec/
Exception encountered: #<NameError: uninitialized constant PagesController>
backtrace:
/Users/admin/Desktop/sample_app/spec/controllers/pages_controller_spec.rb:3:in `<top (required)>'
/Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/rspec-core-2.12.2/lib/rspec/core/configuration.rb:789:in `block in load_spec_files'
/Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/rspec-core-2.12.2/lib/rspec/core/configuration.rb:789:in `each'
/Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/rspec-core-2.12.2/lib/rspec/core/configuration.rb:789:in `load_spec_files'
/Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/rspec-core-2.12.2/lib/rspec/core/command_line.rb:22:in `run'
/Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/spork-0.9.2/lib/spork/test_framework/rspec.rb:11:in `run_tests'
/Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/spork-0.9.2/lib/spork/run_strategy/forking.rb:13:in `block in run'
/Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/spork-0.9.2/lib/spork/forker.rb:21:in `block in initialize'
/Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/spork-0.9.2/lib/spork/forker.rb:18:in `fork'
/Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/spork-0.9.2/lib/spork/forker.rb:18:in `initialize'
/Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/spork-0.9.2/lib/spork/run_strategy/forking.rb:9:in `new'
/Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/spork-0.9.2/lib/spork/run_strategy/forking.rb:9:in `run'
/Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/spork-0.9.2/lib/spork/server.rb:48:in `run'
/Users/admin/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/drb/drb.rb:1548:in `perform_without_block'
/Users/admin/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/drb/drb.rb:1508:in `perform'
/Users/admin/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/drb/drb.rb:1586:in `block (2 levels) in main_loop'
/Users/admin/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/drb/drb.rb:1582:in `loop'
/Users/admin/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/drb/drb.rb:1582:in `block in main_loop'
spec_helper.rb:
require 'rubygems'
require 'spork'
#uncomment the following line to use spork with the debugger
#require 'spork/ext/ruby-debug'
Spork.prefork do
# Loading more in this block will cause your tests to run faster. However,
# if you change any configuration or code from libraries loaded here, you'll
# need to restart spork for it take effect.
ENV["RAILS_ENV"] ||= 'test'
unless defined?(Rails)
require File.dirname(__FILE__) + "/../config/environment"
end
require 'rspec/rails'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
RSpec.configure do |config|
# == Mock Framework
#
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
#
# config.mock_with :mocha
# config.mock_with :flexmock
# config.mock_with :rr
config.mock_with :rspec
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures"
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = true
ActiveSupport::Dependencies.clear
end
end
Spork.each_run do
# This code will be run each time you run your specs.
end
Ismaelのアドバイスに基づいています。私はこれを行い、次の出力を得ました:
admin@new-host:~/Desktop/sample_app$ rspec --pattern spec/*_spec.rb
Exception encountered: #<NameError: uninitialized constant PagesController>
backtrace:
/Users/admin/Desktop/sample_app/spec/controllers/pages_controller_spec.rb:3:in `<top (required)>'
/Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/rspec-core-2.12.2/lib/rspec/core/configuration.rb:789:in `block in load_spec_files'
/Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/rspec-core-2.12.2/lib/rspec/core/configuration.rb:789:in `each'
/Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/rspec-core-2.12.2/lib/rspec/core/configuration.rb:789:in `load_spec_files'
/Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/rspec-core-2.12.2/lib/rspec/core/command_line.rb:22:in `run'
/Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/spork-0.9.2/lib/spork/test_framework/rspec.rb:11:in `run_tests'
/Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/spork-0.9.2/lib/spork/run_strategy/forking.rb:13:in `block in run'
/Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/spork-0.9.2/lib/spork/forker.rb:21:in `block in initialize'
/Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/spork-0.9.2/lib/spork/forker.rb:18:in `fork'
/Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/spork-0.9.2/lib/spork/forker.rb:18:in `initialize'
/Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/spork-0.9.2/lib/spork/run_strategy/forking.rb:9:in `new'
/Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/spork-0.9.2/lib/spork/run_strategy/forking.rb:9:in `run'
/Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/spork-0.9.2/lib/spork/server.rb:48:in `run'
/Users/admin/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/drb/drb.rb:1548:in `perform_without_block'
/Users/admin/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/drb/drb.rb:1508:in `perform'
/Users/admin/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/drb/drb.rb:1586:in `block (2 levels) in main_loop'
/Users/admin/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/drb/drb.rb:1582:in `loop'
/Users/admin/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/drb/drb.rb:1582:in `block in main_loop'
admin@new-host:~/Desktop/sample_app$ autotest
loading autotest/rails_rspec2
/Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/ZenTest-4.8.3/lib/autotest.rb:315:in `load': /Users/admin/Desktop/sample_app/.autotest:3: unterminated string meets end of file (SyntaxError)
from /Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/ZenTest-4.8.3/lib/autotest.rb:315:in `block in initialize'
from /Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/ZenTest-4.8.3/lib/autotest.rb:314:in `each'
from /Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/ZenTest-4.8.3/lib/autotest.rb:314:in `initialize'
from /Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/rspec-core-2.12.2/lib/autotest/rspec2.rb:13:in `initialize'
from /Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/rspec-rails-2.12.0/lib/autotest/rails_rspec2.rb:31:in `initialize'
from /Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/ZenTest-4.8.3/lib/autotest.rb:244:in `new'
from /Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/ZenTest-4.8.3/lib/autotest.rb:244:in `run'
from /Users/admin/.rvm/gems/ruby-1.9.3-p327/gems/ZenTest-4.8.3/bin/autotest:6:in `<top (required)>'
from /Users/admin/.rvm/gems/ruby-1.9.3-p327/bin/autotest:19:in `load'
from /Users/admin/.rvm/gems/ruby-1.9.3-p327/bin/autotest:19:in `<main>'
from /Users/admin/.rvm/gems/ruby-1.9.3-p327/bin/ruby_noexec_wrapper:14:in `eval'
from /Users/admin/.rvm/gems/ruby-1.9.3-p327/bin/ruby_noexec_wrapper:14:in `<main>'