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

David Chelimsky dchelimsky at gmail.com
Tue Feb 20 14:51:48 EST 2007


On 2/20/07, James Hughes <hughes.james at gmail.com> wrote:
> 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).

OK - now I'm confused. As I understand it, the problem was that the
failure message was incorrectly displaying a Hash as an Array of
2-element Arrays. This was ONLY in the message, which was only invoked
after the Hash's had been correctly compared. There was never an Array
of Array's being compared.

With that understanding, I don't see how the spec could have passed
simply by saying #with([[][]]).

Please help me understand.

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

Glad to hear it. And thanks for the feedback in general.

Cheers,
David

>
> 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
> >
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list