【问题标题】:undefined method 'assign_to' after updating shoulda-matchers更新应该匹配器后未定义的方法'assign_to'
【发布时间】:2013-04-15 22:21:04
【问题描述】:

我在我的 rails 项目的 Gemfile 中将 'shoulda-matchers' 从版本 1.4.2 更新到了 2.0.0,现在当我运行我的 rspec 测试时,它给了我以下错误

undefined method `assign_to' for #<RSpec::Core::ExampleGroup::Nested_4::Nested_1::Nested_4::Nested_1:0x007fc96eaaaf48>

在新的 2.0.0 版本中是否删除了此方法?

【问题讨论】:

    标签: ruby-on-rails testing rspec gem shoulda


    【解决方案1】:

    是的,以下方法在 1.5.0 版中已被弃用,并在 shoulda-matchers 的 2.0.0 版中被删除。

    • assign_to
    • respond_with_content_type
    • query_the_database
    • validate_format_of
    • have_sent_email
    • permit(强参数匹配器)
    • delegate_method

    如果您当前正在使用这些方法,开发人员建议您以其他方式测试代码。

    有关更改的简要列表,您可以访问https://github.com/thoughtbot/shoulda-matchers/blob/master/NEWS.md#v-200

    有关更改和删除这些方法的原因的更详细列表,您可以访问他们的博客http://robots.thoughtbot.com/post/47031676783/shoulda-matchers-2-0

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-19
      • 1970-01-01
      • 2019-07-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多