[rspec-users] Spec for 'an array should not include an item'

Neil Cauldwell lists at ruby-forum.com
Wed Oct 1 11:08:59 EDT 2008


Pat Maddox wrote:
> Neil Cauldwell <lists at ruby-forum.com> writes:
>>
>>     respond_to do |format|
>>       format.html
>>       format.xml  { render :xml => @results }
>>     end
>>   end
>>
>> Cheers
> 
> You're stubbing User.search, but you don't actually call it.  search
> ends up being called on a named_scope collection proxy.  So I think that
> this is using the real implementation of both active and search.
> 
> I never saw you post a failure message, so I'm not actually sure what
> problem you're having.  A failure message would be helpful.
> 
> Pat

Pat, I don't see an error message but, I was expecting this to fail 
(which it doesn't, therefore suggesting the spec is broken);

it "should not include any inactive users in an assigned array of user 
results " do
  do_get
  assigns[:results].should_not include(users)
end

I was under the assumption that the above spec checks that we don't have 
any of the users fixtures in the :results. The spec uses this;

   def do_get
     ThinkingSphinx::Search.stub!(:search).and_return(users)
     get :people, :search => "bob"
   end

...so shouldn't the spec fail if we're returning all the users fixtures 
when assigns[:results].should_not include(users)?

Thanks
-- 
Posted via http://www.ruby-forum.com/.


More information about the rspec-users mailing list