【问题标题】:Rspec 3.0.0 Ruby on railsRspec 3.0.0 Ruby on rails
【发布时间】:2014-05-19 16:39:24
【问题描述】:

我用过 gem 'rspec-rails', "~> 2.14.2" 我所有的测试都有效。现在我安装了 gem 'rspec', '~> 3.0.0.beta' 我明白了:

henio@henio-Toshiba:~/git/EduWords$ bundle exec rspec
/home/henio/.rvm/gems/ruby-2.1.1/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:229:in `require': cannot load such file -- rspec/rails (LoadError)
    from /home/henio/.rvm/gems/ruby-2.1.1/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:229:in `block in require'
    from /home/henio/.rvm/gems/ruby-2.1.1/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:214:in `load_dependency'
    from /home/henio/.rvm/gems/ruby-2.1.1/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:229:in `require'
    from /home/henio/git/EduWords/spec/spec_helper.rb:4:in `<top (required)>'
    from /home/henio/git/EduWords/spec/features/languages_pages_spec.rb:1:in `require'
    from /home/henio/git/EduWords/spec/features/languages_pages_spec.rb:1:in `<top (required)>'
    from /home/henio/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.0.rc1/lib/rspec/core/configuration.rb:1051:in `load'
    from /home/henio/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.0.rc1/lib/rspec/core/configuration.rb:1051:in `block in load_spec_files'
    from /home/henio/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.0.rc1/lib/rspec/core/configuration.rb:1051:in `each'
    from /home/henio/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.0.rc1/lib/rspec/core/configuration.rb:1051:in `load_spec_files'
    from /home/henio/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.0.rc1/lib/rspec/core/runner.rb:97:in `setup'
    from /home/henio/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.0.rc1/lib/rspec/core/runner.rb:85:in `run'
    from /home/henio/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.0.rc1/lib/rspec/core/runner.rb:70:in `run'
    from /home/henio/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.0.rc1/lib/rspec/core/runner.rb:38:in `invoke'
    from /home/henio/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.0.rc1/exe/rspec:4:in `<top (required)>'
    from /home/henio/.rvm/gems/ruby-2.1.1/bin/rspec:23:in `load'
    from /home/henio/.rvm/gems/ruby-2.1.1/bin/rspec:23:in `<main>'
    from /home/henio/.rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in `eval'
    from /home/henio/.rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in `<main>'

我正在使用 Rails 4.0.3 和 Ruby 2.1.1p76。我做了bundle install。我做错了什么?

【问题讨论】:

    标签: ruby-on-rails ruby rspec gem


    【解决方案1】:

    如果您使用的是 Rails,则应使用 rspec-rails 将 Rails 与 RSpec 集成。将您的 gem 要求更改为:

    gem 'rspec-rails', '~> 3.0.0.beta'
    

    RSpec 3 introduces significant changes,因此您必须更新一些规范。

    【讨论】:

    • 好的,我改变了它,但现在几乎所有的测试都失败了。 f.e rspec ./spec/routing/tags_routing_spec.rb:14 # TagsController 路由标签路由到#edit
    • 这是意料之中的,因为 RSpec 3 改变了很多东西。为什么要升级?
    • 如果您需要帮助找出规格现在失败的原因,您应该提出一个新问题。
    • 不客气;如果您将问题标记为已回答,其他人会认为您不需要任何建议。
    猜你喜欢
    • 1970-01-01
    • 2014-03-20
    • 2015-10-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多