Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

require 'hashes.rb' RSpec.configure do |config| config.filter_run_excluding :disabled => true end describe 'Ruby Hashes Part I' do describe array_2_hash do it should be defined do expect

image text in transcribedimage text in transcribed

require 'hashes.rb'

RSpec.configure do |config| config.filter_run_excluding :disabled => true end

describe 'Ruby Hashes Part I' do

describe "array_2_hash" do it "should be defined" do expect { array_2_hash(["bobsmith@example.com","sallyfield@example.com","markdole@example.com"], {'Bob Smith'=>'', 'Sally Field'=>'', 'Mark Dole'=>''}) }.not_to raise_error end it "returns the correct hash [20 points]" , points: 20 do expect(array_2_hash(["bobsmith@example.com","sallyfield@example.com","markdole@example.com"], {'Bob Smith'=>'', 'Sally Field'=>'', 'Mark Dole'=>''})).to be_a_kind_of Hash expect(array_2_hash(["bobsmith@example.com","sallyfield@example.com","markdole@example.com"], {'Bob Smith'=>'', 'Sally Field'=>'', 'Mark Dole'=>''})).to eq({'Bob Smith'=>'bobsmith@example.com', 'Sally Field'=>'sallyfield@example.com', 'Mark Dole'=>'markdole@example.com'}) end it "works on the empty array [10 points]" , points: 10 do expect { array_2_hash([], {'Bob Smith'=>'', 'Sally Field'=>'', 'Mark Dole'=>''}) }.not_to raise_error expect(array_2_hash([], {'Bob Smith'=>'', 'Sally Field'=>'', 'Mark Dole'=>''})).to eq({'Bob Smith'=>'', 'Sally Field'=>'', 'Mark Dole'=>''}) end end end

describe 'Ruby Hashes Part II' do

describe "array2d_2_hash", :disabled =>true do it "should be defined" do expect { array2d_2_hash([["bobsmith@example.com", "555-555-5555"],["sallyfield@example.com","111-111-1111"]], {'Bob Smith'=>{}, 'Sally Field'=>{}}) }.not_to raise_error end it "returns the correct hash [30 points]" , points: 30 do expect(array2d_2_hash([["bobsmith@example.com", "555-555-5555"],["sallyfield@example.com","111-111-1111"]], {'Bob Smith'=>{}, 'Sally Field'=>{}})).to be_a_kind_of Hash expect(array2d_2_hash([["bobsmith@example.com", "555-555-5555"],["sallyfield@example.com","111-111-1111"]], {'Bob Smith'=>{}, 'Sally Field'=>{}})).to eq({"Bob Smith"=>{"email"=>"bobsmith@example.com", "phone"=>"555-555-5555"}, "Sally Field"=>{"email"=>"sallyfield@example.com", "phone"=>"111-111-1111"}}) end it "works on the empty array [10 points]" , points: 10 do expect { array2d_2_hash([[]], {'Bob Smith'=>{}, 'Sally Field'=>{}}) }.not_to raise_error expect(array2d_2_hash([[]], {'Bob Smith'=>{}, 'Sally Field'=>{}})).to eq({"Bob Smith"=>{}, "Sally Field"=>{}}) end end end

----------------------------------------------------------------------------------------------------------------------------------------------------

# RubyHashes # Part I def array_2_hash emails, contacts #your code here end

# Part II def array2d_2_hash contact_info, contacts # YOUR CODE HERE end

# Part III def hash_2_array contacts #your code here end

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

