Sha256: 187065a98c345d7e57f14bbd629f4f82aa22661cd180dfb5f6a7872f266f5361

Contents?: true

Size: 842 Bytes

Versions: 1

Compression:

Stored size: 842 Bytes

Contents

require "spec_helper_lite"

describe Undo::Wrapper do
  subject { described_class }
  let(:model) { subject.new object, uuid: uuid, mutator_methods: mutator_methods }
  let(:mutator_methods) { [:change] }
  let(:object) { double :object, change: true }
  let(:uuid) { double :uuid }

  describe "storage" do
    it "stores object when mutator method is called" do
      expect(model).to receive(:store)
      model.change
    end
  end

  describe "#uuid" do
    it "uses provided uuid" do
      expect(model.uuid).to eq uuid
    end

    describe "when object respond_to uuid" do
      it "uses object#uuid instead" do
        expect(object).to receive(:uuid) { "123" }
        expect(model.uuid).to eq "123"
        expect(Undo).to receive(:store).with(object,  hash_including(uuid: "123"))
        model.change
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
undo-0.1.1 spec/undo/wrapper_spec.rb