-
Notifications
You must be signed in to change notification settings - Fork 79
Completed Challenge #59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,78 +5,78 @@ | |
| context "guess the collection" do | ||
|
|
||
| it "Yes, it is a Object, but which class" do | ||
| expect([].is_a? _fill_in_object_).to be true | ||
| expect(Array.new.instance_of? _FILL_ME_IN_).to be true | ||
| expect([].is_a? Array).to be true | ||
| expect(Array.new.instance_of? Array).to be true | ||
| end | ||
|
|
||
| it "Yes, it is a Object, but which class" do | ||
| expect({}.is_a? _fill_in_object_).to be true | ||
| expect(Hash.new.instance_of? _FILL_ME_IN_).to be true | ||
| expect({}.is_a? Hash).to be true | ||
| expect(Hash.new.instance_of? Hash).to be true | ||
| end | ||
| end | ||
|
|
||
| context "guess the type" do | ||
| it "Yes, it is a Object, but which" do | ||
| expect(:class.is_a? _fill_in_object_).to be true | ||
| expect(:class.is_a? Object).to be true | ||
| end | ||
|
|
||
| it "Yes, it is a Object, but which" do | ||
| expect("module".is_a? _fill_in_object_).to be true | ||
| expect("module".is_a? String).to be true | ||
| end | ||
|
|
||
| it "Yes, it is a Object, but which" do | ||
| expect(1.is_a? _fill_in_object_).to be true | ||
| expect(1.is_a? Integer).to be true | ||
| end | ||
|
|
||
| it "Yes, it is a Object, but which" do | ||
| expect(1.5.is_a? _fill_in_object_).to be true | ||
| expect(1.5.is_a? Float).to be true | ||
| end | ||
| end | ||
|
|
||
| context "the following are Array methods" do | ||
| it "adds a thing to the end of the method" do | ||
| expect([]._fill_in_method_here_(1)).to eq [1] | ||
| expect([].push(1)).to eq [1] | ||
| end | ||
|
|
||
| it "removes an item from the end of an array" do | ||
| expect([1]._fill_in_method_here_).to eq 1 | ||
| expect([1].pop).to eq 1 | ||
| end | ||
|
|
||
| it "adds an item to the front of an array" do | ||
| expect([1]._fill_in_method_here_("banana")).to eq ["banana", 1] | ||
| expect([1].unshift("banana")).to eq ["banana", 1] | ||
| end | ||
|
|
||
| it "removes an item from the front of an array" do | ||
| expect([1, "banana"]._fill_in_method_here_).to eq 1 | ||
| expect([1, "banana"].shift).to eq 1 | ||
| end | ||
| end | ||
|
|
||
| context "the following are Hash methods" do | ||
| it "adds a key and value to a Hash" do | ||
| a_hash = {} | ||
| fail "remove this entire line, implement your solution here" | ||
| expect(a_hash.empty?).to be false | ||
| a_hash[:butt] = :head | ||
| expect(a_hash.empty?).to be false | ||
| end | ||
|
|
||
| it "returns a value from the hash for the given key" do | ||
| a_hash = {magic: :johnson, shirley: :temple, "babe" => "ruth"} | ||
|
|
||
| expect(a_hash.fetch(:magic)).to eq _fill_in_sym_or_str | ||
| expect(a_hash[:shirley]).to eq _fill_in_sym_or_str | ||
| expect(a_hash["babe"]).to eq _fill_in_sym_or_str | ||
| expect(a_hash.fetch(:magic)).to eq :johnson | ||
| expect(a_hash[:shirley]).to eq :temple | ||
| expect(a_hash["babe"]).to eq "ruth" | ||
| end | ||
|
|
||
| it "removes a key value pair from a hash" do | ||
| a_hash = { frank: :sinatra } | ||
| a_hash._fill_in_method_here_(:frank) | ||
| a_hash.delete(:frank) | ||
| expect(a_hash.empty?).to be true | ||
| end | ||
| end | ||
|
|
||
| context "on loops, yeah!!!" do | ||
| it "should loop over the array and return a new array" do | ||
| loopy = [1,2,3] | ||
| expect(loopy._fill_in_method_here_ { |n| n + 1 }).to eq [2,3,4] | ||
| expect(loopy.map! { |n| n + 1 }).to eq [2,3,4] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There you go! Er, except you don't want the |
||
| end | ||
| end | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's an
Object, but which....?