Created
February 19, 2014 22:41
-
-
Save fresh5447/9103199 to your computer and use it in GitHub Desktop.
describe "merge_us" do it "merges two hashes that are unique" do h1 = { name: "Computer", cost: "$1,000" } h2 = { first_name: "Bob", age: 34 } new_hash = { name: "Computer", cost: "$1,000", first_name: "Bob", age: 34 } merge_us(h1, h2).should eq(new_hash) end it "merges two hashes that are have some things in common" do h1 = { name: "Computer", …
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
def merge_us(h1 = {}, h2 = {}) | |
h1.merge(h2) | |
end | |
h1 = { name: "Computer", cost: "$1,000" } | |
h2 = { first_name: "Bob", age: 34 } | |
merge_us(h1, h2) | |
def my_keys(h = {}) | |
h.keys | |
end | |
h = { name: "Computer"} | |
def do_i_have?(h, keys) | |
h.keys.sort == keys.sort | |
end | |
h = { name: "Computer", cost: "$1,000", uuid: "1234" } | |
keys = [:name, :uuid, :cost] | |
do_i_have?(h,keys) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment