2

So as a beginner I am following Michael Hart's ruby on rails 2nd edition tutorial !

when I run command line with the integration test module

rspec test/integration/static_pages_test.rb

it's not showing what Hartl's getting. Instead it's showing this :

/Users/Name/rails_testprojects/protego/test/integration/static_pages_test.rb:1:in `require': no such file to load -- test_helper (LoadError)
    from /Users/Name/rails_testprojects/protego/test/integration/static_pages_test.rb:1:in `<top (required)>'
    from /Users/Name/.rvm/gems/ruby-1.9.2-p320@twitclone/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `load'
    from /Users/Name/.rvm/gems/ruby-1.9.2-p320@twitclone/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `block in load_spec_files'
    from /Users/Name/.rvm/gems/ruby-1.9.2-p320@twitclone/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `map'
    from /Users/Name/.rvm/gems/ruby-1.9.2-p320@twitclone/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `load_spec_files'
    from /Users/Name/.rvm/gems/ruby-1.9.2-p320@twitclone/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:22:in `run'
    from /Users/Name/.rvm/gems/ruby-1.9.2-p320@twitclone/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:69:in `run'
    from /Users/Name/.rvm/gems/ruby-1.9.2-p320@twitclone/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:8:in `block in autorun'

Note : In Hartl's tutorial , the integration test is in a different folder called !

bundle exec rspec spec/requests/static_pages_spec.rb

can someone please explain what's going on ? I am a total beginner and have just started following his tutorials !

4

1 回答 1

2

您说您正在关注Michael Hartl 的 Rails Tutorial book,但实际上您并没有关注它;至少不像要求的那么严格;-)

Rails 教程书使用RSpec作为首选的测试框架。在 rspec 中,所有的测试文件都在spec文件夹下,并且被称为specs.

默认情况下,Rails带有Test::Unit测试框架,它将文件放在test文件夹下。

你正在混合它们并且变得困惑。

我建议你坚持使用 Rails 教程书中的内容,并严格按照那里的说明来充分利用你在学习 Rails 上所花费的时间。

于 2013-05-27T09:29:46.920 回答