【问题标题】:Using where.not in rspec should_receive在 rspec should_receive 中使用 where.not
【发布时间】:2020-11-27 09:30:36
【问题描述】:

我正在尝试通过 rspec 测试 where.not 的参数,但找不到用于在 Active Record 上进行调用的函数。谁能告诉我如何在rspec 中模拟where.not 的课程?我尝试了以下方法:

MyClass.should_receive(:where).not

MyClass.should_receive(:where_not)

MyClass.should_receive(:not_where)

任何帮助将不胜感激!

【问题讨论】:

    标签: ruby-on-rails activerecord rspec


    【解决方案1】:

    在你的情况下,你可以像这样模拟它:expect(Class).to receive(:not).with(id: 101)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-02-11
      • 2012-06-09
      • 2010-11-22
      • 2012-04-05
      • 1970-01-01
      • 2014-05-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多