Last active
August 29, 2015 14:02
-
-
Save ryanholm/64fed4a4214d8e4af582 to your computer and use it in GitHub Desktop.
BLOC Debugging Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1CP NoMethodError | |
def hello(name) | |
"Hello #{name}" | |
end | |
# RSpec | |
describe "hello" do | |
it "should return 'Hello World' when passed 'World'" do | |
hello("World").should eq("Hello World") | |
end | |
it "should return 'Hello Bob' when passed 'Bob'" do | |
hello("Bob").should eq("Hello Bob") | |
end | |
end | |
#2CP | |
def hello(first, last) | |
"Hello #{first} #{last}" | |
end | |
#RSpec | |
describe "hello" do | |
it "returns a full greeting for Abraham Lincoln" do | |
hello("Abraham", "Lincoln").should eq("Hello Abraham Lincoln") | |
end | |
it "returns a full greeting for George Washington" do | |
hello("George", "Washington").should eq("Hello George Washington") | |
end | |
end | |
#3CP NoNameError | |
def hello(first, last) | |
"Hello #{first} #{last}" | |
end | |
# RSpec | |
describe "hello" do | |
it "should return 'Hello first name last name'" do | |
hello("Steve", "Jobs").should eq("Hello Steve Jobs") | |
end | |
end | |
#4CP TypeError #String can't be coerced into Fixnum | |
def add(a,b) | |
"#{a} + #{b} = #{a + b}" | |
end | |
#RSpec | |
describe "add" do | |
it "returns a string with 1 and 2 added" do | |
add(1,2).should eq("1 + 2 = 3") | |
end | |
it "returns a string with 5 and 7 added" do | |
add(5,7).should eq("5 + 7 = 12") | |
end | |
end | |
#4CP Unexpected End | |
def hello | |
"Hello World" | |
end | |
# RSpec | |
describe "hello" do | |
it "should return 'Hello World'" do | |
hello.should eq("Hello World") | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment