shoulda-matchers icon indicating copy to clipboard operation
shoulda-matchers copied to clipboard

Enum string with_values broken

Open Loschcode opened this issue 6 years ago • 2 comments

In my WebinarsIdentity model

enum kind_register: {
  live: 'live',
  on_demand: 'on_demand'
}, _prefix: true # `prefix` does not affect the crash (apparently)
Failure/Error:
  is_expected.to define_enum_for(:kind_register).
  with_values(['live', 'on_demand']).
  backed_by_column_of_type(:string)

  Expected WebinarsIdentity to define :kind_register as an enum, backed by
  a string, with possible values ‹["live", "on_demand"]›. However, the
  actual enum values for :kind_register are ‹["live", "on_demand"]›.

Well, I don't really know what to do with such output, everything seems correct.

Loschcode avatar May 21 '19 10:05 Loschcode

Hmm... that does seem fishy. I'll look into this when I have a chance.

mcmire avatar May 21 '19 15:05 mcmire

@Loschcode I think this might be a matter of updating the error message here to be more helpful. However, in the meantime, to fix this on your end, you might want to try something like:

is_expected.to define_enum_for(:kind_register).
  with_values(live: "live", on_demand: "on_demand").
  backed_by_column_of_type(:string).
  with_prefix(true)

mcmire avatar May 30 '19 06:05 mcmire