I want those already methods to be tested, but everything I try, doesn't seem to fit with best practices nor do it work.
May be somebody can support me with this?
CODE To be tested
def any_subset_greater?
divisors_sums.any?{|sum| sum > @value}
end
def no_subset_equal?
!divisors_sums.any?{|sum| sum == @value}
end
def check_room
any_subset_greater? && no_subset_equal?
end
RSPEC TRY
first specify seems not to set proper return values for the divisors method and the instance variable @value.
describe "#any_subset_greater?" do
# Examples:
# [1,2] > 4 #=> false
# [1,2,3] > 4 #=> true
specify "returns true, when value in the array is greater" do
number.stub(:divisors){[1,2,3]}
number.stub(:value) {4}
expect(number.any_subset_greater?).to be_true
end
end
describe "#no_subset_equal?" do
# Examples:
# 4 === [1,2,4] #=> false
# 4 === [1,2,3] #=> false
# 4 === [1,2,6] #=> true
end
describe "#check_room" do
# testing condition from methods above
end