Sha256: 77b2344d9ed79a23f3bc76807b857d12d421c04bd73023be78d04ce574799764

Contents?: true

Size: 670 Bytes

Versions: 4

Compression:

Stored size: 670 Bytes

Contents

require "test_helper"

class UserOptionsTest < Minitest::Spec
  Song = Struct.new(:title)

  representer! do
    property :title, if: ->(options) { options[:visible] }
  end

  it { Song.new("Run With It").extend(representer).to_hash.must_equal({}) }
  it { Song.new("Run With It").extend(representer).to_hash(visible: true).must_equal({"title"=>"Run With It"}) }
  it { Song.new("Run With It").extend(representer).from_hash("title"=>"Business Conduct").title.must_equal "Run With It" }
  it { Song.new("Run With It").extend(representer).from_hash({"title"=>"Business Conduct"}, visible: true).title.must_equal "Business Conduct" }
end
# Representable.deprecations=false

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
representable-2.4.1 test-with-deprecations/user_options_test.rb
representable-2.4.0 test-with-deprecations/user_options_test.rb
representable-2.4.0.rc5 test-with-deprecations/user_options_test.rb
representable-2.4.0.rc4 test-with-deprecations/user_options_test.rb