From 7d56befcf29b40ddfb1b0f3f014b4f932fd2c665 Mon Sep 17 00:00:00 2001 From: Dave Henton Date: Thu, 8 Jun 2023 11:30:03 -0500 Subject: [PATCH 1/3] Update foo_bar.rb --- foo_bar.rb | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/foo_bar.rb b/foo_bar.rb index bc32445..168d669 100644 --- a/foo_bar.rb +++ b/foo_bar.rb @@ -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 From 1d2ee787d7efd77201ece53bb1fb64a880fc165e Mon Sep 17 00:00:00 2001 From: Dave Henton Date: Thu, 8 Jun 2023 11:34:41 -0500 Subject: [PATCH 2/3] Update foo_bar_spec.rb --- spec/foo_bar_spec.rb | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/spec/foo_bar_spec.rb b/spec/foo_bar_spec.rb index 7689240..b2b3a0b 100644 --- a/spec/foo_bar_spec.rb +++ b/spec/foo_bar_spec.rb @@ -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 From 98e65aa4449e97c57c973815072deb85d90baee5 Mon Sep 17 00:00:00 2001 From: Dave Henton Date: Mon, 17 Jul 2023 11:48:45 -0500 Subject: [PATCH 3/3] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index c6889d2..595771d 100644 --- a/README.md +++ b/README.md @@ -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. +