Rounding problem with rspec tests when comparing float arrays

后端 未结 1 1080
旧巷少年郎
旧巷少年郎 2021-02-19 11:02

There is a method which result I want to check:

 result.should  == [1.0,2.0,3.0]

But I get an error:

   expected: [1.0, 2.0, 3.         


        
1条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-19 11:55

    Use:

     .should be_close
    

    Or even:

     .should be_within
    

    Ref here http://rubydoc.info/gems/rspec-expectations/2.4.0/RSpec/Matchers

    0 讨论(0)
提交回复
热议问题