[rspec-users] Odd parameter munging with with()

James Hughes hughes.james at gmail.com
Tue Feb 20 14:40:10 EST 2007


On 2/20/07, David Chelimsky <dchelimsky at gmail.com> wrote:
> Here's the same output w/ the latest trunk. Note that it shows #with
> correctly receiving a Hash now.

Ok, just one more comment here and then I'll shut up. David, I just
now noticed your comment on the RFE:

"I've fixed the message so it will show you the two hashes (expected
and actual), but I think that getting RSpec to make decisions about
stringifying keys would be a mistake. To that end, I think the right
thing is for you to change your spec to expect a Hash with stringy
keys."

You're right, changing the hash to have string keys was not a burden
but doing this had zero effect on whether the spec passed or not; my
point all along (and sorry if this was never made clear enough) was
that it did seem like a burden to convert my hash to an array of
2-element arrays in order for the spec to pass. Not to mention, this
would break any code under test that was expecting to deal with a hash
(as in the #delete example that I mentioned in a separate mail).

Anyways, thanks again for looking into this. As an aside, I'm really
enjoying using  rspec!

James


>
> 1)
> Spec::Mocks::MockExpectationError in 'a test controller should pass a
> hash to #with (1)'
> #<TestController:0x2578854> expected :amethod with ({"param2"=>"bar",
> "id"=>"1"}) but received it with ({"action"=>"index", "id"=>"1",
> "param2"=>"bar", "controller"=>"test"})
> ./spec/controllers/temp_spec.rb:4:in `index'
> ./spec/controllers/temp_spec.rb:16:
>
> 2)
> Spec::Mocks::MockExpectationError in 'a test controller should pass a
> hash to #with (2)'
> #<TestController:0x2516ec4> expected :amethod with ({"param2"=>"bar",
> "id"=>"1"}) but received it with ({"action"=>"index", "id"=>"1",
> "param2"=>"bar", "controller"=>"test"})
> ./spec/controllers/temp_spec.rb:4:in `index'
> ./spec/controllers/temp_spec.rb:19:
>
> 3)
> Spec::Mocks::MockExpectationError in 'a test controller should pass a
> hash to #with (3)'
> #<TestController:0x2461d58> expected :amethod with ({:only_path=>true,
> "param2"=>"bar", "id"=>"1", :action=>:index}) but received it with
> ({"action"=>"index", "id"=>"1", "param2"=>"bar",
> "controller"=>"test"})
> ./spec/controllers/temp_spec.rb:4:in `index'
> ./spec/controllers/temp_spec.rb:22:
>
> I have NO idea yet about  :only_path. I'll keep you posted...
>
> >
> >  rgds from "Confused of Hampshire".
> >
> >
> >
> >
> > _______________________________________________
> > rspec-users mailing list
> > rspec-users at rubyforge.org
> > http://rubyforge.org/mailman/listinfo/rspec-users
> >
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list