bon*_*fer 2 ruby-on-rails mocking ruby-on-rails-3
我想模拟/存根:
@the_bill = GovKit::OpenCongress::Bill.find_by_idents("112-s368").first
用于我的测试.
返回我想要为我的测试目的修复的以下对象:
--- !ruby/object:GovKit::OpenCongress::Bill
bill_type: s
co_sponsors:
- !ruby/object:GovKit::OpenCongress::Person {}
id: 68340
introduced: 1297836000
most_recent_actions:
- result:
created_at: "2011-02-17T07:45:50Z"
govtrack_order:
amendment_id:
text: Read twice and referred to the Committee on Agriculture, Nutrition, and Forestry.
date: 1297836000
how:
id: 287979
vote_type:
type: BillAction
roll_call_id:
action_type: action
datetime: "2011-02-16T00:00:00Z"
where:
bill_id: 68340
roll_call_number:
- result:
created_at: "2011-02-17T07:45:49Z"
govtrack_order:
amendment_id:
text:
date: 1297836000
how:
id: 287978
vote_type:
type: BillAction
roll_call_id:
action_type: introduced
datetime: "2011-02-16T00:00:00Z"
where:
bill_id: 68340
roll_call_number:
number: 368
plain_language_summary:
recent_blogs: []
我已经尝试过Factory_girl(不能做,不是基于模型的对象),Fabrication(仍然是相同的问题)和OpenStruct,可能是可能的,但是在将yaml转换为OpenStruct并将模拟放在正确的位置时遇到了麻烦.
现在,我正在我的测试中进行api调用,而不是我想要的.我在想webmock是我的解决方案,但我在文档中找不到如何只加载一个简单的对象.
| 归档时间: |
|
| 查看次数: |
750 次 |
| 最近记录: |