Sha256: 4013a92a02a8f1f0b8ddfc3522246fdef4f2618d29e21f5e4eda6c1eae3bb1ff

Contents?: true

Size: 419 Bytes

Versions: 4

Compression:

Stored size: 419 Bytes

Contents

require "spec_helper"

describe "shared options" do
  it "supported via .attributes" do
    class Test::Foo < Evil::Struct
      attributes type: Dry::Types["strict.string"], default: proc { "bar" } do
        attribute :foo
        attribute :baz, default: proc { "qux" }
      end
    end

    expect(Test::Foo.new).to eq foo: "bar", baz: "qux"
    expect { Test::Foo.new foo: 1 }.to raise_error(TypeError)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
evil-struct-0.0.4 spec/features/shared_options_spec.rb
evil-struct-0.0.3 spec/features/shared_options_spec.rb
evil-struct-0.0.2 spec/features/shared_options_spec.rb
evil-struct-0.0.1 spec/features/shared_options_spec.rb