【发布时间】:2014-07-11 14:20:20
【问题描述】:
我有以下代码:
it 'draws one h-segment of colour C' do
editor.send :create_image, 3, 2
pp editor.image
expect {
pp editor.image # => [["O", "O", "O"], ["O", "O", "O"]]
editor.send :draw_horizontal, 0, 1, 0, 'C'
pp editor.image # => [["C", "C", "O"], ["O", "O", "O"]]
}.to change{
editor.image
}.
from([["O", "O", "O"], ["O", "O", "O"]]).
to [["C", "C", "O"], ["O", "O", "O"]]
end
因为调用方法 :draw_horizontal 之前和之后的两行都返回了我在 from 和 to 匹配器中的内容,所以我希望测试能够通过。
实际上,我得到了这个错误:
Failure/Error: expect { expected result to have initially been [["O", "O", "O"], ["O", "O", "O"]], but was [["C", "C", "O"], ["O", "O", "O"]]
我也尝试删除from,只留下to,但结果是这样
Failure/Error: expect { expected result to have changed to [["C", "C", "O"], ["O", "O", "O"]], but did not change
任何想法如何解决它?谢谢
【问题讨论】:
标签: ruby-on-rails ruby rspec