Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: nil default value of Array attribute ignored #369

Open
csokol opened this issue Sep 30, 2016 · 1 comment
Open

Bug: nil default value of Array attribute ignored #369

csokol opened this issue Sep 30, 2016 · 1 comment

Comments

@csokol
Copy link

csokol commented Sep 30, 2016

I think I found a bug in virtus.

It looks like the default parameter is being ignored for Array attributes. Here's how to reproduce:

require 'virtus'
class Foo
  include Virtus.model

  attribute :array, Array, default: nil
  attribute :hash, Hash, default: nil
  attribute :string, String, default: nil
end
require './foo.rb'
require 'test/unit/assertions'
include Test::Unit::Assertions


f = Foo.new({})
assert(f.string.nil?, 'string should be nil')
assert(f.hash.nil?, 'hash should be nil')

p f.array
assert(f.array.nil?, 'array should be nil')

Am I missing something or is this a real bug?

@ravicious
Copy link

ravicious commented Oct 28, 2016

I ran into this too recently. I believe this issue is related to #334 and could be closed in favor of that issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants