Sha256: d767df9a0652f2849009f668e42553868ad3e106202c47be99f7ad0898f3fbb1

Contents?: true

Size: 1.09 KB

Versions: 2

Compression:

Stored size: 1.09 KB

Contents

require 'test_helper'

require 'disposable/twin/composition'

class TwinCompositionTest < MiniTest::Spec
  class Request < Disposable::Twin::Composition
    property :song_title, :on => :song, :as => :title
    property :song_id,    :on => :song, :as => :id

    property :name,       :on => :requester
    property :id,         :on => :requester

    # map ...

    # def id
    # make map(name, options)
    # option :played?
  end

  module Model
    Song      = Struct.new(:id, :title, :album)
    Requester = Struct.new(:id, :name)
  end

  let (:requester) { Model::Requester.new(1, "Greg Howe") }
  let (:song) { Model::Song.new(2, "Extraction") }

  let (:request) { Request.new(:song => song, :requester => requester) }

  it { request.song_title.must_equal "Extraction" }
  it { request.name.must_equal "Greg Howe" }


  describe "setter" do
    before do
      request.song_title = "Tease"
      request.name = "Wooten"
    end

    it { request.song_title.must_equal "Tease" }
    # no writing to model.
    it { song.title.must_equal "Extraction" }
    it { request.name.must_equal "Wooten" }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
disposable-0.0.8 test/twin/composition_test.rb
disposable-0.0.7 test/twin/composition_test.rb