Sha256: e0e06302853cc14e8c608c1a14c65df9436dda512598fee8cec860f3dab52e77

Contents?: true

Size: 986 Bytes

Versions: 21

Compression:

Stored size: 986 Bytes

Contents

require 'factory_girl'

FactoryGirl.define do
  factory :artist, :class => MyApp::Artist do
    sequence(:name) {|n| "Artist ##{n}" }
    sequence(:website) {|n| "http://website#{n}.com/" }

    factory :artist_with_albums do
      ignore do
        album_count 3
      end

      after(:create) do |artist, evaluator|
        create_list(:album_with_songs, evaluator.album_count, artist: artist)
      end
    end
  end

  factory :album, :class => MyApp::Album do
    sequence(:title) {|n| "Album ##{n}" }
    sequence(:year) {|n| 1960 + n }
    artist

    factory :album_with_songs do
      ignore do
        song_count 10
      end

      after(:create) do |album, evaluator|
        create_list(:song, evaluator.song_count, album: album, artist: album.artist)
      end
    end
  end

  factory :song, :class => MyApp::Song do
    sequence(:title) {|n| "Song ##{n}" }
    artist
    album
  end

  factory :payment, :class => MyApp::Payment do
    amount 999
    artist
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
restpack_serializer-0.4.27 spec/support/factory.rb
restpack_serializer-0.4.26 spec/support/factory.rb
restpack_serializer-0.4.25 spec/support/factory.rb
restpack_serializer-0.4.24 spec/support/factory.rb
restpack_serializer-0.4.23 spec/support/factory.rb
restpack_serializer-0.4.21 spec/support/factory.rb
restpack_serializer-0.4.20 spec/support/factory.rb
restpack_serializer-0.4.19 spec/support/factory.rb
restpack_serializer-0.4.18 spec/support/factory.rb
restpack_serializer-0.4.17 spec/support/factory.rb
restpack_serializer-0.4.16 spec/support/factory.rb
restpack_serializer-0.4.15 spec/support/factory.rb
restpack_serializer-0.4.14 spec/support/factory.rb
restpack_serializer-0.4.13 spec/support/factory.rb
restpack_serializer-0.4.12 spec/support/factory.rb
restpack_serializer-0.4.11 spec/support/factory.rb
restpack_serializer-0.4.10 spec/support/factory.rb
restpack_serializer-0.4.9 spec/support/factory.rb
restpack_serializer-0.4.8 spec/support/factory.rb
restpack_serializer-0.4.7 spec/support/factory.rb