Skip to content

Instantly share code, notes, and snippets.

@TayKangSheng
Created November 29, 2020 10:13
Show Gist options
  • Save TayKangSheng/b3552d27c864a158d7f16657ef5118e2 to your computer and use it in GitHub Desktop.
Save TayKangSheng/b3552d27c864a158d7f16657ef5118e2 to your computer and use it in GitHub Desktop.
cyber-dojo.org - FizzBuzz
require "rspec/autorun"
class FizzBuzz
def call
end
end
describe FizzBuzz do
let(:subject) { FizzBuzz.new }
describe "call" do
let(:output) { subject.call }
it "returns an array" do
expect(output).to be_an Array
end
it "returns an array of length 100" do
expect(output.length).to eq 100
end
it "returns 1 as the first value" do
expect(output[0]).to eq 1
end
it "returns 'Fizz' on multiples of 3" do
expect(output[2]).to eq 'Fizz'
expect(output[5]).to eq 'Fizz'
expect(output[8]).to eq 'Fizz'
end
it "returns 'Buzz' on multiples of 5" do
expect(output[4]).to eq "Buzz"
expect(output[9]).to eq "Buzz"
expect(output[19]).to eq "Buzz"
end
it "returns 'FizzBuzz' on multiples of 5 and 3" do
expect(output[14]).to eq "FizzBuzz"
expect(output[29]).to eq "FizzBuzz"
expect(output[44]).to eq "FizzBuzz"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment