Sha256: 63c08a6c92025a07147478a9aa4bfc22d610cfb2c2af5330d862b8fbbfc6a209

Contents?: true

Size: 1.89 KB

Versions: 3

Compression:

Stored size: 1.89 KB

Contents

FactoryGirl.define do
  sequence :email do |n|
    "customer#{n}@example.com"
  end

  sequence :customer_id do |n|
    n
  end

  factory :customer, :class => Chargify::Customer do |c|
    c.first_name { Faker::Name.first_name }
    c.last_name { Faker::Name.last_name }
    c.email { FactoryGirl.generate(:email) }
    c.organization { Faker::Company.name }
    c.created_at { 2.days.ago }
    c.updated_at { 1.hour.ago }
  end


  sequence :product_id do |n|
    n
  end

  sequence :product_name do |n|
    "Product #{n}"
  end

  factory :product, :class => Chargify::Product do |p|
    p.name { FactoryGirl.generate(:product_name) }
  end

  sequence :subscription_id do |n|
    n
  end

  factory :subscription, :class => Chargify::Subscription do |s|
    s.balance_in_cents 500
    s.current_period_ends_at 3.days.from_now
  end

  factory :subscription_with_extra_attrs, :parent => :subscription do |swea|
    swea.customer Chargify::Customer.new
    swea.product Chargify::Product.new
    swea.credit_card "CREDIT CARD"
  end

  factory :component, :class => Chargify::Component do |f|
    f.name { Faker::Company.bs }
    f.unit_name 'unit'
  end

  factory :quantity_based_component, :class => Chargify::Component do |f|
    f.name { Faker::Company.bs }
    f.unit_name 'unit'
    f.pricing_scheme 'tiered'
    f.component_type 'quantity_based_component'
  end

  factory :subscriptions_component, :class => Chargify::Subscription::Component do |f|
    f.name { Faker::Company.bs }
    f.unit_name 'unit'
    f.component_type 'quantity_based_component'
  end

  factory :coupon, :class => Chargify::Coupon do |f|
    f.name                   { '15% off' }
    f.code                   { '15OFF' }
    f.description            { '15% off for life' }
    f.percentage             { '14' }
    f.allow_negative_balance { false }
    f.recurring              { false }
    f.end_date               { 1.month.from_now }
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
chargify_api_ares-0.4.4 spec/factories.rb
chargify_api_ares-0.4.3 spec/factories.rb
chargify_api_ares-0.4.2 spec/factories.rb