Last active
August 29, 2015 13:56
-
-
Save zillou/9318757 to your computer and use it in GitHub Desktop.
Set operations in Ruby
This file contains hidden or 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
# filename spec/fake_set_spec.rb | |
require 'spec_helper' | |
require 'fake_set' | |
describe FakeSet, '#union' do | |
set1 = FakeSet.new(1, 2, 3) | |
set2 = FakeSet.new(3, 4, 5) | |
expect(set1.union(set2)).to eq FakeSet.new(1, 2, 3, 4, 5) | |
end | |
describe FakeSet, '#intersect' do | |
set1 = FakeSet.new(1, 2, 3) | |
set2 = FakeSet.new(3, 4, 5) | |
expect(set1.intersect(set2)).to eq FakeSet.new(3) | |
end | |
describe FakeSet, '#difference' do | |
set1 = FakeSet.new(1, 2, 3) | |
set2 = FakeSet.new(3, 4, 5) | |
expect(set1.difference(set2)).to eq FakeSet.new(1 ,2) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment