Sha256: 104c165ef34833bd3e1d7a2dc0237c67dbf5a7da42322ac84181aa02b713ade5
Contents?: true
Size: 1.22 KB
Versions: 1
Compression:
Stored size: 1.22 KB
Contents
require 'rspec' require 'roller/roll' describe Roll 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 "by default" do it "uses the base ruleset" do roll = Roll.new(1) roll.is_a?(Ruleset::BaseRuleset).should be_true end end describe "roll" do it "should have <parameters> elements" do roll = Roll.new(2, mock_obj_hash) roll.should have(2).items end it "returns a list of numbers" do roll = Roll.new(10, mock_obj_hash) roll.should == [1,2,3,4,5,6,7,8,9,10] end it "calls Random once for each call" do Random.should_receive(:rand).exactly(5) roll = Roll.new(5) end it "calls Random with default value of 10 when no options provided" do Random.should_receive(:rand).with(10).exactly(5) roll = Roll.new(5) end it "calls Random with specified value if options provided" do options = { :die_size => 8, :rand_generator => Random } Random.should_receive(:rand).with(8).exactly(5) roll = Roll.new(5, options) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
diceroller-0.0.3 | spec/roller/roll_spec.rb |