- Fork this repo
- Clone your fork
- Fill in your answers by writing in the appropriate area, or placing an 'x' in the square brackets (for multiple-choice questions).
- Add/Commit/Push your changes to Github.
- Open a pull request.
Note: Only place your answer between backticks. Don't modify the backticks, or the language specifier after them.
Define a method called offer_rose
, which should take one argument named person
.
When called the method should puts
"Would you take this rose, person
, in exchange for giving an old beggar woman shelter from the bitter cold?"
Demonstrate calling the method, passing in "young prince" as the argument.
Write your code here:
# code here
Assume the following hash:
town = {
residents: ["Maurice", "Belle", "Gaston"],
castle: {
num_rooms: 47,
residents: "Robby Benson",
guests: []
}
}
Using Ruby, remove Belle from the town residents, and add her to the list of guests in the castle.
Write your code here:
# code here
Assume you have an array of strings representing friend's names:
friends = ["Chip Potts", "Cogsworth", "Lumière", "Mrs. Potts"]
Using .each
AND string interpolation, produce output (using puts
) like so:
Belle is friends with Chip Potts
Belle is friends with Cogsworth
Belle is friends with Lumière
Belle is friends with Mrs. Potts
Write your code here:
# code here
Describe the differences between unit and functional testing. What type of testing is RSpec and why?
Your answer:
Replace this with your answer
Using the following RSpec test as an example, explain the differences between describe
and context
:
describe Apartment do
describe "#add_tenant" do
subject(:apartment) do
apartment = Apartment.create(num_beds: 3)
# we start with 2 tenants (3 bedrooms)
apartment.add_tenant("alice")
apartment.add_tenant("bob")
apartment # return the apartment
end
context "when there is room (<= the number of beds)" do
it "adds a tenant" do
apartment.add_tenant("Third tenant")
expect(apartment.tenants.count).to eq(3)
end
end
end
end
Your answer:
Replace this with your answer
Describe what an ERD is, and why we create them for applications. Also give an example what the attributes and relationships might be for the following entities (no need to draw an ERD):
- Genie
- Lamp
- Person
- Pet
Your answer:
Replace this with your answer
Describe what a schema is, and how we represent a one-to-many relationship in a SQL database. If you need an example, you can use: people and wishes (one-to-many).
Your answer:
Replace this with your answer
Assume:
- Your database two working tables,
genies
andlamps
. - You have a working connection to the database for ActiveRecord.
- You have active record models defined for
Genie
andLamp
, and the relationships between the two are set up in Active Record. - Lamps have one property,
wishes_remaining
, and genies have one property,name
.
Write code to do the following:
- Create a lamp with 3 wishes remaining and a genie named 'Genie'
- Create a relationship between 'Genie' and the lamp.
- Update the lamp so it only has one wish left.
- Oh no... Jafar has Aladdin! Thankfully he's wished to become a genie himself!
- Create a new Genie named 'Jafar' and put him in a new lamp with 3 wishes left.
- Free the good Genie by setting his lamp to
nil
Write your code here:
# code here