0

old_spec.rb

it { should allow_value(:nil).for(:invoice_type) }
it { should allow_value(:customer_invoice).for(:invoice_type) }
it { should allow_value(:creative_invoice).for(:invoice_type) }
it { should_not allow_value(:other).for(:invoice_type) }

I have these code in my spec file and I convert them like below.

new_spec.rb

   it { should ensure_inclusion_of(:invoice_type).in_array(
     [:nil,:customer_invoice,:creative_invoice]) }

I wonder that in the second file (new_spec.rb) do I have to write this line.

it { should_not allow_value(:other).for(:invoice_type) }
Andy Waite
  • 10,785
  • 4
  • 33
  • 47
Johnny Cash
  • 4,867
  • 5
  • 21
  • 37

1 Answers1

0

Based on the description of how ensure_inclusion_of works, you shouldn't need to explicitly prevent other values.

Of course, it would be very easy to check this for yourself...

Andy Waite
  • 10,785
  • 4
  • 33
  • 47