Sha256: 26e05706856dd355353a2300b3eeb52fc80a0e01629dd3aa4736f50b36bc9f25

Contents?: true

Size: 856 Bytes

Versions: 9

Compression:

Stored size: 856 Bytes

Contents

FactoryGirl.define do
  factory :user do
    email { "#{name.gsub(' ', '.').downcase}@example.com" }
    password "password"
    password_confirmation "password"
    transient do
      plan { PaidUp::Plan.order("RANDOM()").first }
    end
    # the after(:create) yields two values; the user instance itself and the
    # evaluator, which stores all values from the factory, including transient
    # attributes; `create_list`'s second argument is the number of records
    # to create and we make sure the user is associated properly to the post
    after(:create) do |user, evaluator|
      token = Stripe::Token.create(
          card: {
              number: '4242424242424242',
              exp_month: 1,
              exp_year: 45,
              cvc: '111'
          }
      ).id
      user.subscribe_to_plan(evaluator.plan, token)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
paid_up-0.9.1 spec/factories/user.rb
paid_up-0.9.0 spec/factories/user.rb
paid_up-0.8.1 spec/factories/user.rb
paid_up-0.7.11 spec/factories/user.rb
paid_up-0.7.10 spec/factories/user.rb
paid_up-0.7.9 spec/factories/user.rb
paid_up-0.7.8 spec/factories/user.rb
paid_up-0.7.7 spec/factories/user.rb
paid_up-0.7.6 spec/factories/user.rb