On Sun, Jul 27, 2008 at 11:56 AM, Steve <[EMAIL PROTECTED]> wrote:
> I can't find it on the RSpec site, and my googling is turning up nothing. Is
> there a way to clear a stub once set? I'm experiencing some behavior where I
> have some nested describes, with "before :each" and I need to change the
> stub from the parent. I thought it would just overwrite the previous stub
> value, but instead it seems to turn the stub into an array making the
> previous value the first element, and then the new value the second.
>
> Thanks,
> Steve
Can you paste your code please? Here's an example I just whipped up
that seems to work fine...I'm using a stub defined inline, a stub
defined in two steps, and a partially stubbed object. They all shadow
the outer stub. What does your code look like?
Pat
describe "outer" do
before(:each) do
@inlined_stub = stub("object", :inlined_stub => :outer)
@verbose = stub("verbose")
@verbose.stub!(:verbose).and_return :outer
@partial = Object.new
@partial.stub!(:partial).and_return :outer
end
it "should work" do
@inlined_stub.inlined_stub.should == :outer
@verbose.verbose.should == :outer
@partial.partial.should == :outer
end
describe "inner" do
before(:each) do
@inlined_stub.stub!(:inlined_stub).and_return :inner
@verbose.stub!(:verbose).and_return :inner
@partial.stub!(:partial).and_return :inner
end
it "should work" do
@inlined_stub.inlined_stub.should == :inner
@verbose.verbose.should == :inner
@partial.partial.should == :inner
end
end
end
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users