Skip to content

Instantly share code, notes, and snippets.

@untitaker
Created September 28, 2017 15:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save untitaker/f2b6b20ad7d1a658264c3f6a8334fa5a to your computer and use it in GitHub Desktop.
Save untitaker/f2b6b20ad7d1a658264c3f6a8334fa5a to your computer and use it in GitHub Desktop.
require 'dry-struct'
module Types
include Dry::Types.module
end
class Bar < Dry::Struct
constructor_type :strict_with_defaults
attribute :baz, Types::Strict::Int
attribute :bam, Types::Strict::Int.optional.default(nil)
end
describe Bar do
specify { expect { Bar.new() }.to raise_error }
specify { expect { Bar.new(baz: 342) }.not_to raise_error }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment