forked from hamstergem/hamster
-
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
6b1980a
commit 2985a65
Showing
6 changed files
with
74 additions
and
4 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
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
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,64 @@ | ||
require 'spec_helper' | ||
|
||
require 'hamster/vector' | ||
|
||
describe Hamster::Vector do | ||
|
||
[:map, :collect].each do |method| | ||
|
||
describe "##{method}" do | ||
|
||
describe "when empty" do | ||
|
||
before do | ||
@original = Hamster.vector | ||
@mapped = @original.send(method) {} | ||
end | ||
|
||
it "returns self" do | ||
@mapped.should equal(@original) | ||
end | ||
|
||
end | ||
|
||
describe "when not empty" do | ||
|
||
before do | ||
@original = Hamster.vector("A", "B", "C") | ||
end | ||
|
||
describe "with a block" do | ||
|
||
before do | ||
@mapped = @original.send(method, &:downcase) | ||
end | ||
|
||
it "preserves the original values" do | ||
@original.should == Hamster.vector("A", "B", "C") | ||
end | ||
|
||
it "returns a new vector with the mapped values" do | ||
@mapped.should == Hamster.vector("a", "b", "c") | ||
end | ||
|
||
end | ||
|
||
describe "with no block" do | ||
|
||
before do | ||
@result = @original.send(method) | ||
end | ||
|
||
it "returns self" do | ||
@result.should equal(@original) | ||
end | ||
|
||
end | ||
|
||
end | ||
|
||
end | ||
|
||
end | ||
|
||
end |