Sha256: 83586e3e7733e014e7b55f7ebe3848934123f343c9a5fa0591c65d63a19e14de

Contents?: true

Size: 984 Bytes

Versions: 10

Compression:

Stored size: 984 Bytes

Contents

# require "test_helper"

# class TwinOptionTest < Minitest::Spec
#   module Model
#     Song  = Struct.new(:id, :title, :album)
#   end

#   class Song < Disposable::Twin
#     property :id
#     property :title

#     def self.option(name, options={})
#       property(name, options.merge(virtual: true))
#     end

#     option :preview?
#     option :current_user
#   end

#   let (:song) { Model::Song.new(1, "Broken") }
#   let (:twin) { Song.new(song, :preview? => false) }


#   # properties are read from model.
#   it { twin.id.must_equal 1 }
#   it { twin.title.must_equal "Broken" }

#   # option is not delegated to model.
#   it { twin.preview?.must_equal false }
#   # not passing option means zero.
#   it { twin.current_user.must_equal nil }

#   describe "passing all options" do
#     let (:twin) { Song.new(song, :preview? => false, current_user: Object) }

#     it { twin.preview?.must_equal false }
#     it { twin.current_user.must_equal Object }
#   end
# end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
disposable-0.4.3 test/twin/option_test.rb
disposable-0.4.2 test/twin/option_test.rb
disposable-0.4.1 test/twin/option_test.rb
disposable-0.4.0 test/twin/option_test.rb
disposable-0.3.2 test/twin/option_test.rb
disposable-0.3.1 test/twin/option_test.rb
disposable-0.3.0 test/twin/option_test.rb
disposable-0.2.6 test/twin/option_test.rb
disposable-0.2.5 test/twin/option_test.rb
disposable-0.2.4 test/twin/option_test.rb