我正在尝试rails3。我正在使用railstutorial 网站来探索有关 rails3 的更多信息;本教程一开始就非常好(我对 rails2 的经验很少)。
我有一个 rspec 问题,它目前阻碍了我的进步。看到教程推荐使用rspec2.0.0.beta.18 gem;我改为使用安装 rspec2.0.0.beta.20 gem
bundle install
但是我发现这个版本的 rspec 存在问题 我的 rspec for integration_test 看起来像:
describe "LayoutLinks" do
it "should have a About page at '/about'" do
get '/about'
response.should have_selector('h1', :content => "About Us")
end
end
失败看起来像:
Failures:
1) LayoutLinks should have a About page at '/about'
Failure/Error: Unable to find matching line from backtrace
stack level too deep
# /home/arun/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/forwardable.rb:185
(注意:那些看过第 5 章的人在理解上下文时不会有问题。)
如果我在 Gemfile 中将 rspec 版本更改为 2.0.0.beta.18 并运行 rspec 我会收到以下错误
arun@ubuntu-world:~/Project/Rails/rails3/sample_app$ rspec spec/
/home/arun/.rvm/gems/ruby-1.9.2-p0/gems/bundler-1.0.0/lib/bundler/runtime.rb:27:in `block in setup': You have already activated rspec-core 2.0.0.beta.20, but your Gemfile requires rspec-core 2.0.0.beta.18. Consider using bundle exec. (Gem::LoadError)
from /home/arun/.rvm/gems/ruby-1.9.2-p0/gems/bundler-1.0.0/lib/bundler/spec_set.rb:12:in `block in each'
from /home/arun/.rvm/gems/ruby-1.9.2-p0/gems/bundler-1.0.0/lib/bundler/spec_set.rb:12:in `each'
from /home/arun/.rvm/gems/ruby-1.9.2-p0/gems/bundler-1.0.0/lib/bundler/spec_set.rb:12:in `each'
from /home/arun/.rvm/gems/ruby-1.9.2-p0/gems/bundler-1.0.0/lib/bundler/runtime.rb:17:in `setup'
from /home/arun/.rvm/gems/ruby-1.9.2-p0/gems/bundler-1.0.0/lib/bundler.rb:100:in `setup'
from /home/arun/Project/Rails/rails3/sample_app/config/boot.rb:8:in `<top (required)>'
from <internal:lib/rubygems/custom_require>:29:in `require'
from <internal:lib/rubygems/custom_require>:29:in `require'
from /home/arun/Project/Rails/rails3/sample_app/config/application.rb:1:in `<top (required)>'
from <internal:lib/rubygems/custom_require>:29:in `require'
from <internal:lib/rubygems/custom_require>:29:in `require'
from /home/arun/Project/Rails/rails3/sample_app/config/environment.rb:2:in `<top (required)>'
from <internal:lib/rubygems/custom_require>:29:in `require'
from <internal:lib/rubygems/custom_require>:29:in `require'
from /home/arun/Project/Rails/rails3/sample_app/spec/spec_helper.rb:3:in `<top (required)>'
from <internal:lib/rubygems/custom_require>:29:in `require'
from <internal:lib/rubygems/custom_require>:29:in `require'
from /home/arun/Project/Rails/rails3/sample_app/spec/requests/layout_links_spec.rb:1:in `<top (required)>'
from /home/arun/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.0.0.beta.20/lib/rspec/core/configuration.rb:302:in `load'
from /home/arun/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.0.0.beta.20/lib/rspec/core/configuration.rb:302:in `block in load_spec_files'
from /home/arun/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.0.0.beta.20/lib/rspec/core/configuration.rb:302:in `map'
from /home/arun/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.0.0.beta.20/lib/rspec/core/configuration.rb:302:in `load_spec_files'
from /home/arun/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.0.0.beta.20/lib/rspec/core/command_line.rb:18:in `run'
from /home/arun/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.0.0.beta.20/lib/rspec/core/runner.rb:46:in `run_in_process'
from /home/arun/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.0.0.beta.20/lib/rspec/core/runner.rb:37:in `run'
from /home/arun/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.0.0.beta.20/lib/rspec/core/runner.rb:10:in `block in autorun'