【发布时间】:2019-05-17 06:25:43
【问题描述】:
在这种情况下,我有多个具有相同值的键,因此为了避免重复,我做了类似下面的操作
sports = [:cricket,:football,:basketball,:baseball,:rugby,:swimming,:table_tennis,:soccer,:karate]
final_hash = Hash.new
sports.each{|d| final_hash[d] = OpenStruct.new(categories: [], count: [], user_hash: {}, sport_count: [], options: {}, period: "",stat_type: "" ) }
现在我想在我的双块中传递这个哈希,但是每当我这样做时都会出错
context 'For users details Page' do
it 'should give the data' do
###now I want to pass the hash SO can anyone guide me how can I do it
presenter = double(UserPresenter, id: 1, sector_name: nil, final_hash)
end
end
【问题讨论】:
-
**final_hash应该这样做。**会将Hash分解为参数 -
@engineersmnky 成功了,谢谢
标签: ruby-on-rails rspec rspec3