Skip to content

Instantly share code, notes, and snippets.

@carlesjove
Created January 19, 2015 06:47
Show Gist options
  • Save carlesjove/948ff8b59ea60ca1dfe9 to your computer and use it in GitHub Desktop.
Save carlesjove/948ff8b59ea60ca1dfe9 to your computer and use it in GitHub Desktop.
SO 28002853
require "minitest/autorun"
12
11 module Numerics
10 def twenty_one?(*nums)
9 nums.inject(&:+) == 21
8 end
7 end
6
5 class TestNumerics < MiniTest::Test
4 include Numerics
3
2 def test_twenty_one?
1 assert_equal twenty_one?(3, 4, 5, 6, 3), true
14 assert_equal twenty_one?(3, 11, 10), false
1 end
2 end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment