debian-mirror-gitlab/qa/spec/factory/product_spec.rb

40 lines
1 KiB
Ruby
Raw Normal View History

2018-03-17 18:26:18 +05:30
describe QA::Factory::Product do
2018-03-27 19:54:05 +05:30
let(:factory) do
QA::Factory::Base.new
end
let(:attributes) do
{ test: QA::Factory::Product::Attribute.new(:test, proc { 'returned' }) }
end
2018-03-17 18:26:18 +05:30
let(:product) { spy('product') }
2018-03-27 19:54:05 +05:30
before do
allow(QA::Factory::Base).to receive(:attributes).and_return(attributes)
end
2018-03-17 18:26:18 +05:30
describe '.populate!' do
2018-03-27 19:54:05 +05:30
it 'returns a fabrication product and define factory attributes as its methods' do
2018-03-17 18:26:18 +05:30
expect(described_class).to receive(:new).and_return(product)
result = described_class.populate!(factory) do |instance|
instance.something = 'string'
end
expect(result).to be product
2018-03-27 19:54:05 +05:30
expect(result.test).to eq('returned')
2018-03-17 18:26:18 +05:30
end
end
describe '.visit!' do
it 'makes it possible to visit fabrication product' do
allow_any_instance_of(described_class)
.to receive(:current_url).and_return('some url')
allow_any_instance_of(described_class)
.to receive(:visit).and_return('visited some url')
expect(subject.visit!).to eq 'visited some url'
end
end
end