I click on the wall because I'm terribly confused about what this rspec error message means. I am testing if there is a value to a work of art. Here are snippets of my rspec:
let(:valid_art_piece){ { date_of_creation: DateTime.parse('2012-3-13'),
placement_date_of_sale: DateTime.parse('2014-8-13'), cost: 250, medium: 'sculpture',
availability: true } }
it 'requires a cost' do
art_piece = ArtPiece.new(valid_art_piece.merge(cost: ''))
expect(art_piece).to_not be_valid
expect(art_piece.errors[:cost].to include "can't be blank")
end
error message:
1) ArtPiece requires a cost
Failure/Error: expect(art_piece.errors[:cost].to include "can't be blank")
NoMethodError:
undefined method `+' for #<RSpec::Matchers::BuiltIn::Include:0x000001050f4cd0>
# ./spec/models/artist_piece_spec.rb:30:in `block (2 levels) in <top (required)>'
As far as I know, this should not have failed, and I do not know why his failure. My schema.rb has the field as null false, and my model validates it using the numeric: true parameter.
class ArtPiece < ActiveRecord::Base
validates_presence_of :date_of_creation
validates_presence_of :placement_date_of_sale
validates :cost, numericality: true
validates_presence_of :medium
validates_presence_of :availability
end
I do not know what the problem is. Some help?
source
share