2012-11-27 135 views

回答

7

不必RSpec的手,现在来验证,但我认为这应该上班:

x.should > y 
+4

'should'在最近的版本中被弃用,使用'expect(x).to be> y' – Micah

1

这不适合你吗?

x.should be > y 

,你也可以尝试一个更直观的测试框架 - Specular

那么你可以:

is?(x) > y 
expect(x) > y 
check(x) > y 
etc. 
+0

如果它不支持表测试比rspec的更好不感兴趣。 – Reactormonk

+0

对不起?桌面测试?我走出轨道? – 2012-11-27 20:54:56

+0

您在框架中引入了一堆数据行,并执行每行预测。 – Reactormonk

4

还有另一种方法来匹配不等式:

x.should be_greater_than_or_equal_to(y) 
x.should be_less_than_or_equal_to(y) 
x.should be_greater_than(y) 
x.should be_less_than(y) 
39

使用RSpec的2.14和预期的语法,这可以这样表示:

expect(x).to be > y