> Based on the above I think the Vcard is a good opportunity for a mock.
> That would most likely imply that you create the Vcard somewhere else
> and pass it into this method. Also, you should directly test the

Ok, and regarding mocking--  Something that is still very unclear to me is how
can I affect instance variables through mocking?  If I do:


def master_method
  @foo = "foo"

  slave_method
end

def slave_method

  @foo

end

..

it "should be foo" do

  foo = mock_model(Foo)

  foo.slave_method.should == "foo"

end

...


This will be false because @foo is set in the msater method which I am
bypassing because I just want to test the slave method.  So how can I set an
instance variabel within my spec so that @foo will be properly set?  Should I
use setter/getter methods in this case??

def master_method
  foo = "foo"

  slave_method
end

def slave_method

  foo

end

def foo=(new_foo)
  @foo = new_foo
end

def foo
  @foo
end

......... ?  Is that the way to go???

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