[rspec-users] why should_receive doesn't work, but stub does.

Zhenning Guan lists at ruby-forum.com
Tue Jul 14 05:49:16 EDT 2009


  before(:each) do
     @myinstance = GetHtml.new
  end



  it "should be a Hyricot" do
    hy = open('test.html') {|f| Hpricot f}
    @myinstance.should_receive(:find_html).with("file:///test_url").and_return(hy)

  end
++++++++++++++++++++++++++++++++++
  it "should be a Hyricot" do
    hy = open('test.html') {|f| Hpricot f}
    @myinstance.stub!(:find_html).with("file:///test_url").and_return(hy)

  end
++++++++++++++++++++++++++++++++++


expected ................ once, but received it 0 times


I have a find_html method in my GetHtml class, but why can't
should_receive run successfuly? but use stub!, it can.
-- 
Posted via http://www.ruby-forum.com/.


More information about the rspec-users mailing list