Sha256: 6854992f35252ef7fb8bd04b5d1a41eb01bdcdf710ba1f410d7d13a4adbfdcd3

Contents?: true

Size: 856 Bytes

Versions: 4

Compression:

Stored size: 856 Bytes

Contents

require "spec_helper"

describe "constructor aliases" do
  it ".new" do
    class Test::Foo < Evil::Struct
      attribute :foo
      attribute :baz, default: proc { "qux" }
    end

    expect(Test::Foo.new foo: "bar").to eq foo: "bar", baz: "qux"
  end

  it ".call" do
    class Test::Foo < Evil::Struct
      attribute :foo
      attribute :baz, default: proc { "qux" }
    end

    expect(Test::Foo.call foo: "bar").to eq foo: "bar", baz: "qux"
  end

  it ".load" do
    class Test::Foo < Evil::Struct
      attribute :foo
      attribute :baz, default: proc { "qux" }
    end

    expect(Test::Foo.load foo: "bar").to eq foo: "bar", baz: "qux"
  end

  it ".[]" do
    class Test::Foo < Evil::Struct
      attribute :foo
      attribute :baz, default: proc { "qux" }
    end

    expect(Test::Foo[foo: "bar"]).to eq foo: "bar", baz: "qux"
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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