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 'spec/support/matchers.rb')
-rw-r--r--spec/support/matchers.rb79
1 files changed, 0 insertions, 79 deletions
diff --git a/spec/support/matchers.rb b/spec/support/matchers.rb
deleted file mode 100644
index 52b11bd6323..00000000000
--- a/spec/support/matchers.rb
+++ /dev/null
@@ -1,79 +0,0 @@
-RSpec::Matchers.define :be_valid_commit do
- match do |actual|
- actual != nil
- actual.id == ValidCommit::ID
- actual.message == ValidCommit::MESSAGE
- actual.author_name == ValidCommit::AUTHOR_FULL_NAME
- end
-end
-
-RSpec::Matchers.define :be_allowed_for do |user|
- match do |url|
- include UrlAccess
- url_allowed?(user, url)
- end
-end
-
-RSpec::Matchers.define :be_denied_for do |user|
- match do |url|
- include UrlAccess
- url_denied?(user, url)
- end
-end
-
-RSpec::Matchers.define :be_404_for do |user|
- match do |url|
- include UrlAccess
- url_404?(user, url)
- end
-end
-
-RSpec::Matchers.define :include_module do |expected|
- match do
- described_class.included_modules.include?(expected)
- end
-
- failure_message_for_should do
- "expected #{described_class} to include the #{expected} module"
- end
-end
-
-module UrlAccess
- def url_allowed?(user, url)
- emulate_user(user)
- visit url
- (status_code != 404 && current_path != new_user_session_path)
- end
-
- def url_denied?(user, url)
- emulate_user(user)
- visit url
- (status_code == 404 || current_path == new_user_session_path)
- end
-
- def url_404?(user, url)
- emulate_user(user)
- visit url
- status_code == 404
- end
-
- def emulate_user(user)
- user = case user
- when :user then create(:user)
- when :visitor then nil
- when :admin then create(:admin)
- else user
- end
- login_with(user) if user
- end
-end
-
-# Extend shoulda-matchers
-module Shoulda::Matchers::ActiveModel
- class EnsureLengthOfMatcher
- # Shortcut for is_at_least and is_at_most
- def is_within(range)
- is_at_least(range.min) && is_at_most(range.max)
- end
- end
-end