rspec允许where(id:my_id).first

恩特尼尔

我正在针对rspec编写测试,并且需要允许以下行用于Location模型:

Location.where(id: params[:id]).first

但这是不正确的(两个参数而不是一个错误):

allow(Location).to receive(:where, :first).with(id: my_id)

这是这样的:

allow(Location).to receive(:where).with(id: my_id).first

哪种方法是正确的?

BroiSatse

因为它是您可以做的:

allow(Location).to receive(:where).with(id: my_id).and_return double(first: <your Location mock here>)

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

聚合this.querySelector('#my_id')与this。$。my_id

来自分类Dev

从Mobile First获取设备ID

来自分类Dev

Postgres SQL - "my_id" 必须出现在 GROUP BY 子句中或用于聚合

来自分类Dev

filter(_:).first 和 first(where:) 有什么区别?

来自分类Dev

EF Code First 6.1将ID从Int更改为Long

来自分类Dev

在Code First中包含外键ID以保存查询?

来自分类Dev

由Arel生成的Rails 4 first_or_initialize sql double id“ _id_id” sql

来自分类Dev

python only recognizes first line of my input

来自分类Dev

AngularJS - 两个 ng -repeat,其中 first.id = second.id

来自分类Dev

ActiveRecord#first方法是否总是返回具有最小ID的记录?

来自分类Dev

VBA-Excel Finding Finding two week date range and first account ID within this range

来自分类Dev

sql where condition for getting the first and second maxium values

来自分类Dev

Model.where(...)。first属性不是nil,而是显示nil

来自分类Dev

SELECT 50 MAX FIRST PRICES 没有“WHERE”子句

来自分类Dev

Eloquent 查询不使用 where/first 条件。为什么?

来自分类Dev

MySql:从另一个表插入表 SELECT,其中 first_table ID =another_table.id

来自分类Dev

Why my client socket died after first send?

来自分类Dev

Writing my first systemcall(for learning kernel development) in freebsd

来自分类Dev

如何使用Code-First EntityFramework在数据库中将ID保存为字符串

来自分类Dev

HtmlElementCollection的First()

来自分类Dev

Where do I find my Facebook Audience ID?

来自分类Dev

first(where :)方法是否始终为O(n)或使用Set或Dictionary可以为O(1)?

来自分类Dev

为什么在User :: first()上调用方法有效,但User :: where(...)无效?

来自分类Dev

first(where :)方法是否始终为O(n)或使用Set或Dictionary可以为O(1)?

来自分类Dev

Swift How To-检查可选对象数组的First / Where语句-展开并匹配

来自分类Dev

从AngularJS指令标签获取字符串值:my-first-directive =“我想要这个”

来自分类Dev

association.first使用具有has_many关联的FactoryGirl工厂在RSpec功能规范中返回nil

来自分类Dev

association.first使用具有has_many关联的FactoryGirl工厂在RSpec功能规范中返回nil

来自分类Dev

在允许first_name或last_name为null但不能同时为null的rails上进行验证

Related 相关文章

  1. 1

    聚合this.querySelector('#my_id')与this。$。my_id

  2. 2

    从Mobile First获取设备ID

  3. 3

    Postgres SQL - "my_id" 必须出现在 GROUP BY 子句中或用于聚合

  4. 4

    filter(_:).first 和 first(where:) 有什么区别?

  5. 5

    EF Code First 6.1将ID从Int更改为Long

  6. 6

    在Code First中包含外键ID以保存查询?

  7. 7

    由Arel生成的Rails 4 first_or_initialize sql double id“ _id_id” sql

  8. 8

    python only recognizes first line of my input

  9. 9

    AngularJS - 两个 ng -repeat,其中 first.id = second.id

  10. 10

    ActiveRecord#first方法是否总是返回具有最小ID的记录?

  11. 11

    VBA-Excel Finding Finding two week date range and first account ID within this range

  12. 12

    sql where condition for getting the first and second maxium values

  13. 13

    Model.where(...)。first属性不是nil,而是显示nil

  14. 14

    SELECT 50 MAX FIRST PRICES 没有“WHERE”子句

  15. 15

    Eloquent 查询不使用 where/first 条件。为什么?

  16. 16

    MySql:从另一个表插入表 SELECT,其中 first_table ID =another_table.id

  17. 17

    Why my client socket died after first send?

  18. 18

    Writing my first systemcall(for learning kernel development) in freebsd

  19. 19

    如何使用Code-First EntityFramework在数据库中将ID保存为字符串

  20. 20

    HtmlElementCollection的First()

  21. 21

    Where do I find my Facebook Audience ID?

  22. 22

    first(where :)方法是否始终为O(n)或使用Set或Dictionary可以为O(1)?

  23. 23

    为什么在User :: first()上调用方法有效,但User :: where(...)无效?

  24. 24

    first(where :)方法是否始终为O(n)或使用Set或Dictionary可以为O(1)?

  25. 25

    Swift How To-检查可选对象数组的First / Where语句-展开并匹配

  26. 26

    从AngularJS指令标签获取字符串值:my-first-directive =“我想要这个”

  27. 27

    association.first使用具有has_many关联的FactoryGirl工厂在RSpec功能规范中返回nil

  28. 28

    association.first使用具有has_many关联的FactoryGirl工厂在RSpec功能规范中返回nil

  29. 29

    在允许first_name或last_name为null但不能同时为null的rails上进行验证

热门标签

归档