Sha256: b07c017a0457215b3516b03192623c970b7e088afe215d1c16d1c5c1f5038669
Contents?: true
Size: 918 Bytes
Versions: 19
Compression:
Stored size: 918 Bytes
Contents
require 'test_helper' require 'lazy_document' class UserModel; end class LazyDocumentTest < Test::Unit::TestCase context "With a lazy document" do setup do @record = stub(:record) @record.stubs(:is_valid?).returns true UserModel.stubs(:find).returns @record @document = ActsAsSolr::LazyDocument.new(1, UserModel) end context "with an uninitialized document" do should "fetch the record from the database" do UserModel.expects(:find).with(1).returns(@record) @document.is_valid? end end context "with an initialized document" do should "not fetch the record again" do @document.is_valid? @document.expects(:find).never @document.is_valid? end should "reroute the calls to the record" do @record.expects(:is_valid?).once @document.is_valid? end end end end
Version data entries
19 entries across 19 versions & 3 rubygems