Created
August 13, 2013 16:34
-
-
Save forforf/6222977 to your computer and use it in GitHub Desktop.
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
class Cloner | |
def clone_array_of_hashes(a) | |
a.map{|h| h.clone} | |
end | |
end |
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
require_relative "./cloner" | |
describe Cloner do | |
let(:cloner) {Cloner.new} | |
let(:orig_ah) { [{a: "A"},{b: "B"}] } | |
let(:cloned_ah) { cloner.clone_array_of_hashes(orig_ah) } | |
it "passes" do | |
cloned_ah[0] #this is the only difference between the two tests | |
orig_ah[0][:a] = "AA" | |
expect(orig_ah[0]).to_not eq(cloned_ah[0]) | |
end | |
it "fails but should pass" do | |
orig_ah[0][:a] = "AA" | |
expect(orig_ah[0]).to_not eq(cloned_ah[0]) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment