Skip to content

Instantly share code, notes, and snippets.

@forforf
Created August 13, 2013 16:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save forforf/6222977 to your computer and use it in GitHub Desktop.
Save forforf/6222977 to your computer and use it in GitHub Desktop.
class Cloner
def clone_array_of_hashes(a)
a.map{|h| h.clone}
end
end
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