Skip to content
This repository has been archived by the owner on Oct 27, 2021. It is now read-only.

Commit

Permalink
rename ContainExactly to MatchArray
Browse files Browse the repository at this point in the history
  • Loading branch information
Pat Maddox authored and dchelimsky committed Nov 27, 2008
1 parent 1bad0db commit 4b0473f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/spec/matchers.rb
Expand Up @@ -6,7 +6,7 @@
require 'spec/matchers/be'
require 'spec/matchers/be_close'
require 'spec/matchers/change'
require 'spec/matchers/contain_exactly'
require 'spec/matchers/match_array'
require 'spec/matchers/eql'
require 'spec/matchers/equal'
require 'spec/matchers/exist'
Expand Down
@@ -1,7 +1,7 @@
module Spec
module Matchers

class ContainExactly #:nodoc:
class MatchArray #:nodoc:

def initialize(expecteds)
@expecteds = expecteds
Expand Down Expand Up @@ -59,21 +59,20 @@ def _pretty_print(array)
end

# :call-seq:
# should contain_exactly(expected)
# should =~ expected
#
# Passes if givens contains all of the expected regardless of order.
# This works for collections. Pass in multiple args and it will only
# pass if all args are found in collection.
#
# NOTE: there is no should_not version of contain_exactly
# NOTE: there is no should_not version of array.should =~ other_array
#
# == Examples
#
# [1,2,3].should contain_exactly(1,2,3) # => would pass
# [1,2,3].should contain_exactly(2,3,1) # => would pass
# [1,2,3,4].should contain_exactly(1,2,3) # => would fail
# [1,2,3].should contain_exactly(1,2,3,4) # => would fail

OperatorMatcher.register(Array, '=~', Spec::Matchers::ContainExactly)
# [1,2,3].should =~ [1,2,3] # => would pass
# [1,2,3].should =~ [2,3,1] # => would pass
# [1,2,3,4].should [1,2,3] # => would fail
# [1,2,3].should [1,2,3,4] # => would fail
OperatorMatcher.register(Array, '=~', Spec::Matchers::MatchArray)
end
end
2 changes: 1 addition & 1 deletion spec/spec/matchers/match_array_spec.rb
Expand Up @@ -73,7 +73,7 @@

end

describe "should_not contain_exactly(with, multiple, args)" do
describe "should_not [:with, :multiple, :args]" do
it "should not exist" do
lambda {
[1,2,3].should_not =~ [1,2,3]
Expand Down

0 comments on commit 4b0473f

Please sign in to comment.