Hi there all. Sorry if the question sounds silly but i'm rather new at the 'mocking' stuff... So here is my problem (code helps more than talking):
the model: class Item < ActiveRecord::Base ... has_many :images, :dependent => :destroy ... protected def validate errors.add(:images, "cannot be empty") if self.images.count end end the spec: describe Item do before(:each) do @item = Item.new end ... it "should have at least one image" do @item.should have(1).error_on(:images) @item.images.should_receive(:count).at_least(:once).and_return(1) @item.should have(0).errors_on(:images) end end Obviously i'm doing something wrong cause this doesn't work: 1) 'Item should have at least one image' FAILED expected 0 errors on :images, got 1 ./spec/models/item_spec.rb:60: script/spec:4: Finished in 0.341594 seconds 10 examples, 1 failure, 5 pending (ignore the rest) Any help would be more than welcome :) -- Posted via http://www.ruby-forum.com/. _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users