diff --git a/config.json b/config.json index 1ca3cf464c..133c9906c3 100644 --- a/config.json +++ b/config.json @@ -895,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/.version b/exercises/two-fer/.meta/.version new file mode 100644 index 0000000000..56a6051ca2 --- /dev/null +++ b/exercises/two-fer/.meta/.version @@ -0,0 +1 @@ +1 \ 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 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 diff --git a/exercises/two-fer/README.md b/exercises/two-fer/README.md new file mode 100644 index 0000000000..15ce3d2bec --- /dev/null +++ b/exercises/two-fer/README.md @@ -0,0 +1,18 @@ +`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). + +## 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..2cedfda54e --- /dev/null +++ b/exercises/two-fer/two_fer_test.rb @@ -0,0 +1,42 @@ +require 'minitest/autorun' +require_relative 'two_fer' + +# 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 + + # 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, 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. + # 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 + skip + assert_equal 1, BookKeeping::VERSION + end +end