Sha256: 0fe04de43a6407c2d1daddef1692df4212c07b4bdda86064d584c7afacd5264d

Contents?: true

Size: 625 Bytes

Versions: 1

Compression:

Stored size: 625 Bytes

Contents

require_relative "spec_helper"

require_relative "../lib/prawn_cocktail/utils/recursive_closed_struct"

describe RecursiveClosedStruct do
  it "provides readers from a hash" do
    subject = RecursiveClosedStruct.new(key: "value")
    assert_equal "value", subject.key
  end

  it "raises when there's no such key" do
    subject = RecursiveClosedStruct.new(key: "value")
    assert_raises(NoMethodError) do
      subject.other_key
    end
  end

  it "recurses through hashes" do
    subject = RecursiveClosedStruct.new({
      one: { two: { three: "four" } }
    })
    assert_equal "four", subject.one.two.three
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
prawn_cocktail-0.7.0 spec/recursive_closed_struct_spec.rb