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

@ -58,7 +58,7 @@ describe Admin::ConferenceController do
conference.reload
expect(flash[:error]).
to eq("Updating conference failed. Short title can't be blank.")
expect(conference.title).to eq('The dog and pony show')
expect(conference.title).to eq("#{conference.title}")
expect(conference.short_title).to eq("#{conference.short_title}")
end

View file

@ -114,7 +114,7 @@ describe ConferenceRegistrationsController, type: :controller do
end
it 'shows error in flash message' do
expect(flash[:error]).to match "Could not update your registration for The dog and pony show: #{@registration.errors.full_messages.join('. ')}."
expect(flash[:error]).to match "Could not update your registration for #{conference.title}: #{@registration.errors.full_messages.join('. ')}."
end
it 'does not update the registration' do
@ -139,7 +139,7 @@ describe ConferenceRegistrationsController, type: :controller do
end
it 'shows success message in flash notice', run: true do
expect(flash[:notice]).to match('You are not registered for The dog and pony show anymore!')
expect(flash[:notice]).to match("You are not registered for #{conference.title} anymore!")
end
it 'deletes the registration' do
@ -160,7 +160,7 @@ describe ConferenceRegistrationsController, type: :controller do
end
it 'shows error in flash message' do
expect(flash[:error]).to match "Could not delete your registration for The dog and pony show: #{@registration.errors.full_messages.join('. ')}."
expect(flash[:error]).to match "Could not delete your registration for #{conference.title}: #{@registration.errors.full_messages.join('. ')}."
end
it 'does not delete the registration' do

View file

@ -35,13 +35,13 @@ feature Lodging do
visit admin_conference_lodgings_path(
conference_id: conference.short_title)
expect(page.has_content?('Example Hotel')).to be true
expect(page.has_content?(lodging.name)).to be true
# Add lodging
click_link 'Edit'
fill_in 'lodging_name', with: 'New lodging'
fill_in 'lodging_website_link', with: 'http:\\www.google.com'
fill_in 'lodging_website_link', with: 'http://www.google.com'
attach_file 'Picture', path
click_button 'Update Lodging'
@ -51,26 +51,26 @@ feature Lodging do
expect(page.has_content?('New lodging')).to be true
lodging.reload
expect(lodging.name).to eq('New lodging')
expect(lodging.description).to eq('Lorem Ipsum Dolor')
expect(lodging.website_link).to eq('http:\\www.google.com')
expect(lodging.description).to eq(lodging.description)
expect(lodging.website_link).to eq('http://www.google.com')
expect(Lodging.count).to eq(1)
end
scenario 'Delete a lodging', feature: true, js: true do
conference.lodgings << create(:lodging)
lodging = create(:lodging, conference: conference)
sign_in organizer
visit admin_conference_lodgings_path(
conference_id: conference.short_title)
expect(page.has_content?('Example Hotel')).to be true
expect(page.has_content?(lodging.name)).to be true
# Add lodging
click_link 'Delete'
# Validations
expect(flash).to eq('Lodging successfully deleted.')
expect(page.has_content?('Example Hotel')).to be false
expect(page.has_content?(lodging.name)).to be false
expect(Lodging.count).to eq(0)
end
end

View file

@ -21,7 +21,7 @@ feature Sponsor do
fill_in 'sponsor_description', with: 'The original provider of the enterprise Linux distribution'
attach_file 'Picture', path
fill_in 'sponsor_website_url', with: 'http://www.suse.com'
select('Platin', from: 'sponsor_sponsorship_level_id')
select(conference.sponsorship_levels.first.title, from: 'sponsor_sponsorship_level_id')
click_button 'Create Sponsor'
@ -30,7 +30,7 @@ feature Sponsor do
expect(page.has_content?('SUSE')).to be true
expect(page.has_content?('The original provider')).to be true
expect(page.has_content?('http://www.suse.com')).to be true
expect(page.has_content?('Platin')).to be true
expect(page.has_content?(conference.sponsorship_levels.first.title)).to be true
expect(page).to have_selector("img[src*='rails.png']")
expect(page.assert_selector('tr', count: 2)).to be true
end

View file

