我写了一个简单的类方法Buy.get_days(string),并试图用不同的文本字符串输入进行测试.但是我觉得这很冗长.
>有没有更简洁的方法来测试以下内容?
有没有
相当于我可以继续通过的方法的主题
不同的参数和检查结果?
有没有办法避免不必要的描述呢?
谢谢
describe Buy do describe '.get_days' do it 'should get days' do Buy.get_days('Includes a 1-weeknight stay for up to 4 people') .should == 1 end it 'should get days' do Buy.get_days('Includes a 1-night stay in a King Studio Room with stone fireplace') .should == 1 end it 'should get days' do Buy.get_days('Includes 4 nights/5 days at the Finisterra Hotel for up to two adults and two children (staying in the same room)') .should == 4 end end end