Sha256: b6920aeccbc1e8f80e0859f3faf81a58580f21396035e0fdfdba61364321082a

Contents?: true

Size: 717 Bytes

Versions: 9

Compression:

Stored size: 717 Bytes

Contents

require "test_helper"

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

  representer! do
    property :title, if: ->(options) { options[:user_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(user_options: {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"}, user_options: {visible: true}).title.must_equal "Business Conduct" }
end
# Representable.deprecations=false

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
representable-3.0.4 test/user_options_test.rb
representable-3.0.3 test/user_options_test.rb
representable-3.0.2 test/user_options_test.rb
representable-3.0.1 test/user_options_test.rb
representable-3.0.0 test/user_options_test.rb
representable-2.4.1 test/user_options_test.rb
representable-2.4.0 test/user_options_test.rb
representable-2.4.0.rc5 test/user_options_test.rb
representable-2.4.0.rc4 test/user_options_test.rb