Sha256: c0f5dbfa79dfbcb61e045bd3a889ceb7355ec54fe698a41d8203ce1ca55b4433
Contents?: true
Size: 1.49 KB
Versions: 1
Compression:
Stored size: 1.49 KB
Contents
require 'rspec' require 'roller/roll' describe "roll with base ruleset" do let(:rand_generator) do rand_generator = double('rand_gen').as_null_object rand_generator.stub(:rand).and_return(1,2,3,4,5,6,7,8,9,10) rand_generator end let(:mock_obj_hash) { Hash[:rand_generator, rand_generator] } describe "rerolls" do it "rerolls all dice that match the parameter" do roll = Roll.new(5, mock_obj_hash) roll.reroll(3).should == [1,2,6,4,5] end it "rerolls all dice that match any of the parameters" do roll = Roll.new(5, mock_obj_hash) roll.reroll(3,4).should == [1,2,6,7,5] end it "applies until it can't" do rand_generator = double('rand_gen').as_null_object rand_generator.stub(:rand).and_return(1,1,1,4) roll = Roll.new(1, Hash[:rand_generator, rand_generator]) roll.reroll(1).should == [4] end end describe "explode" do it "adds die to the result of all dice that match the parameter" do roll = Roll.new(5, mock_obj_hash) roll.explode(3).should == [1,2,9,4,5] end it "adds die to the result of all dice that match any of the parameters" do roll = Roll.new(5, mock_obj_hash) roll.explode(3,4).should == [1,2,9,11,5] end it "applies until it can't" do rand_generator = double('rand_gen').as_null_object rand_generator.stub(:rand).and_return(10,10,10,9) roll = Roll.new(1, Hash[:rand_generator, rand_generator]) roll.explode(10).should == [39] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
diceroller-0.0.3 | spec/roller/base_ruleset_spec.rb |