我正在阅读'Ruby on Rails3 Tutorial'并且自动测试对我来说很好。然后我更新了我的gemfile中的一些宝石(在第6章开头创建User模型之后,我在本书的在线版本中仔细检查了一些内容,并且我注意到Gemfile中指定了更新的gem版本)。现在自动测试根本不起作用 - 只是说它不能运行任何测试。
我将所有gem版本更改回我最初在Gemfile中指定的版本(即打印书中指定的版本),但我无法再使用autotest了。这是我得到的错误:
$ autotest
loading autotest/rails_rspec2
--------------------------------------------------------------------------------
/Users/Me/.rvm/rubies/ruby-1.9.2-p180/bin/ruby -rrubygems -S /Users/Me/.rvm/gems/ruby- 1.9.2-p180@rails3tutorial/gems/rspec-core-2.6.4/bin/rspec --tty '/Users/Me/rails_projects/sample_app/spec/controllers/pages_controller_spec.rb' '/Users/Me/rails_projects/sample_app/spec/controllers/users_controller_spec.rb' '/Users/Me/rails_projects/sample_app/spec/models/user_spec.rb' '/Users/Me/rails_projects/sample_app/spec/requests/layout_links_spec.rb'
Exception encountered: #<OptionParser::InvalidOption: --tty>
backtrace:
/Users/Me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/rspec-core-2.0.1/lib/rspec/core/option_parser.rb:18:in `parse!'
/Users/Me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/rspec-core-2.0.1/lib/rspec/core/option_parser.rb:4:in `parse!'
/Users/Me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/rspec-core-2.0.1/lib/rspec/core/configuration_options.rb:64:in `parse_command_line_options'
/Users/Me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/rspec-core-2.0.1/lib/rspec/core/configuration_options.rb:46:in `parse_options'
/Users/Me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/rspec-core-2.0.1/lib/rspec/core/command_line.rb:7:in `initialize'
/Users/Me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/rspec-core-2.0.1/lib/rspec/monkey/spork/test_framework/rspec.rb:4:in `new'
/Users/Me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/rspec-core-2.0.1/lib/rspec/monkey/spork/test_framework/rspec.rb:4:in `run_tests'
/Users/Me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/spork-0.8.4/lib/spork/run_strategy/forking.rb:13:in `block in run'
/Users/Me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/spork-0.8.4/lib/spork/forker.rb:21:in `block in initialize'
/Users/Me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/spork-0.8.4/lib/spork/forker.rb:18:in `fork'
/Users/Me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/spork-0.8.4/lib/spork/forker.rb:18:in `initialize'
/Users/Me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/spork-0.8.4/lib/spork/run_strategy/forking.rb:9:in `new'
/Users/Me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/spork-0.8.4/lib/spork/run_strategy/forking.rb:9:in `run'
/Users/Me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/spork-0.8.4/lib/spork/server.rb:47:in `run'
/Users/Me/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/drb/drb.rb:1558:in `perform_without_block'
/Users/Me/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/drb/drb.rb:1518:in `perform'
/Users/Me/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/drb/drb.rb:1592:in `block (2 levels) in main_loop'
/Users/Me/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/drb/drb.rb:1588:in `loop'
/Users/Me/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/drb/drb.rb:1588:in `block in main_loop'
我停下来并重新启动了spork和rails服务器,但是自动测试对我来说仍然不起作用。
这是我在Gemfile中使用较新的gem版本时出现的错误:
$ autotest
loading autotest/rails_rspec2
--------------------------------------------------------------------------------
/Users/Me/.rvm/rubies/ruby-1.9.2-p180/bin/ruby -rrubygems -S /Users/Me/.rvm/gems/ruby- 1.9.2-p180@rails3tutorial/gems/rspec-core-2.6.4/bin/rspec --tty '/Users/Me/rails_projects/sample_app/spec/controllers/pages_controller_spec.rb' '/Users/Me/rails_projects/sample_app/spec/controllers/users_controller_spec.rb' '/Users/Me/rails_projects/sample_app/spec/models/user_spec.rb' '/Users/Me/rails_projects/sample_app/spec/requests/layout_links_spec.rb'
Exception encountered: #<NameError: uninitialized constant PagesController>
backtrace:
/Users/Me/rails_projects/sample_app/spec/controllers/pages_controller_spec.rb:3:in `<top (required)>'
/Users/Me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/rspec-core- 2.6.4/lib/rspec/core/configuration.rb:419:in `block in load_spec_files'
/Users/Me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `map'
/Users/Me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `load_spec_files'
/Users/Me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/rspec-core-2.6.4/lib/rspec/core/command_line.rb:18:in `run'
/Users/Me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/rspec-core-2.6.4/lib/rspec/monkey/spork/test_framework/rspec.rb:5:in `run_tests'
/Users/Me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/spork-0.9.0.rc8/lib/spork/run_strategy/forking.rb:13:in `block in run'
/Users/Me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/spork-0.9.0.rc8/lib/spork/forker.rb:21:in `block in initialize'
/Users/Me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/spork-0.9.0.rc8/lib/spork/forker.rb:18:in `fork'
/Users/Me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/spork-0.9.0.rc8/lib/spork/forker.rb:18:in `initialize'
/Users/Me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/spork-0.9.0.rc8/lib/spork/run_strategy/forking.rb:9:in `new'
/Users/Me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/spork-0.9.0.rc8/lib/spork/run_strategy/forking.rb:9:in `run'
/Users/Me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/spork-0.9.0.rc8/lib/spork/server.rb:48:in `run'
/Users/Me/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/drb/drb.rb:1558:in `perform_without_block'
/Users/Me/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/drb/drb.rb:1518:in `perform'
/Users/Me/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/drb/drb.rb:1592:in `block (2 levels) in main_loop'
/Users/Me/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/drb/drb.rb:1588:in `loop'
/Users/Me/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/drb/drb.rb:1588:in `block in main_loop'
感谢所有回复:
我甚至不确定rspec-core-2.6.4来自哪里(我确实在错误消息中看到了它)。我在Gemfile中尝试的两个'rspec'版本是rspec 2.0.1和rspec-rails 2.6.2。根据建议,这是我尝试的:
Gemfile(这些是本书中的原始版本,曾用于自动测试)
source 'http://rubygems.org'
gem 'rails', '3.0.9' #different in book
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
#***updated gem versions from online book****
#gem 'sqlite3', '1.3.3'
gem 'sqlite3-ruby', '1.2.5', :require => 'sqlite3'
group :development do
#gem 'rspec-rails', '2.6.1'
gem 'rspec-rails', '2.0.1'
gem 'annotate', '2.4.0' #different in book
end
group :test do
#gem 'rspec-rails', '2.6.1'
gem 'rspec', '2.0.1'
gem 'webrat', '0.7.1'
#gem 'spork', '0.9.0.rc8'
gem 'spork', '0.8.4'
end
sample_app Me$ bundle install
Using rake (0.9.2)
Using abstract (1.0.0)
Using activesupport (3.0.9)
Using builder (2.1.2)
Using i18n (0.5.0)
Using activemodel (3.0.9)
Using erubis (2.6.6)
Using rack (1.2.3)
Using rack-mount (0.6.14)
Using rack-test (0.5.7)
Using tzinfo (0.3.29)
Using actionpack (3.0.9)
Using mime-types (1.16)
Using polyglot (0.3.1)
Using treetop (1.4.9)
Using mail (2.2.19)
Using actionmailer (3.0.9)
Using arel (2.0.10)
Using activerecord (3.0.9)
Using activeresource (3.0.9)
Using annotate (2.4.0)
Using bundler (1.0.15)
Using diff-lcs (1.1.2)
Using nokogiri (1.5.0)
Using rdoc (3.8)
Using thor (0.14.6)
Using railties (3.0.9)
Using rails (3.0.9)
Using rspec-core (2.0.1)
Using rspec-expectations (2.0.1)
Using rspec-mocks (2.0.1)
Using rspec (2.0.1)
Using rspec-rails (2.0.1)
Using spork (0.8.4)
Using sqlite3-ruby (1.2.5)
Using webrat (0.7.1)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
sample_app Me$ bundle update
Fetching source index for http://rubygems.org/
Using rake (0.9.2)
Using abstract (1.0.0)
Using activesupport (3.0.9)
Using builder (2.1.2)
Using i18n (0.5.0)
Using activemodel (3.0.9)
Using erubis (2.6.6)
Using rack (1.2.3)
Using rack-mount (0.6.14)
Using rack-test (0.5.7)
Using tzinfo (0.3.29)
Using actionpack (3.0.9)
Using mime-types (1.16)
Using polyglot (0.3.1)
Using treetop (1.4.9)
Using mail (2.2.19)
Using actionmailer (3.0.9)
Using arel (2.0.10)
Using activerecord (3.0.9)
Using activeresource (3.0.9)
Using annotate (2.4.0)
Using bundler (1.0.15)
Using diff-lcs (1.1.2)
Using nokogiri (1.5.0)
Using rdoc (3.8)
Using thor (0.14.6)
Using railties (3.0.9)
Using rails (3.0.9)
Using rspec-core (2.0.1)
Using rspec-expectations (2.0.1)
Using rspec-mocks (2.0.1)
Using rspec (2.0.1)
Using rspec-rails (2.0.1)
Using spork (0.8.4)
Using sqlite3-ruby (1.2.5)
Using webrat (0.7.1)
Your bundle is updated! Use `bundle show [gemname]` to see where a bundled gem is installed.
sample_app Me$ bundle show spork
sample_app Me$ bundle exec spork
/Users/Me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/spork- 0.9.0.rc8/lib/spork/test_framework/cucumber.rb:2: warning: already initialized constant DEFAULT_PORT
/Users/Me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/spork- 0.9.0.rc8/lib/spork/test_framework/cucumber.rb:3: warning: already initialized constant HELPER_FILE
/Users/Me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/spork-0.9.0.rc8/lib/spork/test_framework/rspec.rb:2: warning: already initialized constant DEFAULT_PORT
/Users/Me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/spork-0.9.0.rc8/lib/spork/test_framework/rspec.rb:3: warning: already initialized constant HELPER_FILE
Using RSpec
Loading Spork.prefork block...
Spork is ready and listening on 8989!
但是当我打开一个新的终端窗口时,我做了:
sample_app Me$ autotest
我得到了同样的错误。命令:
sample_app Me$ bundle exec autotest
抛出一个Gem :: LoadError,我认为它不应该工作,因为自动测试不在我的Gemfile中。
当我将Gemfile与更新的gem版本一起使用时,我得到了一个不同的错误:
source 'http://rubygems.org'
gem 'rails', '3.0.9'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
#***updated gem versions from online book****
gem 'sqlite3', '1.3.3'
#gem 'sqlite3-ruby', '1.2.5', :require => 'sqlite3'
group :development do
gem 'rspec-rails', '2.6.1'
#gem 'rspec-rails', '2.0.1'
gem 'annotate', '2.4.0'
end
group :test do
gem 'rspec-rails', '2.6.1'
#gem 'rspec', '2.0.1'
gem 'webrat', '0.7.1'
gem 'spork', '0.9.0.rc8'
#gem 'spork', '0.8.4'
end
sample_app Me$ bundle install
Using rake (0.9.2)
Using abstract (1.0.0)
Using activesupport (3.0.9)
Using builder (2.1.2)
Using i18n (0.5.0)
Using activemodel (3.0.9)
Using erubis (2.6.6)
Using rack (1.2.3)
Using rack-mount (0.6.14)
Using rack-test (0.5.7)
Using tzinfo (0.3.29)
Using actionpack (3.0.9)
Using mime-types (1.16)
Using polyglot (0.3.1)
Using treetop (1.4.9)
Using mail (2.2.19)
Using actionmailer (3.0.9)
Using arel (2.0.10)
Using activerecord (3.0.9)
Using activeresource (3.0.9)
Using annotate (2.4.0)
Using bundler (1.0.15)
Using diff-lcs (1.1.2)
Using nokogiri (1.5.0)
Using rdoc (3.8)
Using thor (0.14.6)
Using railties (3.0.9)
Using rails (3.0.9)
Using rspec-core (2.6.4)
Using rspec-expectations (2.6.0)
Using rspec-mocks (2.6.0)
Using rspec (2.6.0)
Using rspec-rails (2.6.1)
Using spork (0.9.0.rc8)
Using sqlite3 (1.3.3)
Using webrat (0.7.1)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
-
sample_app Me$ bundle update
Fetching source index for http://rubygems.org/
Using rake (0.9.2)
Using abstract (1.0.0)
Using activesupport (3.0.9)
Using builder (2.1.2)
Using i18n (0.5.0)
Using activemodel (3.0.9)
Using erubis (2.6.6)
Using rack (1.2.3)
Using rack-mount (0.6.14)
Using rack-test (0.5.7)
Using tzinfo (0.3.29)
Using actionpack (3.0.9)
Using mime-types (1.16)
Using polyglot (0.3.1)
Using treetop (1.4.9)
Using mail (2.2.19)
Using actionmailer (3.0.9)
Using arel (2.0.10)
Using activerecord (3.0.9)
Using activeresource (3.0.9)
Using annotate (2.4.0)
Using bundler (1.0.15)
Using diff-lcs (1.1.2)
Using nokogiri (1.5.0)
Using rdoc (3.8)
Using thor (0.14.6)
Using railties (3.0.9)
Using rails (3.0.9)
Using rspec-core (2.6.4)
Using rspec-expectations (2.6.0)
Using rspec-mocks (2.6.0)
Using rspec (2.6.0)
Using rspec-rails (2.6.1)
Using spork (0.9.0.rc8)
Using sqlite3 (1.3.3)
Using webrat (0.7.1)
Your bundle is updated! Use `bundle show [gemname]` to see where a bundled gem is installed.
sample_app Me$ bundle show spork
/Users/Me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/spork-0.9.0.rc8
sample_app Me$ bundle exec spork
Using RSpec
Preloading Rails environment
Loading Spork.prefork block...
Spork is ready and listening on 8989!
-
sample_app Me$ autotest
loading autotest/rails_rspec2
--------------------------------------------------------------------------------
/Users/Me/.rvm/rubies/ruby-1.9.2-p180/bin/ruby -rrubygems -S /Users/Me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/rspec-core-2.6.4/bin/rspec --tty '/Users/Me/rails_projects/sample_app/spec/controllers/pages_controller_spec.rb' '/Users/Me/rails_projects/sample_app/spec/controllers/users_controller_spec.rb' '/Users/Me/rails_projects/sample_app/spec/models/user_spec.rb' '/Users/Me/rails_projects/sample_app/spec/requests/layout_links_spec.rb'
Exception encountered: #<NameError: uninitialized constant PagesController>
backtrace:
/Users/Me/rails_projects/sample_app/spec/controllers/pages_controller_spec.rb:3:in `<top (required)>'
/Users/Me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `block in load_spec_files'
/Users/Me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `map'
/Users/Me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `load_spec_files'
/Users/Me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/rspec-core-2.6.4/lib/rspec/core/command_line.rb:18:in `run'
/Users/Me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/rspec-core-2.6.4/lib/rspec/monkey/spork/test_framework/rspec.rb:5:in `run_tests'
/Users/Me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/spork-0.9.0.rc8/lib/spork/run_strategy/forking.rb:13:in `block in run'
/Users/Me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/spork-0.9.0.rc8/lib/spork/forker.rb:21:in `block in initialize'
/Users/Me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/spork-0.9.0.rc8/lib/spork/forker.rb:18:in `fork'
/Users/Me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/spork-0.9.0.rc8/lib/spork/forker.rb:18:in `initialize'
/Users/Me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/spork-0.9.0.rc8/lib/spork/run_strategy/forking.rb:9:in `new'
/Users/Me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/spork-0.9.0.rc8/lib/spork/run_strategy/forking.rb:9:in `run'
/Users/Me/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/spork-0.9.0.rc8/lib/spork/server.rb:48:in `run'
/Users/Me/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/drb/drb.rb:1558:in `perform_without_block'
/Users/Me/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/drb/drb.rb:1518:in `perform'
/Users/Me/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/drb/drb.rb:1592:in `block (2 levels) in main_loop'
/Users/Me/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/drb/drb.rb:1588:in `loop'
/Users/Me/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/drb/drb.rb:1588:in `block in main_loop'
这出现在spork窗口中:
Running tests with args ["--color", "--tty", "/Users/Me/rails_projects/sample_app/spec/controllers/pages_controller_spec.rb", "/Users/Me/rails_projects/sample_app/spec/controllers/users_controller_spec.rb", "/Users/Me/rails_projects/sample_app/spec/models/user_spec.rb", "/Users/Me/rails_projects/sample_app/spec/requests/layout_links_spec.rb"]...
Done.
我通过nuking整个rails3tutorial gemset再次使用autotest。有关这样做的详细信息,请参见第90页第3章。
1) After doing:
$ gem install rails
I started at the beginning of Chapter 3 using the Gemfile with the earlier gem versions(posted above). Followed by:
2) $ bundle install
3) $ rails generate rspec:install
4) Then I continued with the steps on p. 85, Chapter 3:
$ gem install autotest -v 4.3.2 (don't use sudo with rvm!)
$ gem install autotest
(Growl is already installed)
$gem install autotest-fsevent -v 0.2.2
$gem install autotest-growl -v 0.2.4
5) Then before doing:
$ spork --bootstrap
I copied and pasted spec/spec_helper.rb into a text editor, then I deleted spec/spec_helper.rb:
$ rm spec/spec_helper.rb
then:
$ spork --bootstrap
Then I copied and pasted the text in the text editor into the newly created spec/spec_helper.rb
6) $ bundle exec spork
7) Then I opened up a new Terminal window, and did:
$ autotest
因为我是受虐狂,我想我会尝试再次将Gemfile更新到更新的版本,并且在执行'bundle install'和'bundle update'之后,我得到了与以前完全相同的PagesController错误。再次,当我将gem版本更改回我的Gemfile中的早期版本,并且我进行了'bundle install'和'bundle update'时,我得到了那个-tty错误。我将再次核对rails3tutorial gemset,这次我将从我的Gemfile中的较新版本开始,看看是否有效。
我再次修改了rails3tutorial gemset,这次我开始使用包含在线书籍中列出的较新宝石版本的Gemfile,并且:
1)我安装了本书在线版中指定的各种自动测试宝石的新版本。
和
2)我根据本书的在线版本修改了spork使用的spec / spec_helper.rb文件。在线规范/ spec_helper.rb文件与印刷书籍的spec / spec_helper.rb文件不同。
...现在自动测试再次起作用。
因此,切换到在线书中指定的新宝石版本会导致问题,因为较新的宝石版本不适用于我正在使用的印刷书籍spec / spec_helper.rb文件。但是,这并不能解释为什么在我改变我的Gemfile以再次使用旧的gem版本之后,我仍然会遇到错误。据我所知,使用bundler安装不同的gem版本存在问题。 Nuking整个gemset解决了这个问题,但这不是一个好的解决方案。
(osx 10.6.7)
答案 0 :(得分:2)
看起来你正试图运行两个不同版本的RSpec(2.6.4和2.0.1)。 2.6.4设置-tty
选项,2.0.1
无法识别。
bundle update
。bundle exec autotest
而非autotest
。答案 1 :(得分:1)
这可能是known issue with parallel_tests when used with rspec < 2.2 for the tty
option。
您有几个选择:
tty
选项,或者.. 答案 2 :(得分:1)
这可能会有所帮助!
http://blog.chrisblunt.com/rails-configuring-rspec-for-spork/
他说:“解决方案是从spec_helper.rb中移除条件:”
# spec/spec_helper.rb
# ...
# before:
# require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
require File.dirname(__FILE__) + "/../config/environment"
为我工作!
顺便说一下,在require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
有条件的情况下,它有unless?
这本书......
答案 3 :(得分:0)
确保app / controllers /
中有pages_controller.rb答案 4 :(得分:0)
如果您没有想到它,有一个更好的替代自动测试,它被称为 infinity_test ,请在此处查看,https://github.com/tomas-stefano/infinity_test。
我按照这里的说明https://github.com/tomas-stefano/infinity_test/wiki/Customize-Infinity-Test,甚至修改它以满足我的需要,它就像一个魅力。
我已经完成了整个Rail 3 Tutorial两次,自动测试的东西第一次为我工作但是当我更新我的宝石时它就破了。我认为 infinity_test 更容易设置并且有更多选项。
我在Ubuntu 10.10上使用Rails 3.0.9和Rspec 2.5.0
希望这有帮助!