From 696be9ff4d6a6f7e3286cba14df4e4f449d31bb6 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Mon, 5 Oct 2015 20:12:42 +0200 Subject: Refactor generation of band params for test into factory. --- spec/support/band_factory.rb | 59 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 spec/support/band_factory.rb (limited to 'spec/support/band_factory.rb') diff --git a/spec/support/band_factory.rb b/spec/support/band_factory.rb new file mode 100644 index 0000000..f14caf2 --- /dev/null +++ b/spec/support/band_factory.rb @@ -0,0 +1,59 @@ +module BandFactory + def create_band_params(options = {}) + opts = { + :songs => 1, + }.merge(options) + + num_songs = opts.delete(:songs) + + params = { + 'name' => 'Imbalance', + 'city' => 'Oslo', + 'website' => 'http://imbalance.no', + 'label' => 'Calculated Imperfection', + 'shortbio' => 'Thrash metal from Norway', + 'contact' => { + 'name' => 'Harald Eilertsen', + 'addr' => "Gamleveien 13\n1289 Snufstad", + 'phone' => '98765432', + 'email' => 'mail@imbalance.no' + }, + 'members' => { + '1' => { + 'name' => 'Harald Eilertsen', + 'instrument' => 'Bass/Vocals', + 'age' => '' + }, + '2' => { + 'name' => 'Welle', + 'instrument' => 'Drums', + 'age' => '' + }, + '3' => { + 'name' => 'Thormodr', + 'instrument' => 'Guitar', + 'age' => '' + } + }, + 'songs' => {} + } + + (1..num_songs).each do |i| + num = i.to_s + params['songs'][num] = create_song_params + end + + params + end + + def create_song_params + { + 'title' => 'Bestial by Nature', + 'time' => '02:80', + 'isrc' => '', + 'performers' => "Harald Eilertsen\nThormod Steinert\nLars Welle", + 'composers' => "Harald Eilertsen\nThormod Steinert", + 'notes' => 'Rævrukkje rum kjurr!' + } + end +end -- cgit v1.2.3