加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 更新shoulda-matchers后的undefined方法’assi

发布时间:2020-12-16 21:12:46 所属栏目:百科 来源:网络整理
导读:我在我的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
我在我的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版本中删除了此方法?

解决方法

是的,以下方法在版本1.5.0中已弃用,并在版本2.0.0的shoulda-matcher中删除.

> 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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读