【问题标题】:rspec failures out of nowhererspec 突然失败
【发布时间】:2011-06-23 00:57:09
【问题描述】:

rspecs 开始失败并出现以下错误:

ruby 1.8.7,rails 3.06。

~/.rvm/rubies/ree-1.8.7-2011.03/bin/ruby -S bundle exec rspec spec/controllers/gift_cards_controller_spec.rb:30
No DRb server is running. Running in local process instead ...
Run filtered including {:line_number=>30}
F

Failures:

  1) GiftCardsController POST to :create for a logged-in User with valid attributes 
     Failure/Error: it { should respond_with(:redirect) }
     NoMethodError:
       undefined method `respond_with' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_1::Nested_1::Nested_1:0x11af4324>
     # ./spec/controllers/gift_cards_controller_spec.rb:30

Finished in 0.93776 seconds
1 example, 1 failure

【问题讨论】:

    标签: ruby-on-rails controller rspec


    【解决方案1】:

    #repond_with 不是应该匹配器吗?确保它位于 Gemfile 中的 RSpec 之后:

    group :development, :test do
      gem 'rspec-rails', '2.4.1'
      gem 'shoulda-matchers', '1.0.0.beta1'
    end
    

    【讨论】:

      【解决方案2】:

      将我的旧 Rails 应用程序升级到 rails 5.0 后出现此错误。然后将以下配置添加到spec_helper.rb,现在它可以正常工作了。

      Shoulda::Matchers.configure do |config|
         config.integrate do |with|
           with.test_framework :rspec
           with.library :rails
         end
      end
      

      【讨论】:

        猜你喜欢
        • 2023-03-17
        • 1970-01-01
        • 1970-01-01
        • 2020-06-25
        • 2021-11-27
        • 2011-09-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多