Hi,

> What if they didn't? Is there a different way you could design this so
> that the interesting bits (The small methods) didn't depend so much on
> the other bits around them?
> 

Well this is for importing vCards...
http://gist.github.com/381384

So for example, I would like to just make a spec that does:

...

  before(:all) do
    card_data = File.read(RAILS_ROOT + "/spec/fixtures/vcard/kirk_no_photo.vcf")
    @vcard = Vcard.create!(:data => card_data)
    Contact.all.map(&:destroy)
  end
  
  describe "finding a contact" do
    
    it "should find the contact when an email for the contact exists" do
      email = Email.create!(:address => "k...@enterprise.com")
      contact = Contact.create!(:first_name => 'James', :last_name => 'Kirk')
      contact.emails << email
      
      @vcard.find_contact.should == contact
    end
  end

...


But, like I said, I am not quite sure how to structure it so that my @card ivar 
gets set..

> Make them public. Move them to their own classes that encapsulate the
> stuff they need to know about (e.g. the "setup".) When you test the
> higher level methods you can mock this stuff. When you test the small
> methods you should call them directly.

So is it bad practice then to use private methods?  I have a habit of doing
that-- but from what you're saying there is no way to test those things 
individually....

Patrick J. Collins
http://collinatorstudios.com
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to