There is a scenario where I have multiple keys with the same value so to avoid that repetition I have done something like below

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: "" )  }

Now I want to pass this hash in my double block but Whenever I do so I get an error

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

1 Answers

0
Aniket Shivam Tiwari On

As suggested by @engineersmnky making use of double splat operator(**hash) over hash worked for me.