[rspec-users] Spec for 'an array should not include an item'
lists at ruby-forum.com
Wed Oct 1 15:17:30 EDT 2008
Pat Maddox wrote:
> Neil Cauldwell <lists at ruby-forum.com> writes:
>> (which it doesn't, therefore suggesting the spec is broken);
>> def do_get
>> get :people, :search => "bob"
>> ...so shouldn't the spec fail if we're returning all the users fixtures
>> when assigns[:results].should_not include(users)?
> Well, flip the should_not to should and it ought to fail, and give you a
> bit more info. Or print the stuff out. I imagine what's ultimately
> happening is something along the lines of
> [1,2,3].should_not include([1,2,3])
> which is true. [1,2,3] is not an element of the array [1,2,3]. I used
> a simplified example here but it applies equally to an array of User
> Anyway, what kind of debugging have you done to see what objects you're
> actually dealing with? I think doing "p assigns[:results]" and "p
> users" will help point you in the right direction...
Thanks Pat. That really helps. If I do the flip (please ignore the spec
it "should not include any inactive users in an assigned array of user
results " do
Rspec tells me;
should not include any inactive users in an assigned array of user
expected  to include 
I was expecting :results to contain something, otherwise, wouldn't this
spec fail (?), or is nil different to empty?;
it "should assign an array of user results" do
...so I'm one step closer but I'm now a little confused by the other
I haven't done any debugging, I haven't come across any debugging
techniques within Rspec before - please treat me as an absolute newbie
Posted via http://www.ruby-forum.com/.
More information about the rspec-users