diff options
Diffstat (limited to 'qa/spec/factory/product_spec.rb')
-rw-r--r-- | qa/spec/factory/product_spec.rb | 66 |
1 files changed, 7 insertions, 59 deletions
diff --git a/qa/spec/factory/product_spec.rb b/qa/spec/factory/product_spec.rb index 43b1d93d769..5b6eaa13e9c 100644 --- a/qa/spec/factory/product_spec.rb +++ b/qa/spec/factory/product_spec.rb @@ -1,73 +1,21 @@ describe QA::Factory::Product do let(:factory) do Class.new(QA::Factory::Base) do - def foo - 'bar' + attribute :test do + 'block' end + + attribute :no_block end.new end let(:product) { spy('product') } let(:product_location) { 'http://product_location' } - subject { described_class.new(factory, product_location) } - - describe '.populate!' do - before do - expect(factory.class).to receive(:attributes).and_return(attributes) - end - - context 'when the product attribute is populated via a block' do - let(:attributes) do - [QA::Factory::Product::Attribute.new(:test, proc { 'returned' })] - end - - it 'returns a fabrication product and defines factory attributes as its methods' do - result = described_class.populate!(factory, product_location) - - expect(result).to be_a(described_class) - expect(result.test).to eq('returned') - end - end - - context 'when the product attribute is populated via the api' do - let(:attributes) do - [QA::Factory::Product::Attribute.new(:test)] - end - - it 'returns a fabrication product and defines factory attributes as its methods' do - expect(factory).to receive(:api_resource).and_return({ test: 'returned' }) - - result = described_class.populate!(factory, product_location) + subject { described_class.new(factory) } - expect(result).to be_a(described_class) - expect(result.test).to eq('returned') - end - end - - context 'when the product attribute is populated via a factory attribute' do - let(:attributes) do - [QA::Factory::Product::Attribute.new(:foo)] - end - - it 'returns a fabrication product and defines factory attributes as its methods' do - result = described_class.populate!(factory, product_location) - - expect(result).to be_a(described_class) - expect(result.foo).to eq('bar') - end - end - - context 'when the product attribute has no value' do - let(:attributes) do - [QA::Factory::Product::Attribute.new(:bar)] - end - - it 'returns a fabrication product and defines factory attributes as its methods' do - expect { described_class.populate!(factory, product_location) } - .to raise_error(described_class::NoValueError, "No value was computed for product bar of factory #{factory.class.name}.") - end - end + before do + factory.web_url = product_location end describe '.visit!' do |