learn-co-curriculum / cartoon-collections Goto Github PK
View Code? Open in Web Editor NEWCartoon Collections
Home Page: flatironschool.com
License: Other
Cartoon Collections
Home Page: flatironschool.com
License: Other
it "returns false if all calls are shorter than 4 characters" do
calls_short = ["wind", "fire"]
expect(long_planeteer_calls(calls_short)).to eq(false)
end
This should read "returns false if all calls are 4 characters or less"
Just use the regular array creator
lab says that it wasn't forked, however, i completed the lab, passed the tests and submitted pull request.
so.. I used each_with_index per the instructions, but it is not valid
however, each.with_index is valid
this is highly confusing
It doesn't really make sense to have a name collision like this intentionally. Even though Ruby can typically navigate around it, it seems unnecessarily complicated for where/what it is.
it "returns true if any calls are longer than 4 characters" do
long_planeteer_calls = ["earth", "wind", "fire", "water", "heart"]
expect(long_planeteer_calls(long_planeteer_calls)).to eq(true)
end
Method also named: long_planeteer_calls
Should be an easy fix.
@aturkewi
ommitting changes...
It looks like you have no changes to commit. Will still try updating your submission...
Pushing changes to GitHub...
Username for 'https://github.com': Seems there was an error pushing to GitHub. Trying again...
Pushing changes to GitHub...
Username for 'https://github.com': Seems there was an error pushing to GitHub. Trying again...
Pushing changes to GitHub...
Username for 'https://github.com': Seems there was an error pushing to GitHub. Trying again...
Pushing changes to GitHub...
Username for 'https://githu
Hey guys. I got to pass this test passing with an incorrect logic so seems the rspec didn't meet all criteria. I realized it afterward and managed to go back to fix my code and solve it.
Just wanted to report on it. Here's the incorrect logic that passed it:
#logic is not correct and I passed.
def long_planeteer_calls(arr)
arr.find do |x|
if x.length == 4
return false
else
return true
end
end
end
#incorrect logic and it passed.
def find_the_cheese(arr)
# the array below is here to help
cheese_types = ["cheddar", "gouda", "camembert"]
counter = 0
arr.find do |x|
if x == cheese_types[counter]
x
else
nil
end
end
end
Changing the calls_long array to: calls_long = ["wind", "earth", "fire", "water", "heart"]
should fix this:
Currently, this particular test may give false positives; I was in the middle of trying to correct a student's understanding of how looping worked, and how array and string lengths differed when she more or less stumbled into a passing implementation.
This is potentially pretty bad, given it can mean some students with conceptual misunderstandings may have those misunderstandings reinforced by tests like this.
This code, currently, passes:
def long_planeteer_calls(array)
array.each do |str|
if str.length > 4
return true
end
return false
end
end
(As, of course, do other if/else variations).
Ensuring the first item in the array isn't > 4 chars should ensure solutions like this don't pass and serve to lead students down the wrong path and into potential trouble down the road.
Obviously it's not exactly far off from a solution that would work just fine (moving return false
down one line so that it's outside of the loop), but I feel it's a pretty important basic concept to understand :)
I imagine this was overlooked due to .any?
being the solution most people would think of.
Readme instructions ask to "It should then capitalize each element and add an exclamation point at the end. " whereas the test specs expect only the first letter of each word to be capitalized ie. .capitalize instead of .upcase
describe "#long_planeteer_calls" do
it "returns true if any calls are longer than 4 characters" do
calls_long = ["axe", "earth", "wind", "fire", "water", "heart"]
expect(long_planeteer_calls(calls_long)).to eq(true)
end
it "returns false if all calls are shorter than 4 characters" do
calls_short = ["wind", "fire"]
expect(long_planeteer_calls(calls_short)).to eq(false)
end
end
Students' first intuition may lead them to experiment with .length
without first turning to iteration. Below is one of the possible solutions a student may attempt:
def long_planeteer_calls(words)
if words.length > 4
true
else
false
end
end
Or even simply:
def long_planeteer_calls(words)
words.length > 4
end
Calling the #length
method on the argument array returns the length of the array. Unfortunately, the way the spec is written causes this to pass the specs, since the only example that is expecting true
has six elements in the array, and the only example expecting false
has only two elements in the array.
Simply removing two words from the argument given in the first spec and adding three or more words of length <= 4 to the second spec will fix this error, eliminating the possibility that a student could be passing spec with an insufficient solution.
#Staff
cartoon-collections/spec/cartoon_collections_spec.rb
Lines 33 to 35 in 565cfb6
That is doing another test...yet it's in the same it block. Should be two it blocks. Technically, we shouldn't just test the same method with two different inputs, but this blocks the just making it work for one input problem
describe "#long_planteer_calls" do
it "returns true if any calls are longer than 4 characters" do
long_planteer_calls = ["earth", "wind", "fire", "water", "heart"] --> variable is long_planteer_calls
expect(long_planteer_calls(long_planeteer_calls)).to eq(true) --> variable is long_planeteer_calls
end
Misspelled variable causes test to fail due to undefined variable no matter what.
Segment can be found in lines 41-45 of cartoon_collections_spec.rb
notice how each of these
cartoon-collections/spec/cartoon_collections_spec.rb
Lines 51 to 61 in 565cfb6
The test suite tests for things not part of the code given. (This is a lab where all the code is handed to us to input, but the test suite is testing for different things).
Here is the code given to us:
`def hello_t(array)
i = 0
while i < array.length
yield(array[i])
i = i + 1
end
array
end
hello_t(["Tim", "Tom", "Jim"]) do |name|
if name.start_with?("T")
puts "Hi, #{name}"
end
end`
And here is the test suite:
`require "spec_helper"
describe "#hello_t" do
let (:names) { ["Tim", "Tom", "Jim"] }
it "only passes names that start with 'T' to the block" do
expect{hello_t(names){|name| puts "Hi, #{name}" }}.to output("Hi, Tim\nHi, Tom\n").to_stdout
end
it "returns an array with only names that start with 'T'" do
expect(hello_t(names) {|name| puts "Hi, #{name}" }).to eq(["Tim", "Tom"])
end
it "is case insensitive" do
other_names = ["tim", "tom", "jim"]
expect{hello_t(other_names){|name| puts "Hi, #{name}" }}.to output("Hi, tim\nHi, tom\n").to_stdout
end
end`
What it's supposed to do is iterate through the array, puts 'Hi, Tim' and 'Hi, Tom', and return the original array. The test suite wants other things, and an updated array returned.
Here
cartoon-collections/spec/cartoon_collections_spec.rb
Lines 44 to 45 in 565cfb6
Those belong in two different tests. In general you only want one expect per it anyways
In the Cartoon_collections_spec.rb file there was a typo i believe the word plan(e)teer was spelled wrong: I fixed it like this: describe "#long_planteer_calls" do it "returns true if any calls are longer than 4 characters" do long_planeteer_calls = ["earth", "wind", "fire", "water", "heart"] expect(long_planeteer_calls(long_planeteer_calls)).to eq(true) end it "returns false if all calls are shorter than 4 characters" do short_planeteer_calls = ["wind", "fire"] expect(long_planeteer_calls(short_planeteer_calls)).to eq(false) end
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.