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:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-09-13 21:06:03 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-09-13 21:06:03 +0300
commit40d3d574132d2849646c20eb9d8742b159d9bfc8 (patch)
tree431dee6675639da4421dbb1d6f50b7734a3190c3 /spec/rubocop/cop/qa
parent5939b09fd3db37ec98dfce0345162617d9d1d313 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/rubocop/cop/qa')
-rw-r--r--spec/rubocop/cop/qa/ambiguous_page_object_name_spec.rb54
1 files changed, 54 insertions, 0 deletions
diff --git a/spec/rubocop/cop/qa/ambiguous_page_object_name_spec.rb b/spec/rubocop/cop/qa/ambiguous_page_object_name_spec.rb
new file mode 100644
index 00000000000..8ee720af9a5
--- /dev/null
+++ b/spec/rubocop/cop/qa/ambiguous_page_object_name_spec.rb
@@ -0,0 +1,54 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+require 'rubocop'
+require 'rubocop/rspec/support'
+
+require_relative '../../../../rubocop/cop/qa/ambiguous_page_object_name'
+
+describe RuboCop::Cop::QA::AmbiguousPageObjectName do
+ include CopHelper
+
+ let(:source_file) { 'qa/page.rb' }
+
+ subject(:cop) { described_class.new }
+
+ context 'in a QA file' do
+ before do
+ allow(cop).to receive(:in_qa_file?).and_return(true)
+ end
+
+ it "registers an offense for pages named `page`" do
+ expect_offense(<<-RUBY)
+ Page::Layout::Bar.perform do |page|
+ ^^^^ Don't use 'page' as a name for a Page Object. Use `bar` instead.
+ expect(page).to have_performance_bar
+ expect(page).to have_detailed_metrics
+ end
+ RUBY
+ end
+
+ it "doesnt offend if the page object is named otherwise" do
+ expect_no_offenses(<<-RUBY)
+ Page::Object.perform do |obj|
+ obj.whatever
+ end
+ RUBY
+ end
+ end
+
+ context 'outside of a QA file' do
+ before do
+ allow(cop).to receive(:in_qa_file?).and_return(false)
+ end
+
+ it "does not register an offense" do
+ expect_no_offenses(<<-RUBY)
+ Page::Object.perform do |page|
+ page.do_something
+ end
+ RUBY
+ end
+ end
+end