Skip to content

Instantly share code, notes, and snippets.

@DavidBechtel
Created January 24, 2013 21:11
Show Gist options
  • Save DavidBechtel/4627797 to your computer and use it in GitHub Desktop.
Save DavidBechtel/4627797 to your computer and use it in GitHub Desktop.
presents rspec test file
#presents_spec file
require './fizzbuzz_generator'
require './presents'
describe Presents, "#new" do
context 'as_text for output format'
it "returns fizzbuzz for numbers 1 through 15 in an array" do
p = Presents.new(FizzBuzzGenerator.new(15))
p.as_text.should eq(["1 ","2 ","3 fizz ","4 ","5 buzz ","6 fizz ","7 ","8 ","9 fizz ","10 buzz ","11 ","12 fizz ","13 ","14 ","15 fizzbuzz "])
end
context 'as_json for output format'
it "returns fizzbuzz for numbers 1 through 12 in an array" do
p = Presents.new(FizzBuzzGenerator.new(12))
p.as_json.should eq("[\"1 \",\"2 \",\"3 fizz \",\"4 \",\"5 buzz \",\"6 fizz \",\"7 \",\"8 \",\"9 fizz \",\"10 buzz \",\"11 \",\"12 fizz \"]")
end
context 'as_html for output format'
it "returns fizzbuzz for numbers 1 through 8 in an array" do
p = Presents.new(FizzBuzzGenerator.new(8))
p.as_html.should eq("<ul>\n\t<li> 1 </li> \n\t<li> 2 </li> \n\t<li> 3 fizz </li> \n\t<li> 4 </li> \n\t<li> 5 buzz </li> \n\t<li> 6 fizz </li> \n\t<li> 7 </li> \n\t<li> 8 </li> \n</ul>")
end
end
@DavidBechtel
Copy link
Author

Rspec test for Presents.rb program.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment