Re: [rspec-users] Should change not comparing arrays how I expected

2008-09-28 Thread Michael Latta
I think the difference comes down to whether you are writing specs or tests. It is good enough for RSpec or Cucumber to fake out AR proxies if all you are doing is testing something. If it is a spec, then I believe that having the framework fake out the test is very dangerous, because a r

Re: [rspec-users] Should change not comparing arrays how I expected

2008-09-28 Thread Ashley Moran
On Sep 28, 2008, at 7:52 pm, David Chelimsky wrote: What you're proposing could be resolved with an argument constraint that's been discussed in some other threads on this list - something like: lambda {...}.should change{...}.to(array_consisting_of(...)) I'd prefer this as it lets us keep t

Re: [rspec-users] Should change not comparing arrays how I expected

2008-09-28 Thread Ashley Moran
On Sep 28, 2008, at 5:01 pm, David Chelimsky wrote: Wow. OK - here's what I figured out. Talk about insidious bugs! This is actually quite a bit different from what I thought. There are two lambdas involved here: lambda { 1st lambda: expression that should cause the change }.should change{

Re: [rspec-users] Should change not comparing arrays how I expected

2008-09-28 Thread Pat Maddox
Michael Latta <[EMAIL PROTECTED]> writes: > David, > > It seems to me that the root of the problem is that the specification > is incorrect. Since Rails returns association proxies the > specification fails because it does not specify what the behavior > should be. I would suggest that instead o

Re: [rspec-users] Should change not comparing arrays how I expected

2008-09-28 Thread Michael Latta
The constraint looks good. ar_proxy_of(...) for this case? Or is your constraint specified as making a copy? Your patch seems to be narrow enough that that is also workable. As you say, it is Rails that is causing the surprise. Michael On Sep 28, 2008, at 11:52 AM, David Chelimsky wro

Re: [rspec-users] Should change not comparing arrays how I expected

2008-09-28 Thread David Chelimsky
On Sun, Sep 28, 2008 at 1:18 PM, Michael Latta <[EMAIL PROTECTED]> wrote: > David, > > It seems to me that the root of the problem is that the specification is > incorrect. Since Rails returns association proxies the specification fails > because it does not specify what the behavior should be. I

Re: [rspec-users] Should change not comparing arrays how I expected

2008-09-28 Thread David Chelimsky
On Sun, Sep 28, 2008 at 1:44 PM, Michael Latta <[EMAIL PROTECTED]> wrote: > Is your patch AR proxy specific? If it is for any collection, it prevents > two collections from being compared for equality. I have had many examples > of collections that are not simple containers, and only comparing th

Re: [rspec-users] Should change not comparing arrays how I expected

2008-09-28 Thread Michael Latta
Is your patch AR proxy specific? If it is for any collection, it prevents two collections from being compared for equality. I have had many examples of collections that are not simple containers, and only comparing the contents would be equally invalid as the simple equality on AR proxies

Re: [rspec-users] Should change not comparing arrays how I expected

2008-09-28 Thread Michael Latta
David, It seems to me that the root of the problem is that the specification is incorrect. Since Rails returns association proxies the specification fails because it does not specify what the behavior should be. I would suggest that instead of patching the change matcher, that you shoul

Re: [rspec-users] Should change not comparing arrays how I expected

2008-09-28 Thread David Chelimsky
On Sun, Sep 28, 2008 at 11:01 AM, David Chelimsky <[EMAIL PROTECTED]> wrote: > On Sun, Sep 28, 2008 at 10:43 AM, David Chelimsky <[EMAIL PROTECTED]> wrote: >> On Sun, Sep 28, 2008 at 9:47 AM, Ashley Moran >> <[EMAIL PROTECTED]> wrote: >>> Hi >>> >>> Just had a surprising result: >>> >>> it "should

Re: [rspec-users] Should change not comparing arrays how I expected

2008-09-28 Thread David Chelimsky
On Sun, Sep 28, 2008 at 10:43 AM, David Chelimsky <[EMAIL PROTECTED]> wrote: > On Sun, Sep 28, 2008 at 9:47 AM, Ashley Moran > <[EMAIL PROTECTED]> wrote: >> Hi >> >> Just had a surprising result: >> >> it "should not appear in the Story.unposted list" do >>@story.save >>lambda { >> @s

Re: [rspec-users] Should change not comparing arrays how I expected

2008-09-28 Thread David Chelimsky
On Sun, Sep 28, 2008 at 9:47 AM, Ashley Moran <[EMAIL PROTECTED]> wrote: > Hi > > Just had a surprising result: > > it "should not appear in the Story.unposted list" do >@story.save >lambda { > @story.post_to_twitter(@twitter_client) >}.should change { Story.unposted }.from([EMAIL

[rspec-users] Should change not comparing arrays how I expected

2008-09-28 Thread Ashley Moran
Hi Just had a surprising result: it "should not appear in the Story.unposted list" do @story.save lambda { @story.post_to_twitter(@twitter_client) }.should change { Story.unposted }.from([EMAIL PROTECTED]).to([]) end 'Story#post_to_twitter should not appear in the Story.un