@ -33,7 +33,7 @@ feature Registration do
expect(current_path).to eq(conference_conference_registrations_path(conference.short_title))
expect(flash).
to eq("Thank you for supporting #{conference.title} by purchasing a ticket.")
expect(page.has_content?('2 Business Ticket Tickets for 10')).to be true
expect(page.has_content?("2 #{ticket.title} Tickets for 10")).to be true
end
scenario 'deletes a purchased ticket', feature: true, js: true do
@ -41,7 +41,7 @@ feature Registration do
create(:ticket_purchase, conference: conference, user: participant, ticket: ticket, quantity: 4)
visit conference_conference_registrations_path(conference.short_title)
expect(page.has_content?('4 Business Ticket Tickets for 10')).to be true
expect(page.has_content?("4 #{ticket.title} Tickets for 10")).to be true
click_link "ticket-#{ticket.id}-delete"
expect(flash).to eq('Ticket successfully deleted.')

View file

@ -11,7 +11,7 @@ describe SponsorsHelper, type: :helper do
end
it 'returns correct url' do
expect(get_logo(sponsor)).to match %r{.*(\bfirst/rails.png\b)}
expect(get_logo(sponsor)).to match %r{.*(\bfirst/#{sponsor.logo_file_name}\b)}
end
end
@ -22,7 +22,7 @@ describe SponsorsHelper, type: :helper do
end
it 'returns correct url' do
expect(get_logo(sponsor)).to match %r{.*(\bsecond/rails.png\b)}
expect(get_logo(sponsor)).to match %r{.*(\bsecond/#{sponsor.logo_file_name}\b)}
end
end
@ -33,7 +33,7 @@ describe SponsorsHelper, type: :helper do
end
it 'returns correct url' do
expect(get_logo(sponsor)).to match %r{.*(\bothers/rails.png\b)}
expect(get_logo(sponsor)).to match %r{.*(\bothers/#{sponsor.logo_file_name}\b)}
end
end
end

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

View file

@ -12,7 +12,7 @@ describe ConferenceSerializer, type: :serializer do
{
conference: {
short_title: 'goto',
title: 'The dog and pony show',
title: conference.title,
description: 'Lorem ipsum dolor sit',
start_date: '2014-03-04',
end_date: '2014-03-10',
@ -61,7 +61,7 @@ describe ConferenceSerializer, type: :serializer do
before do
venue = create(:venue, conference: conference)
_room = create(:room, venue: venue)
_track = create(:track, program: conference.program)
track = create(:track, program: conference.program)
room_hash = {
rooms: [{
@ -74,8 +74,8 @@ describe ConferenceSerializer, type: :serializer do
track_hash = {
tracks: [{
id: 1,
name: 'Example Track',
description: 'Lorem Ipsum dolsum'
name: track.name,
description: track.description
}
]
}

View file

@ -7,7 +7,7 @@ describe RoomSerializer, type: :serializer do
expected_json = {
room: {
guid: room.guid,
name: 'Example Room',
name: room.name,
description: ''
}
}.to_json

View file

@ -8,8 +8,8 @@ describe TrackSerializer, type: :serializer do
expected_json = {
track: {
guid: track.guid,
name: 'Example Track',
color: '#ffffff'
name: track.name,
color: track.color
}
}.to_json

View file

@ -7,6 +7,6 @@ describe 'admin/lodgings/index' do
@conference.lodgings << create(:lodging)
assign :venue, @conference.venue
render
expect(rendered).to include('Example Hotel')
expect(rendered).to include(@conference.lodgings.first.name)
end
end

View file

@ -9,9 +9,9 @@ describe 'admin/sponsors/index' do
)
assign :conference, @conference
render
expect(rendered).to include('Example sponsor')
expect(rendered).to include('http://www.example.com')
expect(rendered).to include('Lorem Ipsum Dolor')
expect(rendered).to include('Platin')
expect(rendered).to include(@conference.sponsors.first.name)
expect(rendered).to include(@conference.sponsors.first.website_url)
expect(rendered).to include(truncate(@conference.sponsors.first.description))
expect(rendered).to include(@conference.sponsorship_levels.first.title)
end
end

View file

@ -5,6 +5,6 @@ describe 'admin/sponsorship_levels/index' do
@sponsorship_level = create(:sponsorship_level)
assign :conference, @sponsorship_level.conference
render
expect(rendered).to include('Platin')
expect(rendered).to include(@sponsorship_level.title)
end
end