diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2018-01-09 16:36:09 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2018-01-09 16:36:09 +0300 |
commit | ffd109af4ef74ce54203f4067c2be3d2ff31e137 (patch) | |
tree | 1e4b571233f3e80603908a98e2436e96fcdc61b3 /qa | |
parent | 7725a7071d9ff2a32b9dfa9c19ac827e2e56fd9b (diff) |
Add tests for QA test selectors sanity scenario
Diffstat (limited to 'qa')
-rw-r--r-- | qa/qa/scenario/test/sanity/selectors.rb | 4 | ||||
-rw-r--r-- | qa/spec/scenario/test/sanity/selectors_spec.rb | 40 |
2 files changed, 42 insertions, 2 deletions
diff --git a/qa/qa/scenario/test/sanity/selectors.rb b/qa/qa/scenario/test/sanity/selectors.rb index 365eb3315f8..157336be66f 100644 --- a/qa/qa/scenario/test/sanity/selectors.rb +++ b/qa/qa/scenario/test/sanity/selectors.rb @@ -15,7 +15,7 @@ module QA validators.map(&:errors).flatten.tap do |errors| break if errors.none? - STDERR.puts <<~EOS + $stderr.puts <<~EOS GitLab QA sanity selectors validation test detected problems with your merge request! @@ -40,7 +40,7 @@ module QA EOS - STDERR.puts errors + $stderr.puts errors end validators.each(&:validate!) diff --git a/qa/spec/scenario/test/sanity/selectors_spec.rb b/qa/spec/scenario/test/sanity/selectors_spec.rb new file mode 100644 index 00000000000..a64a60fa119 --- /dev/null +++ b/qa/spec/scenario/test/sanity/selectors_spec.rb @@ -0,0 +1,40 @@ +describe QA::Scenario::Test::Sanity::Selectors do + let(:validator) { spy('validator') } + + before do + stub_const('QA::Page::Validator', validator) + end + + context 'when there are errors detected' do + before do + allow(validator).to receive(:errors).and_return(['some error']) + end + + it 'outputs information about errors' do + expect { described_class.perform } + .to output(/some error/).to_stderr + + expect { described_class.perform } + .to output(/electors validation test detected problems/) + .to_stderr + end + end + + context 'when there are no errors detected' do + before do + allow(validator).to receive(:errors).and_return([]) + end + + it 'processes pages module' do + described_class.perform + + expect(validator).to have_received(:new).with(QA::Page) + end + + it 'triggers validation' do + described_class.perform + + expect(validator).to have_received(:validate!) + end + end +end |