I am working on Test First Ruby with rspec examples testing...
which I need to pass this test.
it "tokenizes a string" do
calculator.tokens("1 2 3 * + 4 5 - /").should ==
[1, 2, 3, :*, :+, 4, 5, :-, :/]
end
And here is my code
def tokens(str)
data = str.split(' ')
outcomes = []
data.collect do |x|
if x.to_i != 0
outcomes.push(x.to_i)
elsif x.to_i == 0
temp = x.gsub('"', '')
outcomes.push(":#{temp}")
end
end
outcomes
end
However, I got these feedback. Have no idea how to get rid of the quotation mark.
Failure/Error: [1, 2, 3, :*, :+, 4, 5, :-, :/]
expected: [1, 2, 3, :*, :+, 4, 5, :-, :/]
got: [1, 2, 3, ":*", ":+", 4, 5, ":-", ":/"] (using ==)