From 620569529699b2c2658702a79422ca2242628149 Mon Sep 17 00:00:00 2001 From: Rudresh Amin Date: Thu, 7 Sep 2017 19:41:24 -0700 Subject: [PATCH 1/8] Add solution to Two Fer. --- config.json | 10 +++++++++ exercises/two-fer/README.md | 37 +++++++++++++++++++++++++++++++ exercises/two-fer/two_fer_test.rb | 37 +++++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+) create mode 100644 exercises/two-fer/README.md create mode 100644 exercises/two-fer/two_fer_test.rb diff --git a/config.json b/config.json index 1ca3cf464c..f3d097c4f7 100644 --- a/config.json +++ b/config.json @@ -175,6 +175,16 @@ ] }, + { + "uuid": "8d345e34-e815-49cd-91ab-ca8db63b07ef", + "slug": "two-fer", + "core": false, + "unlocked_by": null, + "difficulty": 1, + "topics": [ + + ] + }, { "uuid": "4fc25295-5d6a-4d13-9b87-064167d8980e", "slug": "sum-of-multiples", diff --git a/exercises/two-fer/README.md b/exercises/two-fer/README.md new file mode 100644 index 0000000000..6b0adc751b --- /dev/null +++ b/exercises/two-fer/README.md @@ -0,0 +1,37 @@ +`Two-fer` or `2-fer` is short for two for one. One for you and one for me. + +``` +"One for X, one for me." +``` + +When X is a name or "you". + +If the given name is "Alice", the result should be "One for Alice, one for me." +If no name is given, the result should be "One for you, one for me." + +* * * * + +For installation and learning resources, refer to the +[exercism help page](http://exercism.io/languages/ruby). + +For running the tests provided, you will need the Minitest gem. Open a +terminal window and run the following command to install minitest: + + gem install minitest + +If you would like color output, you can `require 'minitest/pride'` in +the test file, or note the alternative instruction, below, for running +the test file. + +In order to run the test, you can run the test file from the exercise +directory. For example, if the test suite is called +`hello_world_test.rb`, you can run the following command: + + ruby hello_world_test.rb + +To include color from the command line: + + ruby -r minitest/pride hello_world_test.rb + +## Submitting Incomplete Solutions +It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/two-fer/two_fer_test.rb b/exercises/two-fer/two_fer_test.rb new file mode 100644 index 0000000000..c30cd7021e --- /dev/null +++ b/exercises/two-fer/two_fer_test.rb @@ -0,0 +1,37 @@ +require 'minitest/autorun' +require_relative 'two_fer' + +class TwoFerTest < Minitest::Test + def test_no_name_given + assert_equal TwoFer.getResponse(""), "One for you, one for me." + end + + def test_name_given + assert_equal TwoFer.getResponse("Alice"), "One for Alice, one for me." + end + + def test_another_name_given + assert_equal TwoFer.getResponse("Bob"), "One for Bob, one for me." + end + + # Problems in exercism evolve over time, as we find better ways to ask + # questions. + # The version number refers to the version of the problem you solved, + # not your solution. + # + # Define a constant named VERSION inside of the top level BookKeeping + # module. + # In your file, it will look like this: + # + # module BookKeeping + # VERSION = 1 # Where the version number matches the one in the test. + # end + # + # If you are curious, read more about constants on RubyDoc: + # http://ruby-doc.org/docs/ruby-doc-bundle/UsersGuide/rg/constants.html + + def test_bookkeeping + assert_equal 1, BookKeeping::VERSION + end + +end From e23aac8c7673136dbdb58b9f1c13fe1a63e903ce Mon Sep 17 00:00:00 2001 From: Rudresh Amin Date: Thu, 7 Sep 2017 19:41:24 -0700 Subject: [PATCH 2/8] Add missing .meta folder for Two Fer. --- exercises/two-fer/.meta/solutions/two_fer.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 exercises/two-fer/.meta/solutions/two_fer.rb diff --git a/exercises/two-fer/.meta/solutions/two_fer.rb b/exercises/two-fer/.meta/solutions/two_fer.rb new file mode 100644 index 0000000000..676478e416 --- /dev/null +++ b/exercises/two-fer/.meta/solutions/two_fer.rb @@ -0,0 +1,13 @@ +module BookKeeping + VERSION = 1 +end + +class TwoFer + def self.getResponse(name) + unless name.empty? + sprintf("One for %s, one for me.", name) + else + "One for you, one for me." + end + end +end From 0e403ac35512f4b680c881bb50ecaff25816a08f Mon Sep 17 00:00:00 2001 From: Rudresh Amin Date: Fri, 8 Sep 2017 09:37:08 -0700 Subject: [PATCH 3/8] Properly generate tests for Two-fer using generator. Update README to have proper commands. Update config.json to include topics for Two-fer. --- config.json | 21 ++++++++++---------- exercises/two-fer/.meta/solutions/two_fer.rb | 2 +- exercises/two-fer/README.md | 4 ++-- exercises/two-fer/two_fer_test.rb | 18 +++++++++-------- 4 files changed, 24 insertions(+), 21 deletions(-) diff --git a/config.json b/config.json index f3d097c4f7..133c9906c3 100644 --- a/config.json +++ b/config.json @@ -175,16 +175,6 @@ ] }, - { - "uuid": "8d345e34-e815-49cd-91ab-ca8db63b07ef", - "slug": "two-fer", - "core": false, - "unlocked_by": null, - "difficulty": 1, - "topics": [ - - ] - }, { "uuid": "4fc25295-5d6a-4d13-9b87-064167d8980e", "slug": "sum-of-multiples", @@ -905,6 +895,17 @@ "uuid": "89bd3d71-000f-4cd9-9a84-ad1b22ddbd33", "slug": "point-mutations", "deprecated": true + }, + { + "uuid": "8d345e34-e815-49cd-91ab-ca8db63b07ef", + "slug": "two-fer", + "core": false, + "unlocked_by": null, + "difficulty": 1, + "topics": [ + "Control-flow (conditionals)", + "Strings" + ] } ], "foregone": [ diff --git a/exercises/two-fer/.meta/solutions/two_fer.rb b/exercises/two-fer/.meta/solutions/two_fer.rb index 676478e416..fe9d04d74f 100644 --- a/exercises/two-fer/.meta/solutions/two_fer.rb +++ b/exercises/two-fer/.meta/solutions/two_fer.rb @@ -1,5 +1,5 @@ module BookKeeping - VERSION = 1 + VERSION = 3 end class TwoFer diff --git a/exercises/two-fer/README.md b/exercises/two-fer/README.md index 6b0adc751b..46096813cd 100644 --- a/exercises/two-fer/README.md +++ b/exercises/two-fer/README.md @@ -27,11 +27,11 @@ In order to run the test, you can run the test file from the exercise directory. For example, if the test suite is called `hello_world_test.rb`, you can run the following command: - ruby hello_world_test.rb + ruby two_fer_test.rb To include color from the command line: - ruby -r minitest/pride hello_world_test.rb + ruby -r minitest/pride two_fer_test.rb ## Submitting Incomplete Solutions It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/two-fer/two_fer_test.rb b/exercises/two-fer/two_fer_test.rb index c30cd7021e..f364f293e9 100644 --- a/exercises/two-fer/two_fer_test.rb +++ b/exercises/two-fer/two_fer_test.rb @@ -1,17 +1,18 @@ require 'minitest/autorun' require_relative 'two_fer' +# Common test data version: 1.1.0 c080bdf class TwoFerTest < Minitest::Test def test_no_name_given - assert_equal TwoFer.getResponse(""), "One for you, one for me." + assert_equal "One for you, one for me.", TwoFer.getResponse('') end - def test_name_given - assert_equal TwoFer.getResponse("Alice"), "One for Alice, one for me." + def test_a_name_given + assert_equal "One for Alice, one for me.", TwoFer.getResponse('Alice') end def test_another_name_given - assert_equal TwoFer.getResponse("Bob"), "One for Bob, one for me." + assert_equal "One for Bob, one for me.", TwoFer.getResponse('Bob') end # Problems in exercism evolve over time, as we find better ways to ask @@ -20,8 +21,9 @@ def test_another_name_given # not your solution. # # Define a constant named VERSION inside of the top level BookKeeping - # module. - # In your file, it will look like this: + # module, which may be placed near the end of your file. + # + # In your file, it will look like this: # # module BookKeeping # VERSION = 1 # Where the version number matches the one in the test. @@ -31,7 +33,7 @@ def test_another_name_given # http://ruby-doc.org/docs/ruby-doc-bundle/UsersGuide/rg/constants.html def test_bookkeeping - assert_equal 1, BookKeeping::VERSION + skip + assert_equal 3, BookKeeping::VERSION end - end From f780ecea9c68b18b00d413f7996444da0f855651 Mon Sep 17 00:00:00 2001 From: Rudresh Amin Date: Fri, 8 Sep 2017 09:39:30 -0700 Subject: [PATCH 4/8] Update Two-fer README to have correct test commands. --- exercises/two-fer/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/two-fer/README.md b/exercises/two-fer/README.md index 46096813cd..f7a68d28df 100644 --- a/exercises/two-fer/README.md +++ b/exercises/two-fer/README.md @@ -25,7 +25,7 @@ the test file. In order to run the test, you can run the test file from the exercise directory. For example, if the test suite is called -`hello_world_test.rb`, you can run the following command: +`two_fer_test.rb`, you can run the following command: ruby two_fer_test.rb From 822a6841e178433d10e1880b68036db9d96d3268 Mon Sep 17 00:00:00 2001 From: Rudresh Amin Date: Fri, 8 Sep 2017 09:41:12 -0700 Subject: [PATCH 5/8] Reinsert skip statements to Two Fer tests. --- exercises/two-fer/two_fer_test.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/exercises/two-fer/two_fer_test.rb b/exercises/two-fer/two_fer_test.rb index f364f293e9..2cacc947fd 100644 --- a/exercises/two-fer/two_fer_test.rb +++ b/exercises/two-fer/two_fer_test.rb @@ -4,14 +4,17 @@ # Common test data version: 1.1.0 c080bdf class TwoFerTest < Minitest::Test def test_no_name_given + # skip assert_equal "One for you, one for me.", TwoFer.getResponse('') end def test_a_name_given + skip assert_equal "One for Alice, one for me.", TwoFer.getResponse('Alice') end def test_another_name_given + skip assert_equal "One for Bob, one for me.", TwoFer.getResponse('Bob') end From 02f0779b6ca71c2f64ff53f69f81a770aea1e143 Mon Sep 17 00:00:00 2001 From: Rudresh Amin Date: Fri, 8 Sep 2017 10:43:56 -0700 Subject: [PATCH 6/8] Add generator for Two-fer. --- exercises/two-fer/.meta/.version | 1 + exercises/two-fer/.meta/generator/two_fer_case.rb | 9 +++++++++ 2 files changed, 10 insertions(+) create mode 100644 exercises/two-fer/.meta/.version create mode 100644 exercises/two-fer/.meta/generator/two_fer_case.rb diff --git a/exercises/two-fer/.meta/.version b/exercises/two-fer/.meta/.version new file mode 100644 index 0000000000..e440e5c842 --- /dev/null +++ b/exercises/two-fer/.meta/.version @@ -0,0 +1 @@ +3 \ No newline at end of file diff --git a/exercises/two-fer/.meta/generator/two_fer_case.rb b/exercises/two-fer/.meta/generator/two_fer_case.rb new file mode 100644 index 0000000000..133a354ae9 --- /dev/null +++ b/exercises/two-fer/.meta/generator/two_fer_case.rb @@ -0,0 +1,9 @@ +require 'generator/exercise_case' + +class TwoFerCase < Generator::ExerciseCase + + def workload + assert_equal { "TwoFer.getResponse('#{input}')" } + end + +end From 33ce6aae94953974721d740251af277c2f627580 Mon Sep 17 00:00:00 2001 From: Rudresh Amin Date: Fri, 8 Sep 2017 10:57:29 -0700 Subject: [PATCH 7/8] Update version to 1 for Two-fer tests. --- exercises/two-fer/.meta/.version | 2 +- exercises/two-fer/.meta/solutions/two_fer.rb | 2 +- exercises/two-fer/two_fer_test.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/exercises/two-fer/.meta/.version b/exercises/two-fer/.meta/.version index e440e5c842..56a6051ca2 100644 --- a/exercises/two-fer/.meta/.version +++ b/exercises/two-fer/.meta/.version @@ -1 +1 @@ -3 \ No newline at end of file +1 \ No newline at end of file diff --git a/exercises/two-fer/.meta/solutions/two_fer.rb b/exercises/two-fer/.meta/solutions/two_fer.rb index fe9d04d74f..676478e416 100644 --- a/exercises/two-fer/.meta/solutions/two_fer.rb +++ b/exercises/two-fer/.meta/solutions/two_fer.rb @@ -1,5 +1,5 @@ module BookKeeping - VERSION = 3 + VERSION = 1 end class TwoFer diff --git a/exercises/two-fer/two_fer_test.rb b/exercises/two-fer/two_fer_test.rb index 2cacc947fd..2cedfda54e 100644 --- a/exercises/two-fer/two_fer_test.rb +++ b/exercises/two-fer/two_fer_test.rb @@ -37,6 +37,6 @@ def test_another_name_given def test_bookkeeping skip - assert_equal 3, BookKeeping::VERSION + assert_equal 1, BookKeeping::VERSION end end From 4d4a707e10d69bd29ccb1e7213dfd7e41d6aa374 Mon Sep 17 00:00:00 2001 From: Rudresh Amin Date: Fri, 8 Sep 2017 11:35:54 -0700 Subject: [PATCH 8/8] Clean up Two-fer README. --- exercises/two-fer/README.md | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/exercises/two-fer/README.md b/exercises/two-fer/README.md index f7a68d28df..15ce3d2bec 100644 --- a/exercises/two-fer/README.md +++ b/exercises/two-fer/README.md @@ -14,24 +14,5 @@ If no name is given, the result should be "One for you, one for me." For installation and learning resources, refer to the [exercism help page](http://exercism.io/languages/ruby). -For running the tests provided, you will need the Minitest gem. Open a -terminal window and run the following command to install minitest: - - gem install minitest - -If you would like color output, you can `require 'minitest/pride'` in -the test file, or note the alternative instruction, below, for running -the test file. - -In order to run the test, you can run the test file from the exercise -directory. For example, if the test suite is called -`two_fer_test.rb`, you can run the following command: - - ruby two_fer_test.rb - -To include color from the command line: - - ruby -r minitest/pride two_fer_test.rb - ## Submitting Incomplete Solutions It's possible to submit an incomplete solution so you can see how others have completed the exercise.