From bfc6d9a6ceed3a2ee9a38a1afa4dffec972eca83 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Tue, 6 Oct 2015 21:13:37 +0200 Subject: Add submit form helper to specs. --- spec/spec_helper.rb | 3 +++ spec/support/submit_form_helper.rb | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 spec/support/submit_form_helper.rb (limited to 'spec') diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index ad8ead8..cd9f3f3 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -2,10 +2,13 @@ ENV['RACK_ENV'] = 'test' require_relative '../registration' require_relative 'support/band_factory' +require_relative 'support/submit_form_helper' require 'capybara/rspec' RSpec.configure do |config| config.include BandFactory + config.include SubmitFormHelper + config.before(:example) do @doc_spy = spy("Prawn::Document") allow(Prawn::Document).to receive('new') { @doc_spy } diff --git a/spec/support/submit_form_helper.rb b/spec/support/submit_form_helper.rb new file mode 100644 index 0000000..acccbd6 --- /dev/null +++ b/spec/support/submit_form_helper.rb @@ -0,0 +1,37 @@ +module SubmitFormHelper + def fill_in_form_with(params) + fill_in 'Bandnavn:', with: params['name'] + fill_in 'Hjemsted:', with: params['city'] + fill_in 'Webside:', with: params['website'] + fill_in 'Plateselskap:', with: params['label'] + fill_in 'Kort bio:', with: params['shortbio'] + + within '#form-contact-info' do + fill_in 'Navn:', with: params['contact']['name'] + fill_in 'Postadresse:', with: params['contact']['addr'] + fill_in 'Tlf:', with: params['contact']['phone'] + fill_in 'E-post:', with: params['contact']['email'] + end + + click_on 'Legg til medlem' + + within '#form-members .member-info' do + fill_in 'Navn:', with: params['members']['1']['name'] + end + + if params['songs'] + click_on 'Legg til låt' + + within '#form-songs #song-1-info' do + fill_in 'Tittel:', with: params['songs']['1']['title'] + fill_in 'Lengde:', with: params['songs']['1']['time'] + fill_in 'ISRC-kode:', with: params['songs']['1']['isrc'] + fill_in 'Utøvere:', with: params['songs']['1']['performers'] + fill_in 'Opphavsmenn:', with: params['songs']['1']['composers'] + fill_in 'Andre merknader:', with: params['songs']['1']['notes'] + end + end + + click_on 'Send skjema' + end +end -- cgit v1.2.3