Last active
August 29, 2015 14:18
-
-
Save PamBWillenz/3853ce7b2095a3b4ab8f to your computer and use it in GitHub Desktop.
Reading RSpec Tests
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
describe "greet" do | |
it "says hello to someone" do | |
greeting = greet("Steve", "Jobs") | |
expect(greeting).to eq("Hello Steve Jobs.") | |
end | |
end | |
In order to make this test pass, you would implement the greet method as it's written below: | |
def greet(first, last) | |
"Hello #{first} #{last}." | |
end | |
describe "multiply" do | |
it "multiplies its two arguments" do | |
product = multiply(5, 3) | |
expect(product).to eq(15) | |
end | |
end | |
A TESTED METHOD - Assignment | |
describe "link_to" do | |
it "should return a valid link for Bloc" do | |
expect( link_to("Bloc", "https://www.bloc.io") ).to eq("<a href='https://www.bloc.io'>Bloc</a>") | |
end | |
it "should return a valid link for Google" do | |
expect( link_to("Google", "http://www.google.com") ).to eq("<a href='http://www.google.com'>Google</a>") | |
end | |
end | |
def link_to(text, address) | |
"<a href='#{address}'>#{text}</a>" | |
end | |
p link_to("https://www.bloc.io", "Bloc") | |
p link_to("http://www.google.com", "Google") | |
Output | |
"<a href='Bloc'>https://www.bloc.io</a>" | |
"<a href='Google'>http://www.google.com</a>" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment