Last active
August 29, 2015 14:23
-
-
Save mattpatterson94/5171b4798b316ad41959 to your computer and use it in GitHub Desktop.
Content Formatter spec
This file contains hidden or 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
require 'content_formatter' | |
describe ContentFormatter do | |
describe "awesome" | |
it "returns awesome when AW is given" do | |
text = "AW" | |
expect(ContentFormatter.awesome(text)).to eq("Awesome") | |
end | |
it "returns awesome when AW is given multiple times within random text" do | |
text = "blah blah blah AW blah AW blah" | |
expect(ContentFormatter.awesome(text)).to eq("blah blah blah Awesome blah Awesome blah") | |
end | |
it "returns awesome three times when AW is joined together three times" do | |
text = "AWAWAW" | |
expect(ContentFormatter.awesome(text)).to eq("AwesomeAwesomeAwesome") | |
end | |
it "returns nothing when nothing is given" do | |
text = "" | |
expect(ContentFormatter.awesome(text)).to eq("") | |
end | |
end |
Good thinking, will add to it.
line 4 and 6 should be blank (rubocop should be shouting at you re this?)
line 24 is good but you can inline it eg expect(ContentFormatter.awesome("")).to eq("")
and you still haven't covered off nil
In Ruby nil is different to ""
Otherwise these are good to start making pass!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a good start. Can you think of any scenarios that the test doesn't cover (hint: nils, just AW, multiple AWAWAW together etc) ?