-
-
Notifications
You must be signed in to change notification settings - Fork 359
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #301 from samphippen/array-including-matcher
Add an array_including argument matcher
- Loading branch information
Showing
6 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
require 'spec_helper' | ||
|
||
module RSpec | ||
module Mocks | ||
module ArgumentMatchers | ||
describe ArrayIncludingMatcher do | ||
it "describes itself properly" do | ||
expect(ArrayIncludingMatcher.new([1, 2, 3]).description).to eq "array_including(1,2,3)" | ||
end | ||
|
||
context "passing" do | ||
it "matches the same array" do | ||
expect(array_including(1, 2, 3)).to eq([1, 2, 3]) | ||
end | ||
|
||
it "matches the same array, specified without square brackets" do | ||
expect(array_including(1, 2, 3)).to eq([1, 2, 3]) | ||
end | ||
|
||
it "matches the same array, which includes nested arrays" do | ||
expect(array_including([1, 2], 3, 4)).to eq([[1, 2], 3, 4]) | ||
end | ||
|
||
it "works with duplicates in expected" do | ||
expect(array_including(1, 1, 2, 3)).to eq([1, 2, 3]) | ||
end | ||
|
||
it "works with duplicates in actual" do | ||
expect(array_including(1, 2, 3)).to eq([1, 1, 2, 3]) | ||
end | ||
end | ||
|
||
context "failing" do | ||
it "fails when not all the entries in the expected are present" do | ||
expect(array_including(1,2,3,4,5)).not_to eq([1,2]) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters