Sha256: ab365c4d9e6106d519c82c2027620cff272a06bb51f62db859efae519c9b8d3e

Contents?: true

Size: 907 Bytes

Versions: 19

Compression:

Stored size: 907 Bytes

Contents

require 'games_dice'

describe GamesDice::Dice do

  describe "dice scheme" do

    before :each do
      srand(67809)
    end

    describe '1d10+2' do
      let(:dice) { GamesDice::Dice.new( [ { :sides => 10, :ndice => 1 } ], 2 ) }

      it "should simulate rolling a ten-sided die, and adding two to each result" do
        [5,4,10,10,7,5,9].each do |expected_total|
          dice.roll.should == expected_total
          dice.result.should == expected_total
        end
      end
    end

    describe '2d6+6' do
      let(:dice) { GamesDice::Dice.new( [ { :sides => 6, :ndice => 2 } ], 6) }

      it "should simulate rolling two six-sided dice and adding six to the result" do
        [15,12,17,15,13,13,16].each do |expected_total|
          dice.roll.should == expected_total
          dice.result.should == expected_total
        end
      end
    end

  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
games_dice-0.3.9 spec/dice_spec.rb
games_dice-0.3.8 spec/dice_spec.rb
games_dice-0.3.7 spec/dice_spec.rb
games_dice-0.3.6 spec/dice_spec.rb
games_dice-0.3.5 spec/dice_spec.rb
games_dice-0.3.3 spec/dice_spec.rb
games_dice-0.3.2 spec/dice_spec.rb
games_dice-0.3.1 spec/dice_spec.rb
games_dice-0.3.0 spec/dice_spec.rb
games_dice-0.2.4 spec/dice_spec.rb
games_dice-0.2.3 spec/dice_spec.rb
games_dice-0.2.2 spec/dice_spec.rb
games_dice-0.2.1 spec/dice_spec.rb
games_dice-0.2.0 spec/dice_spec.rb
games_dice-0.1.3 spec/dice_spec.rb
games_dice-0.1.2 spec/dice_spec.rb
games_dice-0.1.1 spec/dice_spec.rb
games_dice-0.0.6 spec/dice_spec.rb
games_dice-0.0.5 spec/dice_spec.rb