diff options
Diffstat (limited to 'qa/qa/factory/product.rb')
-rw-r--r-- | qa/qa/factory/product.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/qa/qa/factory/product.rb b/qa/qa/factory/product.rb new file mode 100644 index 00000000000..996b7f14f61 --- /dev/null +++ b/qa/qa/factory/product.rb @@ -0,0 +1,30 @@ +require 'capybara/dsl' + +module QA + module Factory + class Product + include Capybara::DSL + + Attribute = Struct.new(:name, :block) + + def initialize + @location = current_url + end + + def visit! + visit @location + end + + def self.populate!(factory) + new.tap do |product| + factory.class.attributes.each_value do |attribute| + product.instance_exec(factory, attribute.block) do |factory, block| + value = block.call(factory) + product.define_singleton_method(attribute.name) { value } + end + end + end + end + end + end +end |