forked from flippercloud/flipper
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5aa9cfd
commit 748b431
Showing
4 changed files
with
53 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module Flipper | ||
module Expressions | ||
class Include | ||
def self.call(left, right) | ||
left.respond_to?(:include?) && left.include?(right) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
RSpec.describe Flipper::Expressions::Include do | ||
describe "#call" do | ||
it "returns true when left includes right" do | ||
expect(described_class.call([2], 2)).to be(true) | ||
end | ||
|
||
it "returns false when left does not include right" do | ||
expect(described_class.call([2], "2")).to be(false) | ||
end | ||
|
||
it "returns false when left does not respond to #include?" do | ||
expect(described_class.call(nil, nil)).to be(false) | ||
end | ||
|
||
it "raises ArgumentError with no arguments" do | ||
expect { described_class.call }.to raise_error(ArgumentError) | ||
end | ||
|
||
it "raises ArgumentError with one argument" do | ||
expect { described_class.call(10) }.to raise_error(ArgumentError) | ||
end | ||
end | ||
end |