Sha256: dee432039d819ff3025c83e6310c19319588680c545cce7d0afae47db02361b8

Contents?: true

Size: 806 Bytes

Versions: 6

Compression:

Stored size: 806 Bytes

Contents

require 'test_helper'

class FromTest < MiniTest::Spec
  module Model
    Album = Struct.new(:name, :composer)
    Artist = Struct.new(:realname)
  end


  module Twin
    class Album < Disposable::Twin
      feature Sync
      feature Save
      feature Disposable::Twin::Expose

      property :full_name, from: :name

      property :artist, from: :composer do
        property :name, from: :realname
      end
    end
  end


  let (:composer) { Model::Artist.new("AFI").extend(Disposable::Saveable) }
  let (:album)    { Model::Album.new("Black Sails In The Sunset", composer).extend(Disposable::Saveable) }
  let (:twin)     { Twin::Album.new(album) }

  it do
    expect(twin.full_name).must_equal "Black Sails In The Sunset"
    expect(twin.artist.name).must_equal "AFI"

    twin.save


  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

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