Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

@robzolkos robzolkos commented Jun 25, 2015

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

This comment has been minimized.

Copy link
Owner Author

@mattpatterson94 mattpatterson94 commented Jun 25, 2015

Good thinking, will add to it.

@robzolkos

This comment has been minimized.

Copy link

@robzolkos robzolkos commented Jun 25, 2015

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