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

Ashley Moran ashley.moran at patchspace.co.uk
Sun Sep 28 10:47:30 EDT 2008


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([@story]).to([])
   end

'Story#post_to_twitter should not appear in the Story.unposted list'  
FAILED
result should have been changed to [], but is now []

Anyone know why this fails?  I've looked in change.rb but I can't  
figure it out.

I can make it work with:
   should change { Story.unposted.length }.from(1).to(0)

But that's a weaker test.

Thanks
Ashley

-- 
http://www.patchspace.co.uk/
http://aviewfromafar.net/



More information about the rspec-users mailing list