Skip to content
Closed
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
11 changes: 11 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
1 change: 1 addition & 0 deletions exercises/two-fer/.meta/.version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
9 changes: 9 additions & 0 deletions exercises/two-fer/.meta/generator/two_fer_case.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require 'generator/exercise_case'

class TwoFerCase < Generator::ExerciseCase

def workload
assert_equal { "TwoFer.getResponse('#{input}')" }
end

end
13 changes: 13 additions & 0 deletions exercises/two-fer/.meta/solutions/two_fer.rb
Original file line number Diff line number Diff line change
@@ -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
18 changes: 18 additions & 0 deletions exercises/two-fer/README.md
Original file line number Diff line number Diff line change
@@ -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.
42 changes: 42 additions & 0 deletions exercises/two-fer/two_fer_test.rb
Original file line number Diff line number Diff line change
@@ -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