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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,4 @@ The browser extension will also highlight the newly covered lines in `foo_bar.rb

2. Commit to `demo-branch`. You should now see duplication issues reported by Code Climate.


23 changes: 22 additions & 1 deletion foo_bar.rb
Original file line number Diff line number Diff line change
@@ -1 +1,22 @@
# TODO: Add FooBar content
class FooBar
def run(items = gets.chomp.to_i)
if items > 0
list = []
(1..items).each do |n|
if n % 3 == 0 && n % 5 == 0
list << "FOOBAR"
elsif n % 3 == 0
list << "FOO"
elsif n % 5 == 0
list << "BAR"
else
list << n
end
end
else
puts "Please enter a positive number"
end

list
end
end
25 changes: 24 additions & 1 deletion spec/foo_bar_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
require "spec_helper"
require_relative "../foo_bar"

# TODO: Add FooBar specs
describe "FooBar" do
it "returns correct list of items" do
result = FooBar.new.run(15)

expect(result.length).to eq(15)
expect(result).to eq([
1,
2,
"FOO",
4,
"BAR",
"FOO",
7,
8,
"FOO",
"BAR",
11,
"FOO",
13,
14,
"FOOBAR",
])
end
end