Skip to content

Instantly share code, notes, and snippets.

@harrisonmalone
Last active December 30, 2019 00:55
Show Gist options
  • Save harrisonmalone/c58a8d0dd979faaac10d0e118064fea1 to your computer and use it in GitHub Desktop.
Save harrisonmalone/c58a8d0dd979faaac10d0e118064fea1 to your computer and use it in GitHub Desktop.
this is what i want all ruby challenges to eventually look like, with rspec tests
# to solve the code below you need to
# => gem install rspec
# then to execute this code run
# => rspec index.rb --format doc
# 1.
def sum(num1, num2)
# your code here
end
describe "#sum" do
it do
result = sum(2, 3)
expect(result).to eq(5)
end
end
# 2.
def say_hello
# your code here
end
describe "#say_hello" do
it do
expect(say_hello).to eq("hello")
end
end
# 3.
def abc_123(str)
# your code here
end
describe "#abc_123" do
it do
expect(abc_123("abc")).to eq("ABC123")
end
end
# 4.
def separate_numbers(arr)
# your code here
end
describe "#separate_numbers" do
it do
result = [[1,2,3],[4,5,6]]
expect(separate_numbers([1,2,3,4,5,6])).to eq(result)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment