diff --git a/lib/saulabs/gauss/distribution.rb b/lib/saulabs/gauss/distribution.rb index 80d83a6..2d6e19a 100644 --- a/lib/saulabs/gauss/distribution.rb +++ b/lib/saulabs/gauss/distribution.rb @@ -131,6 +131,7 @@ def +(other) end def ==(other) + return false unless other.kind_of?(self.class) self.mean == other.mean && self.variance == other.variance end diff --git a/spec/saulabs/gauss/distribution_spec.rb b/spec/saulabs/gauss/distribution_spec.rb index 0006b56..12f973c 100644 --- a/spec/saulabs/gauss/distribution_spec.rb +++ b/spec/saulabs/gauss/distribution_spec.rb @@ -188,3 +188,16 @@ end end + +describe Gauss::Distribution, "#==" do + let(:distribution) { Gauss::Distribution.with_deviation(25.0, 8.333333) } + + it "should be reflexive" do + distribution.should == distribution + end + + it "should not equal any object of another class" do + distribution.should_not == Object.new + end + +end