Skip to content

Instantly share code, notes, and snippets.

@mattpatterson94
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattpatterson94/5171b4798b316ad41959 to your computer and use it in GitHub Desktop.
Save mattpatterson94/5171b4798b316ad41959 to your computer and use it in GitHub Desktop.
Content Formatter spec
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
@robzolkos
Copy link

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) ?

@mattpatterson94
Copy link
Author

Good thinking, will add to it.

@robzolkos
Copy link

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