On Oct 23, 2010, at 7:29 PM, Peter Havens wrote:

> On Oct 23, 1:40 pm, Katrina <katrina.o...@gmail.com> wrote:
>> 
>> [...]
>> It fails with the following:
>> expected {:total=>139 #...
>>        got {"total"=>139 #...
>> [...}
> 
> I think the problem you're having is that you're expecting/stubbing
> symbols for your keys, but the keys for parameters are strings.

This hash wasn't a params hash - it was coming directly from a model, and then 
exposed to the view by Rails. The problem is that Rails converts hashes 
assigned to views into HashWithIndifferentAccess, which do not treat Symbols 
and Strings indifferently when comparing complete hashes, even though they let 
you access the keys indifferently. in Katrina's case, this would pass:

  assigns(:summary)[:total].should eq(139)
  assigns(:summary)[:submitted].should eq(97)
  assigns(:summary)[:published].should eq(82)
  assigns(:summary)[:removed].should eq(12)

Make sense?
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to