Use dynamic fake data in the spec

This commit is contained in:
Henne Vogelsang 2016-05-02 15:25:18 +02:00
parent 4d38305110
commit 73ce49de25
14 changed files with 36 additions and 36 deletions

View file

@ -9,7 +9,7 @@ describe EmailSettings do
{
'email' => 'john@doe.com',
'name' => 'John Doe',
'conference' => 'The dog and pony show',
'conference' => conference.title,
'conference_start_date' => Date.new(2014, 05, 01),
'conference_end_date' => Date.new(2014, 05, 06),
'registrationlink' => 'http://localhost:3000/conference/goto/register',
@ -62,7 +62,7 @@ describe EmailSettings do
context 'conference has venue' do
before do
conference.update_attributes(venue: create(:venue))
venue_hash = { 'venue' => 'Suse Office', 'venue_address' => 'Maxfeldstrasse 5, Nuremberg, Germany' }
venue_hash = { 'venue' => conference.venue.name, 'venue_address' => conference.venue.address }
expected_hash.merge!(venue_hash)
end
@ -105,7 +105,7 @@ describe EmailSettings do
it 'replaces fillers in template' do
expected_text = "Dear John Doe\n\nWe are very pleased" \
'to inform you that your submission Talk about talks has been accepted for the conference The dog and pony show.'
"to inform you that your submission Talk about talks has been accepted for the conference #{conference.title}."
expect(conference.email_settings.generate_event_mail(event, event_template)).to eq expected_text
end
end
@ -114,7 +114,7 @@ describe EmailSettings do
let(:conf_update_template) { "Dear {name},\n\nThank you for Registering for the conference {conference}." }
it 'replaces fillers in template' do
expected_text = "Dear John Doe,\n\nThank you for Registering for the conference The dog and pony show."
expected_text = "Dear John Doe,\n\nThank you for Registering for the conference #{conference.title}."
expect(conference.email_settings.generate_email_on_conf_updates(conference, user, conf_update_template)).to eq expected_text
end
end

View file

@ -221,7 +221,7 @@ describe Event do
describe '#abstract_word_count' do
it 'counts words in abstract' do
event = build(:event)
expect(event.abstract_word_count).to eq(233)
expect(event.abstract_word_count).to eq(event.abstract.to_s.split.size)
event.update_attributes!(abstract: 'abstract.')
expect(event.abstract_word_count).to eq(1)
end