summaryrefslogtreecommitdiff
path: root/spec/ruby/core/set/union_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/set/union_spec.rb')
-rw-r--r--spec/ruby/core/set/union_spec.rb19
1 files changed, 16 insertions, 3 deletions
diff --git a/spec/ruby/core/set/union_spec.rb b/spec/ruby/core/set/union_spec.rb
index 3e77022d4b..206535aae2 100644
--- a/spec/ruby/core/set/union_spec.rb
+++ b/spec/ruby/core/set/union_spec.rb
@@ -1,10 +1,23 @@
require_relative '../../spec_helper'
-require_relative 'shared/union'
describe "Set#union" do
- it_behaves_like :set_union, :union
+ it "is an alias of Set#|" do
+ Set.instance_method(:union).should == Set.instance_method(:|)
+ end
end
describe "Set#|" do
- it_behaves_like :set_union, :|
+ before :each do
+ @set = Set[:a, :b, :c]
+ end
+
+ it "returns a new Set containing all elements of self and the passed Enumerable" do
+ (@set | Set[:b, :d, :e]).should == Set[:a, :b, :c, :d, :e]
+ (@set | [:b, :e]).should == Set[:a, :b, :c, :e]
+ end
+
+ it "raises an ArgumentError when passed a non-Enumerable" do
+ -> { @set | 1 }.should.raise(ArgumentError)
+ -> { @set | Object.new }.should.raise(ArgumentError)
+ end
end