Last active
December 31, 2015 09:09
-
-
Save brittanmcg/7965083 to your computer and use it in GitHub Desktop.
This should return any random number or letter passed into the array. It does from what I can tell but it doesn't pass the specs.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Die | |
def initialize(labels) | |
if labels.empty? | |
raise ArgumentError | |
end | |
@labels = labels | |
end | |
def sides | |
@labels.length | |
end | |
def roll | |
random = @labels.shuffle | |
random[1] | |
end | |
end | |
#test------------------------------------------------------ | |
it 'returns a single letter if one label is passed in' do | |
random_letter = ('A'..'Z').to_a[rand(26)] | |
die = Die.new([random_letter]) | |
#end test-------------------------------------------------- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment