diff options
Diffstat (limited to 'spec/ruby/core/set/map_spec.rb')
| -rw-r--r-- | spec/ruby/core/set/map_spec.rb | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/spec/ruby/core/set/map_spec.rb b/spec/ruby/core/set/map_spec.rb index 996191b0a8..fd04a8bde1 100644 --- a/spec/ruby/core/set/map_spec.rb +++ b/spec/ruby/core/set/map_spec.rb @@ -1,6 +1,22 @@ require_relative '../../spec_helper' -require_relative 'shared/collect' describe "Set#map!" do - it_behaves_like :set_collect_bang, :map! + before :each do + @set = Set[1, 2, 3, 4, 5] + end + + it "yields each Object in self" do + res = [] + @set.map! { |x| res << x } + res.sort.should == [1, 2, 3, 4, 5].sort + end + + it "returns self" do + @set.map! { |x| x }.should.equal?(@set) + end + + it "replaces self with the return values of the block" do + @set.map! { |x| x * 2 } + @set.should == Set[2, 4, 6, 8, 10] + end end |
