在某些情况下,我有多个具有相同值的键,因此为了避免重复,我做了如下操作
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: "" ) }
现在,我想在我的double块中传递此哈希,但是每当我这样做时,我都会收到错误消息
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
答案 0 :(得分:0)
正如@engineersmnky所建议的那样,在哈希上使用双splat运算符(** hash)对我有用。