spec/excel_functions_spec.rb in rubyfromexcel-0.0.7 vs spec/excel_functions_spec.rb in rubyfromexcel-0.0.9
- old
+ new
@@ -171,10 +171,14 @@
describe "max" do
it "should return the argument with the greatest value" do
FunctionTest.max(1,"two",FunctionTest.a('a1','a3')).should == 100
end
+ it "should return an error if any of its inputs are errors" do
+ FunctionTest.max(1,"two",FunctionTest.a('a1','a3'),:ref).should == :ref
+ end
+
end
describe "min" do
it "should return the argument with the smallest value" do
FunctionTest.min(1000,"two",FunctionTest.a('a1','a3')).should == 10
@@ -191,10 +195,15 @@
it "should return true if passed a symbol" do
FunctionTest.iserr(:na).should == true
FunctionTest.iserr(:ref).should == true
end
+ it "should return true if passed nan or infinity" do
+ FunctionTest.iserr(0.0/0.0).should == true
+ FunctionTest.iserr(10.0/0.0).should == true
+ end
+
it "should return false if passed anything else" do
FunctionTest.iserr(123).should == false
end
end
@@ -204,10 +213,15 @@
end
it "should return its third argument if its first argument is false" do
FunctionTest.excel_if(false,:second,:third).should == :third
end
+
+ it "should have a default value of false for its second argument" do
+ FunctionTest.excel_if(true,:second).should == :second
+ FunctionTest.excel_if(false,:second).should == false
+ end
end
describe "iferror" do
it "should return its second value if there is an error in the first" do
FunctionTest.iferror(FunctionTest.index(FunctionTest.a('a1','b3'),3.0,1.0),"Not found").should == 0.0
@@ -254,9 +268,16 @@
it "should find the first occurrence of one string in another after a given index" do
FunctionTest.find("one","onetwothree",1).should == 1
FunctionTest.find("one","twoonethree",5).should == :value
FunctionTest.find("one","oneone",2).should == 4
+ end
+end
+
+describe "pmt" do
+ it "should calculate the monthly payment required for a given principal, interest rate and loan period" do
+ FunctionTest.pmt(0.1,10,100).should be_within(0.01).of(-16.27)
+ FunctionTest.pmt(0.0123,99.1,123.32).should be_within(0.01).of(-2.159)
end
end
describe "ability to respond to empty cell references" do
it "should return 0 if a reference is made to an empty cell" do
\ No newline at end of file