Sha256: f1f77a76e597cc428385ca3042739e60da77c97630898ba8c77e899e52bfa7be

Contents?: true

Size: 841 Bytes

Versions: 6

Compression:

Stored size: 841 Bytes

Contents

require 'test_helper'

class VirtualTest < MiniTest::Spec
  class CreditCardTwin < Disposable::Twin
    include Sync
    property :credit_card_number, virtual: true # no read, no write, it's virtual.
  end

  let (:twin) { CreditCardTwin.new(Object.new) }

  it {
    twin.credit_card_number = "123"

    expect(twin.credit_card_number).must_equal "123"  # this is still readable in the UI.

    twin.sync

    hash = {}
    twin.sync do |nested|
      hash = nested
    end

    expect(hash).must_equal("credit_card_number"=> "123")
  }

  describe "setter should never be called with virtual:true" do
    class Raising < Disposable::Twin
      property :id, virtual: true

      def id=(*)
        raise "i should never be called!"
      end
    end

    it "what" do
      expect(Raising.new(Object.new).id).must_be_nil
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
disposable-0.6.3 test/twin/virtual_test.rb
disposable-0.6.2 test/twin/virtual_test.rb
disposable-0.6.1 test/twin/virtual_test.rb
disposable-0.6.0 test/twin/virtual_test.rb
disposable-0.5.0 test/twin/virtual_test.rb
disposable-0.4.7 test/twin/virtual_test.rb