Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.4
2.4.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try not to change these files in a feature change

27 changes: 27 additions & 0 deletions models/sarahb_fizzbuzz.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

class Fizzbuzz

def initialize number
@fizzbuzz = number
end

def string
x = @fizzbuzz
case
when x % 3 == 0 && x % 5 == 0
"fizzbuzz"
when x % 3 == 0
"fizz"
when x % 5 == 0
"buzz"
else
x
end
end
end


(1..100).each do |n|
fb = Fizzbuzz.new(n)
puts (fb.string)
end
25 changes: 25 additions & 0 deletions specs/models/sarahb_fizzbuzz_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
require 'rspec'
require_relative "../../models/sarahb_fizzbuzz"

describe 'fizzbuzz' do
it " returns 1" do
fb = Fizzbuzz.new(1)
expect(fb.string).to eq(1)
end
it "returns fizz for a multiple of 3" do
fb = Fizzbuzz.new(3)
expect(fb.string).to eq('fizz')
end
it 'returns buzz for a multiple 5' do
fb = Fizzbuzz.new(5)
expect(fb.string).to eq('buzz')

end
it 'returns fizzbuzz for multiples of 3 and 5' do
fb = Fizzbuzz.new(15)
expect(fb.string).to eq('fizzbuzz')
end

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

watch spare lines between 'end'

end

puts Fizzbuzz.new(15).string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rogue puts