1 require File.expand_path(File.dirname(__FILE__) + '/edgecase')
3 # Implement a DiceSet Class here:
13 @values = (1..n).map { rand(6) + 1 }
18 class AboutDiceProject < EdgeCase::Koan
19 def test_can_create_a_dice_set
24 def test_rolling_the_dice_returns_a_set_of_integers_between_1_and_6
28 assert dice.values.is_a?(Array), "should be an array"
29 assert_equal 5, dice.values.size
30 dice.values.each do |value|
31 assert value >= 1 && value <= 6, "value #{value} must be between 1 and 6"
35 def test_dice_values_do_not_change_unless_explicitly_rolled
38 first_time = dice.values
39 second_time = dice.values
40 assert_equal first_time, second_time
43 def test_dice_values_should_change_between_rolls
47 first_time = dice.values
50 second_time = dice.values
52 assert_not_equal first_time, second_time,
53 "Two rolls should not be equal"
57 # If the rolls are random, then it is possible (although not
58 # likely) that two consecutive rolls are equal. What would be a
59 # better way to test this.
62 def test_you_can_roll_different_numbers_of_dice
66 assert_equal 3, dice.values.size
69 assert_equal 1, dice.values.size