Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'qa/spec/resource/base_spec.rb')
-rw-r--r--qa/spec/resource/base_spec.rb100
1 files changed, 62 insertions, 38 deletions
diff --git a/qa/spec/resource/base_spec.rb b/qa/spec/resource/base_spec.rb
index 2dd25f983bf..eab205ec5d1 100644
--- a/qa/spec/resource/base_spec.rb
+++ b/qa/spec/resource/base_spec.rb
@@ -3,10 +3,45 @@
RSpec.describe QA::Resource::Base do
include QA::Support::Helpers::StubEnv
- let(:resource) { spy('resource', username: 'qa') }
+ let(:resource) { spy('resource') }
let(:location) { 'http://location' }
let(:log_regex) { %r{==> Built a MyResource with username 'qa' via #{method} in [\d.\-e]+ seconds+} }
+ before do
+ allow(QA::Tools::TestResourceDataProcessor).to receive(:collect)
+ allow(QA::Tools::TestResourceDataProcessor).to receive(:write_to_file)
+ end
+
+ shared_context 'with simple resource' do
+ subject do
+ Class.new(QA::Resource::Base) do
+ def self.name
+ 'MyResource'
+ end
+
+ attribute :test do
+ 'block'
+ end
+
+ attribute :username do
+ 'qa'
+ end
+
+ attribute :no_block
+
+ def fabricate!(*args)
+ 'any'
+ end
+
+ def self.current_url
+ 'http://stub'
+ end
+ end
+ end
+
+ let(:resource) { subject.new }
+ end
+
shared_context 'with fabrication context' do
subject do
Class.new(described_class) do
@@ -56,23 +91,29 @@ RSpec.describe QA::Resource::Base do
end
describe '.fabricate_via_api!' do
- include_context 'with fabrication context'
+ context 'when fabricating' do
+ include_context 'with fabrication context'
- it_behaves_like 'fabrication method', :fabricate_via_api!
+ it_behaves_like 'fabrication method', :fabricate_via_api!
- it 'instantiates the resource, calls resource method returns the resource' do
- expect(resource).to receive(:fabricate_via_api!).and_return(location)
+ it 'instantiates the resource, calls resource method returns the resource' do
+ expect(resource).to receive(:fabricate_via_api!).and_return(location)
- result = subject.fabricate_via_api!(resource: resource, parents: [])
+ result = subject.fabricate_via_api!(resource: resource, parents: [])
- expect(result).to eq(resource)
+ expect(result).to eq(resource)
+ end
end
context "with debug log level" do
+ include_context 'with simple resource'
+
let(:method) { 'api' }
before do
allow(QA::Runtime::Logger).to receive(:debug)
+ allow(resource).to receive(:api_support?).and_return(true)
+ allow(resource).to receive(:fabricate_via_api!)
end
it 'logs the resource and build method' do
@@ -88,27 +129,32 @@ RSpec.describe QA::Resource::Base do
end
describe '.fabricate_via_browser_ui!' do
- include_context 'with fabrication context'
+ context 'when fabricating' do
+ include_context 'with fabrication context'
- it_behaves_like 'fabrication method', :fabricate_via_browser_ui!, :fabricate!
+ it_behaves_like 'fabrication method', :fabricate_via_browser_ui!, :fabricate!
- it 'instantiates the resource and calls resource method' do
- subject.fabricate_via_browser_ui!('something', resource: resource, parents: [])
+ it 'instantiates the resource and calls resource method' do
+ subject.fabricate_via_browser_ui!('something', resource: resource, parents: [])
- expect(resource).to have_received(:fabricate!).with('something')
- end
+ expect(resource).to have_received(:fabricate!).with('something')
+ end
- it 'returns fabrication resource' do
- result = subject.fabricate_via_browser_ui!('something', resource: resource, parents: [])
+ it 'returns fabrication resource' do
+ result = subject.fabricate_via_browser_ui!('something', resource: resource, parents: [])
- expect(result).to eq(resource)
+ expect(result).to eq(resource)
+ end
end
context "with debug log level" do
+ include_context 'with simple resource'
+
let(:method) { 'browser_ui' }
before do
allow(QA::Runtime::Logger).to receive(:debug)
+ # allow(resource).to receive(:fabricate!)
end
it 'logs the resource and build method' do
@@ -123,28 +169,6 @@ RSpec.describe QA::Resource::Base do
end
end
- shared_context 'with simple resource' do
- subject do
- Class.new(QA::Resource::Base) do
- attribute :test do
- 'block'
- end
-
- attribute :no_block
-
- def fabricate!
- 'any'
- end
-
- def self.current_url
- 'http://stub'
- end
- end
- end
-
- let(:resource) { subject.new }
- end
-
describe '.attribute' do
include_context 'with simple resource'