Sha256: be547b124228357738b8c12835cdf56a37caf350c9f8fc3b4a7ce84590eedde4

Contents?: true

Size: 729 Bytes

Versions: 5

Compression:

Stored size: 729 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

5 entries across 5 versions & 3 rubygems

Version Path
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/representable-3.2.0/test/user_options_test.rb
fluent-plugin-google-cloud-logging-on-prem-0.1.0 vendor/ruby/3.1.0/gems/representable-3.2.0/test/user_options_test.rb
representable-3.2.0 test/user_options_test.rb
representable-3.1.1 test/user_options_test.rb
representable-3.1.0 test/user_options_test.rb