summaryrefslogtreecommitdiff
path: root/spec/rubyspec/library/set/enumerable/to_set_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/rubyspec/library/set/enumerable/to_set_spec.rb')
-rw-r--r--spec/rubyspec/library/set/enumerable/to_set_spec.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/spec/rubyspec/library/set/enumerable/to_set_spec.rb b/spec/rubyspec/library/set/enumerable/to_set_spec.rb
new file mode 100644
index 0000000000..41ca039de6
--- /dev/null
+++ b/spec/rubyspec/library/set/enumerable/to_set_spec.rb
@@ -0,0 +1,19 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'set'
+
+describe "Emumerable#to_set" do
+ it "returns a new Set created from self" do
+ [1, 2, 3].to_set.should == Set[1, 2, 3]
+ {a: 1, b: 2}.to_set.should == Set[[:b, 2], [:a, 1]]
+ end
+
+ it "allows passing an alternate class for Set" do
+ sorted_set = [1, 2, 3].to_set(SortedSet)
+ sorted_set.should == SortedSet[1, 2, 3]
+ sorted_set.instance_of?(SortedSet).should == true
+ end
+
+ it "passes down passed blocks" do
+ [1, 2, 3].to_set { |x| x * x }.should == Set[1, 4, 9]
+ end
+end