ich ein Validate für meine Bestellung Modell hinzugefügt:RSPEC fehlgeschlagen validate: document_type ist nicht in der Liste enthalten
validates :document_type, inclusion: { in: %w(boleta factura) },
allow_nil: true
/My spec fatories/orders.rb:
FactoryGirl.define do
factory :order do
status 'MyString'
order_date '2016-02-16 13:44:01'
delivery_date '2016-02-16 13:44:01'
subtotal '9.99'
igv '9.99'
total '9.99'
document_type 'MyString'
store { FactoryGirl.build(:store) }
order_items { [FactoryGirl.build(:order_item)] }
user { FactoryGirl.build(:user) }
end
end
Aber wenn ich laufen „rspec“ diese ausgefallen und zeigte mir dies:
1) OrderItemsController POST create redirects
Failure/Error: @order = FactoryGirl.create(:order)
ActiveRecord::RecordInvalid:
Validate failed : Document type is not included in the list
# ./spec/controllers/order_items_controller_spec.rb:4:in `block (3 levels) in <top (required)>'
2) OrderItemsController DELETE destroy redirects
Failure/Error: @order = FactoryGirl.create(:order)
ActiveRecord::RecordInvalid:
Validate failed : Document type is not included in the list
# ./spec/controllers/order_items_controller_spec.rb:37:in `block (3 levels) in <top (required)>'
3) OrderItemsController PUT update redirects
Failure/Error: @order = FactoryGirl.create(:order)
ActiveRecord::RecordInvalid:
Validate failed : Document type is not included in the list
# ./spec/controllers/order_items_controller_spec.rb:26:in `block (3 levels) in <top (required)>'
4) OrderItemsController PATCH update redirects
Failure/Error: @order = FactoryGirl.create(:order)
ActiveRecord::RecordInvalid:
Validate failed : Document type is not included in the list
# ./spec/controllers/order_items_controller_spec.rb:15:in `block (3 levels) in <top (required)>'
Wie kann ich document_type
zur Liste hinzufügen?
Aktualisieren Sie die Frage mit 'spec/factories/order.rb' Inhalt. – Pavan
@Pavan fertig: 'D – Giancarlos
Versuchen Sie 'Dokumententyp [" Boleta "," Faktura "]. Beispiel' anstelle von 'Dokumententyp' MyString'' – Pavan