diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-22 21:10:06 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-22 21:10:06 +0000 |
commit | c66b5f750f309b995529d63708b482bcc4e3d35c (patch) | |
tree | 1baa97efbc3a37828d763cf4ef4ef6668da864b7 /spec/support_specs | |
parent | 9a14667521070786dbf3e61409a50ef6ef72e7ff (diff) | |
download | gitlab-ce-c66b5f750f309b995529d63708b482bcc4e3d35c.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/support_specs')
-rw-r--r-- | spec/support_specs/matchers/be_sorted_spec.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/support_specs/matchers/be_sorted_spec.rb b/spec/support_specs/matchers/be_sorted_spec.rb new file mode 100644 index 00000000000..e62bc9b36b3 --- /dev/null +++ b/spec/support_specs/matchers/be_sorted_spec.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +require 'fast_spec_helper' + +load File.expand_path('../../../spec/support/matchers/be_sorted.rb', __dir__) + +RSpec.describe 'be_sorted' do + it 'matches empty collections, regardless of arguments' do + expect([]) + .to be_sorted + .and be_sorted.asc + .and be_sorted.desc + .and be_sorted(:foo) + .and be_sorted(:bar) + + expect([].to_set).to be_sorted + expect({}).to be_sorted + end + + it 'matches in both directions' do + expect([1, 2, 3]).to be_sorted.asc + expect([3, 2, 1]).to be_sorted.desc + end + + it 'can match on a projection' do + xs = [['a', 10], ['b', 7], ['c', 4]] + + expect(xs).to be_sorted.asc.by(&:first) + expect(xs).to be_sorted(:first, :asc) + expect(xs).to be_sorted.desc.by(&:second) + expect(xs).to be_sorted(:second, :desc) + end +end |