28
Çünkü bu kafa karıştırıcı sonucun soruyorum:
describe Object do
it "passes, as expected" do
foo = mock('foo')
foo.should_receive(:bar).once.ordered.with(1)
foo.should_receive(:bar).once.ordered.with(2)
foo.bar(1)
foo.bar(2)
end
it "fails, as expected" do
foo = mock('foo')
foo.should_receive(:bar).once.ordered.with(1) # => Mock "foo" expected :bar with (1) once, but received it twice
foo.should_receive(:bar).once.ordered.with(2)
foo.bar(1)
foo.bar(1)
foo.bar(2)
end
it "fails, as expected" do
foo = mock('foo')
foo.should_receive(:bar).once.ordered.with(1)
foo.should_receive(:bar).once.ordered.with(2)
foo.bar(2) # => Mock "foo" received :bar out of order
foo.bar(1)
end
it "fails, as expected, but with an unexpected message" do
foo = mock('foo')
foo.should_receive(:bar).once.ordered.with(1)
foo.should_receive(:bar).once.ordered.with(2)
foo.bar(1)
foo.bar(999) # => Mock "foo" received :bar with unexpected arguments
# => expected: (1)
# => got (999)
end
end
Geçen başarısızlık mesaj "beklenen: (2)" beklenen değil, "beklenen (1)". Rspec'i yanlış kullandım mı?
iyidir Yani: Hatalı bir hata iletisi değiştirir "(1) var Beklenen (999)" "beklenen: (2) bir kez, ama alınan 0 kez bir bar vardır." Için Tam olarak noktasına, ama en azından ben ne başlamıştı gibi düz dışarı yalan değil. Ama şimdi tespit etmekte başarısız: foo.bar (1); foo.bar (999); foo.bar (2). biri daha gerçekçi hata mesajı almak için bazı hataları tespit yeteneğini uzak ticarete sahip sanki gibi görünüyor. Senin hatan değil, biliyorum. –