spec/ppl/adapter/storage/git_spec.rb in ppl-2.4.0 vs spec/ppl/adapter/storage/git_spec.rb in ppl-2.4.1

- old
+ new

@@ -10,10 +10,11 @@ @disk = double(Ppl::Adapter::Storage::Disk) @contact = double(Ppl::Entity::Contact) @repo = double(Rugged::Repository) @commit = double(Rugged::Commit) @vcard = double(Ppl::Adapter::Vcard) + @target = double(Rugged::Commit) Rugged::Repository.stub(:new).and_return(@repo) @disk.stub(:directory).and_return(Dir.new("/contacts")) @disk.stub(:path).and_return("/contacts") @@ -48,11 +49,12 @@ before(:each) do @head = double(Rugged::Reference) @files = [{:name => "test.vcf"}] - @commit.should_receive(:target) + @commit.should_receive(:target).and_return(@target) + @target.should_receive(:oid) @repo.should_receive(:lookup).and_return(@head) @repo.should_receive(:head).and_return(@commit) @git.stub(:load_contact) do |id| contact = Ppl::Entity::Contact.new @@ -80,26 +82,36 @@ end describe "#load_contact" do it "should return a contact" do + target = OpenStruct.new + target.oid = "asdfg" head = OpenStruct.new - head.target = "asdfg" + head.target = target + blob = OpenStruct.new + blob.content = 'vcard contents' + @repo.should_receive(:head).and_return(head) - @repo.should_receive(:file_at).and_return("vcard contents") + @repo.should_receive(:blob_at).and_return(blob) @vcard.should_receive(:decode).and_return(@contact) @contact.should_receive(:id=).with("test") contact = @git.load_contact("test") end it "handles encoding errors gracefully" do + target = OpenStruct.new + target.oid = "asdfg" head = OpenStruct.new - head.target = "asdfg" + head.target = target + blob = OpenStruct.new + blob.content = 'vcard contents' + @repo.should_receive(:head).and_return(head) - @repo.should_receive(:file_at).and_return("vcard contents") + @repo.should_receive(:blob_at).and_return(blob) @vcard.should_receive(:decode).and_raise(GreenCard::InvalidEncodingError) expect{ @git.load_contact("test") }.to raise_error(Ppl::Error::InvalidVcard) end end