I'm currently testing this class in Sinatra/Datamapper
class Score
include DataMapper::Resource
property :score, Integer
property :created_at, DateTime, :default => DateTime.now, :lazy => [:show]
property :updated_at, DateTime, :default => DateTime.now, :lazy => [:show]
belongs_to :pageant, :key => true
belongs_to :candidate, :key => true
belongs_to :category, :key => true
belongs_to :judge, :key => true
end
with this rspec test
it 'that can be inserted by a judge if a pageant is active' do
score_count = Score.all.length
post '/score', @correct_score_data
Score.all.length.should eq score_count+1
end
it 'cannot be duplicated if it has been sent' do
score_count = Score.all.length
post '/score', @correct_score_data
Score.all.length.should eq score_count
end
basically what is supposed to happen is that a judge can only send a score for a specific category+candidate+pageant combination once, after which I'm suppose to deny the next scores. Now when I run this I get an IntegrityError (which I expect). How do I tell rspec that I "expect to see this error"? You guys can also critique my code, I'm still learning all of these together