learn-co-curriculum / apples-and-holidays Goto Github PK
View Code? Open in Web Editor NEWLicense: Other
License: Other
spec/spec_helper.rb file line 1: require_relative '../lib/apple'
but there is no '../lib/apple'.
tests only run if line is commented-out (or that file is created, obviously).
Make the tests more specific so as to force the use of .compact, etc.
test from handraise
oh my god.
The apple.rb files and tests don't seem to belong here. I got the tests to pass, but there is no mention of the exercise in the description, plus it deals with array methods that are covered earlier in the course.
These tests can be updated. The setup and expectations should be optimized for flow and understanding, not DRY.
# Question 4
# Write a method that adds a new holiday and its associated supplies to any season
describe "#add_new_holiday_with_supplies" do
let(:columbus_supplies) { ["Flags", "Parade Floats", "Candle Sticks"] }
let(:v_day_supplies) { ["Cupid Cut-Out", "Candy Hearts"] }
let(:add_columbus_day) { add_new_holiday_with_supplies(holiday_supplies, :fall, :columbus_day, columbus_supplies) }
let(:add_v_day) { add_new_holiday_with_supplies(holiday_supplies, :winter, :valentines_day, v_day_supplies) }
it "returns an updated version of the original hash" do
[add_columbus_day, add_v_day].each do |result|
expect(result.class).to eq(Hash)
end
end
it "still has exactly four seasons" do
[add_columbus_day, add_v_day].each do |result|
expect(result.keys.size).to eq(4)
end
end
it "has two total holidays in fall when holiday is added to fall" do
num_of_keys_in_fall = add_columbus_day[:fall].keys.size
expect(num_of_keys_in_fall).to eq(2)
end
it "has three total holidays in winter when holiday is added to winter" do
num_of_keys_in_winter = add_v_day[:winter].keys.size
expect(num_of_keys_in_winter).to eq(3)
end
it "adds an extra holiday to the hash in the correct season
where the key is the holiday name and
the value is the array of supplies" do
expect(add_columbus_day[:fall][:columbus_day]).to eq(columbus_supplies)
expect(add_v_day[:winter][:valentines_day]).to eq(v_day_supplies)
end
end
Should be re-written as:
# Question 4
# Write a method that adds a new holiday and its associated supplies to any season
describe "#add_new_holiday_with_supplies" do
it "modifies the original hash by adding supplies of a new holiday to a season" do
columbus_day_supplies = ["Flags", "Parade Floats", "Candle Sticks"]
add_new_holiday_with_supplies(holiday_supplies, :fall, :columbus_day, columbus_day_supplies)
expect(holiday_supplies[:fall].keys).to include(:columbus_day)
expect(holiday_supplies[:fall][:columbus_day]).to match_array(columbus_day_supplies)
valentines_day_supplies = ["Cupid Cut-Out", "Candy Hearts"]
add_new_holiday_with_supplies(holiday_supplies, :winter, :valentines_day, valentines_day_supplies)
expect(holiday_supplies[:fall].keys).to include(:valentines_day)
expect(holiday_supplies[:fall][:columbus_day]).to match_array(valentines_day_supplies)
end
end
I think that's way clearer. Thoughts?
he really needs help.
This is a test from handraise.
Looks like the resource site has been (re)moved. Clicking the link pointing to http://www.codequizzes.com/learn-ruby/iteration-nested-data-structures
will result in an error: "The page you were looking for doesn't exist."
The link to codecademy "night at the movies" is broken.
Hi there.
I was struggling with a lot of this lesson evidently due to the fact that some of the pre-filled arguments for the last few methods in this lab didn't match up to what was provided in the solution. Since I'm fairly new to this I didn't realize that I can just alter those arguments to best fit the solutions needed. I tend to take things too literally so its probably my fault for not realizing I could make those sorts of changes, but it might help some of us newbs if that was mentioned in the hint section.
Test should force iterating through all the winter holidays and add the supply to each of them.
He needed help with everything.
The specifications could not find an apple.rb file. Looking at the github page, it seemed to have been purposefully removed. However, in the specification file I had, it still had:
require_relative '../lib/apple'
Once I commented it out, everything worked fine.
holiday_supplies
in both of these methods should be holiday_hash
.
def all_winter_holiday_supplies(holiday_hash)
holiday_supplies[:winter].map do |holiday, supplies|
supplies
end.flatten
end
def all_supplies_in_holidays(holiday_hash)
holiday_supplies.each do |season, holidays|
puts "#{season.capitalize}:"
holidays.each do |holiday, supplies|
puts" #{holiday.to_s.split('_').map {|w| w.capitalize }.join(' ') }: #{supplies.join(", ")}"
end
end
end
The test describes itself like so: "returns the string 'BBQ' without hardcoding it".
But the test doesn't contain any code that checks for a hardcoded solution:
describe "#second_supply_for_fourth_of_july" do
it "returns the string 'BBQ' without hardcoding it" do
expect(second_supply_for_fourth_of_july(holiday_supplies)).to eq("BBQ")
end
end
Test from handraise production
Is something being done about the error that is coming up sometimes when opening the learn IDE? I have seen comments from other students as well that this is consistently reoccurring. It either shows the error below or does not reconnect Learn IDE.
This is putting people behind on coursework and is making things difficult during an already rigorous program.
I feel like I just got thrown into the deep end of the pool. Here's my fork: https://github.com/markedwardmurray/apples-and-holidays-000
There are still 3 failures:
I don't understand why using the .collect method is returning an empty array on that test.
Why is valentine's day not getting added?
I'm not practiced enough with string interpolation at this point to solve displaying the nested hash according to the expectation. The instructions were not clear that I could have chosen to puts
everything individually. Don't provide two options to solve a challenge: pick one and be clear about the expectation. If you want to keep the second option, turn it into an advanced.
Were I a student at home, this lab may have caused me to give up on Learn.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.