spec/exponential_spec.rb in distribution-0.7.0 vs spec/exponential_spec.rb in distribution-0.7.1
- old
+ new
@@ -74,7 +74,21 @@
# end
# it_should_behave_like "exponential engine"
#
# end
# end
-
+ describe "rng" do
+ it "should default to Kernel#rand if no :random is given" do
+ Random.stub(:rand)
+ Random.should_receive(:rand).and_return(0.5)
+ rng = Distribution::Exponential.rng 1.0
+ rng.call()
+ end
+
+ it "should use a given rng if one is passed during construction" do
+ random = double("random")
+ random.should_receive(:rand).and_return(0.5)
+ rng = Distribution::Exponential::rng 1.0, :random => random
+ rng.call()
+ end
+ end
end