On Thu, Oct 30, 2008 at 11:41 AM, Rémi Gagnon <[EMAIL PROTECTED]> wrote:

> I do agree, That's what we're gonna do. it was just an example.
> But what if we want to test find_thingy(in model spec) to make sure the
> :conditions is set properly?


You are probably more interested in the fact that find_thingy works rather
then it sets a bunch of conditions. Perhaps something like the below would
work for you:

it "can find things by blank and blank" do
   thing1 = Thing.create! :nte_no => 1, vaat_id_type_statut_pcpa => 2
   thing2 = Thing.create! :nte_no => 2, vaat_id_type_statut_pcpa => 3
   Thing.find_by_thingy(1,2).should == thing1
   Thing.find_by_thingy(2,3).should == thing2
end

If you have a way of generating "things" that are valid, then I'd use that
mechanism and pass in the attributes you are specifically going to be
testing against (so they stand out in the example that that's what matters
in the example).

I know the above example breaks the one assertion per test guideline people
strive to adhere to, but I think it is ok.  If there are more examples that
should be used to make sure find_thingy works then I'd break out a separate
describe block and have multiple 'it' examples,


-- 
Zach Dennis
http://www.continuousthinking.com
http://www.mutuallyhuman.com
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to