Skip to content

Commit

Permalink
adds testing improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
jsqu99 committed Nov 20, 2013
1 parent af917e0 commit 221e3fd
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
76 changes: 76 additions & 0 deletions lib/spree_flexi_variants/factories.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
FactoryGirl.define do
factory :no_charge_calculator, :class => Spree::Calculator::NoCharge do
end
end

FactoryGirl.define do
factory :product_customization_type, :class => Spree::ProductCustomizationType do
sequence(:name) { |n| "Product Customization Type ##{n} - #{Kernel.rand(9999)}" }
sequence(:presentation) { |n| "Product Customization Type Presentation ##{n} - #{Kernel.rand(9999)}" }

calculator { |p| p.association(:no_charge_calculator) }
end
end

FactoryGirl.define do
factory :product_customization, :class => Spree::ProductCustomization do
product_customization_type { |p| p.association(:product_customization_type) }
line_item { |p| p.association(:line_item) }
end
end

FactoryGirl.define do
factory :customizable_product_option, :class => Spree::CustomizableProductOption do
sequence(:name) { |n| "Customizable Product Option ##{n} - #{Kernel.rand(9999)}" }
sequence(:presentation) { |n| "Customizable Product Option Presentation ##{n} - #{Kernel.rand(9999)}" }
sequence(:description) { |n| "Customizable Product Option Description ##{n} - #{Kernel.rand(9999)}" }

product_customization_type { |p| p.association(:product_customization_type) }

end
end

FactoryGirl.define do
factory :customized_product_option, :class => Spree::CustomizedProductOption do
product_customization { |p| p.association(:product_customization) }
customizable_product_option { |p| p.association(:customizable_product_option) }
sequence(:value) { |n| "Customizaed Product Option Value ##{n} - #{Kernel.rand(9999)}" }
end
end

FactoryGirl.define do
factory :ad_hoc_option_type, :class => Spree::AdHocOptionType do
product { |p| p.association(:product) }
option_type { |p| p.association(:option_type) }
end
end


FactoryGirl.define do
factory :ad_hoc_option_value, :class => Spree::AdHocOptionValue do
ad_hoc_option_type { |p| p.association(:ad_hoc_option_type) }
option_value { |p| p.association(:option_value) }
end
end

FactoryGirl.define do
factory :customizable_product, :parent => :base_product do
after(:create) do |p|
p.product_customization_types << FactoryGirl.create(:product_customization_type)
end
end
end

FactoryGirl.define do
factory :ad_hoc_variant_exclusion, :class => Spree::AdHocVariantExclusion do
product { |p| p.association(:product) }
end
end

FactoryGirl.define do
factory :excluded_ad_hoc_option_value, :class => Spree::ExcludedAdHocOptionValue do
ad_hoc_variant_exclusion { |p| p.association(:ad_hoc_variant_exclusion) }
ad_hoc_option_value { |p| p.association(:ad_hoc_option_value) }
end
end

2 changes: 2 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
require 'spree/testing_support/controller_requests'
require 'spree/testing_support/url_helpers'

require 'spree_flexi_variants/factories'

RSpec.configure do |config|
config.include FactoryGirl::Syntax::Methods
config.include IntegrationHelpers
Expand Down

0 comments on commit 221e3fd

Please sign in to comment.