T hashes_spec.rb hashes.rb require 'hashes.rb' min RSpec.configure do config config.filter_run_excluding :disabled => true end describe "Ruby Hashes Part I' do describe "array_2_hash" do it "should be defined" do expect array_2_hash(["bobsmith@example.com", "sallyfield example.com", "markdolefexample.com"}, {"Bob Smith'=>'', 'Sally Field'=>'', 'Mark Dole'=>''}) } .not_to raise_error end it "returns the correct hash [28 points]", points: 20 do expect(array_2_hash(["bobsmith@example.com", "sallyfield@example.com", "markdole@example.com"}, {"Bob Smith'=>'", "Sally Field'=>'', 'Mark Dole'=>''})).to be_a_kind of Hash expect (array 2 hash(["bobsmith@example.com", "sallyfield@example.com", "markdole@example.com"}, {'Bob Smith'=>'', 'Sally Field'=>', Mark Dole'=>''})).to eq({ 'Bob Smith' => 'bobsmith@example.com', 'Sally Field'>'sallyfield example.com', 'Mark Dole' => markdoledexample.com'>> end it "works on the empty array [10 points]", points: 10 do expect array_2_hash([], {'Bob Smith'=>'', 'Sally Field'=>'', 'Mark Dole'=>''}) }.not_to raise_error expect (array_2_hash([1, {"Bob Smith'=>'', 'Sally Field'=>'', 'Mark Dole'=>''})).to eq({ 'Bob Smith'=>'', 'Sally Field"=>", "Mark Dole'=>' end ) end end describe 'Ruby Hashes Part II" do describe "array2d_2_hash", disabled =>true do it "should be defined" do expect { array2d_2_hash([["bobsmith@example.com", "555-555-5555"],["sallyfield@example.com", "111-111-1111"]], ['Bob Smith'=>{}, "Sally Field"=>{}}) }.not_to raise_error end it "returns the correct hash [38 points]" , points: 38 do expect (array2d_2_hash([[ "bobsmith@example.com", "555-555-5555"],["sallyfield@example.com","111-111-1111"]}, {"Bob Smith'=>{}, "Sally Field' =>{}}>).to be a kind of Hash expect(array2d 2 hash([[ "bobsmith@example.com", "555-555-5555"],["sallyfield@example.com", "111-111-1111"]), ('Bob Smith'=>{}, "Sally Field'=>${}}>).to eq({"Bob Smith"=>{"email"=>"bobsmith@example.com", "phone" => "555-555-5555"}, "Sally Field"=>{"email"=>"sallyfield@example.com", "phone"=>"111-11 end it works on the empty array (18 points]", points: 10 do expect array2d_2_hash([0]), ('Bob Smith'=>{}, 'Sally Field' =>()} }.not_to raise_error expect (array2d_2_hash([0]), ('Bob Smith'=>{}, 'Sally Field' =>{}}).to eq[{"Bob Smith"=>{}, "Sally Field"=>0}}) end end end 42 43 3 hashes.ro hashes_spec.rb X + 1 2 3 # RubyHashes # Part I def array_2_hash emails, contacts #your code here end 5 # Part II def array2d 2 hash contact_info, contacts # YOUR CODE HERE end # Part III def hash_2_array contacts #your code here end 15 T hashes_spec.rb hashes.rb require 'hashes.rb' min RSpec.configure do config config.filter_run_excluding :disabled => true end describe "Ruby Hashes Part I' do describe "array_2_hash" do it "should be defined" do expect array_2_hash(["bobsmith@example.com", "sallyfield example.com", "markdolefexample.com"}, {"Bob Smith'=>'', 'Sally Field'=>'', 'Mark Dole'=>''}) } .not_to raise_error end it "returns the correct hash [28 points]", points: 20 do expect(array_2_hash(["bobsmith@example.com", "sallyfield@example.com", "markdole@example.com"}, {"Bob Smith'=>'", "Sally Field'=>'', 'Mark Dole'=>''})).to be_a_kind of Hash expect (array 2 hash(["bobsmith@example.com", "sallyfield@example.com", "markdole@example.com"}, {'Bob Smith'=>'', 'Sally Field'=>', Mark Dole'=>''})).to eq({ 'Bob Smith' => 'bobsmith@example.com', 'Sally Field'>'sallyfield example.com', 'Mark Dole' => markdoledexample.com'>> end it "works on the empty array [10 points]", points: 10 do expect array_2_hash([], {'Bob Smith'=>'', 'Sally Field'=>'', 'Mark Dole'=>''}) }.not_to raise_error expect (array_2_hash([1, {"Bob Smith'=>'', 'Sally Field'=>'', 'Mark Dole'=>''})).to eq({ 'Bob Smith'=>'', 'Sally Field"=>", "Mark Dole'=>' end ) end end describe 'Ruby Hashes Part II" do describe "array2d_2_hash", disabled =>true do it "should be defined" do expect { array2d_2_hash([["bobsmith@example.com", "555-555-5555"],["sallyfield@example.com", "111-111-1111"]], ['Bob Smith'=>{}, "Sally Field"=>{}}) }.not_to raise_error end it "returns the correct hash [38 points]" , points: 38 do expect (array2d_2_hash([[ "bobsmith@example.com", "555-555-5555"],["sallyfield@example.com","111-111-1111"]}, {"Bob Smith'=>{}, "Sally Field' =>{}}>).to be a kind of Hash expect(array2d 2 hash([[ "bobsmith@example.com", "555-555-5555"],["sallyfield@example.com", "111-111-1111"]), ('Bob Smith'=>{}, "Sally Field'=>${}}>).to eq({"Bob Smith"=>{"email"=>"bobsmith@example.com", "phone" => "555-555-5555"}, "Sally Field"=>{"email"=>"sallyfield@example.com", "phone"=>"111-11 end it works on the empty array (18 points]", points: 10 do expect array2d_2_hash([0]), ('Bob Smith'=>{}, 'Sally Field' =>()} }.not_to raise_error expect (array2d_2_hash([0]), ('Bob Smith'=>{}, 'Sally Field' =>{}}).to eq[{"Bob Smith"=>{}, "Sally Field"=>0}}) end end end 42 43 3 hashes.ro hashes_spec.rb X + 1 2 3 # RubyHashes # Part I def array_2_hash emails, contacts #your code here end 5 # Part II def array2d 2 hash contact_info, contacts # YOUR CODE HERE end # Part III def hash_2_array contacts #your code here end 15

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started