Sha256: c8b0fa32f5cc674dec5926c89068832827196f3073d56735b6f14a2fe1c584af
Contents?: true
Size: 1.31 KB
Versions: 1
Compression:
Stored size: 1.31 KB
Contents
require 'helpers' describe GamesDice::MapRule do describe "#new" do it "should accept self-consistent operator/value pairs as a trigger" do GamesDice::MapRule.new( 5, :>, 1 ) GamesDice::MapRule.new( (1..5), :member?, 17 ) end it "should reject inconsistent operator/value pairs for a trigger" do lambda { GamesDice::MapRule.new( 5, :member?, -1 ) }.should raise_error( ArgumentError ) lambda { GamesDice::MapRule.new( (1..5), :>, 12 ) }.should raise_error( ArgumentError ) end it "should reject non-Integer map results" do lambda { GamesDice::MapRule.new( 5, :>, :reroll_again ) }.should raise_error( TypeError ) lambda { GamesDice::MapRule.new( (1..5), :member?, 'foo' ) }.should raise_error( TypeError ) end end describe '#map_from' do it "should return the mapped value for a match" do rule = GamesDice::MapRule.new( 5, :>, -1 ) rule.map_from(4).should == -1 rule = GamesDice::MapRule.new( (1..5), :member?, 3 ) rule.map_from(4).should == 3 end it "should return nil for no match" do rule = GamesDice::MapRule.new( 5, :>, -1 ) rule.map_from(6).should be_nil rule = GamesDice::MapRule.new( (1..5), :member?, 3 ) rule.map_from(6).should be_nil end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
games_dice-0.3.12 | spec/map_rule_spec.rb |